Bugzilla – Attachment 153001 Details for
Bug 33606
Access to ERM requires parameters => 'manage_sysprefs'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33606: Add a erm/config route to retrieve the ERM config needed for the Vue app
Bug-33606-Add-a-ermconfig-route-to-retrieve-the-ER.patch (text/plain), 14.92 KB, created by
Jonathan Druart
on 2023-07-04 07:18:17 UTC
(
hide
)
Description:
Bug 33606: Add a erm/config route to retrieve the ERM config needed for the Vue app
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-07-04 07:18:17 UTC
Size:
14.92 KB
patch
obsolete
>From ecfd6d3941e47c12546a8fc1a635a7919ab024f2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 25 Apr 2023 15:56:51 +0200 >Subject: [PATCH] Bug 33606: Add a erm/config route to retrieve the ERM config > needed for the Vue app > >This could be extended later in bug 32968 to pass the permission of the >logged in user. > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/REST/V1/ERM.pm | 22 +++++++++++ > api/v1/swagger/definitions/erm_config.yaml | 7 ++++ > api/v1/swagger/paths/erm_config.yaml | 38 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 4 ++ > .../ERM/EHoldingsEBSCOPackagesList.vue | 6 +-- > .../ERM/EHoldingsEBSCOTitlesList.vue | 6 +-- > .../prog/js/vue/components/ERM/Main.vue | 28 +++++--------- > .../prog/js/vue/fetch/erm-api-client.js | 9 +++++ > t/cypress/integration/ERM/Agreements_spec.ts | 9 +---- > t/cypress/integration/ERM/Dialog_spec.ts | 9 +---- > t/cypress/integration/ERM/Licenses_spec.ts | 9 +---- > t/cypress/integration/ERM/Packages_spec.ts | 9 +---- > t/cypress/integration/ERM/Searchbar_spec.ts | 9 +---- > t/cypress/integration/ERM/Titles_spec.ts | 9 +---- > 14 files changed, 108 insertions(+), 66 deletions(-) > create mode 100644 api/v1/swagger/definitions/erm_config.yaml > create mode 100644 api/v1/swagger/paths/erm_config.yaml > >diff --git a/Koha/REST/V1/ERM.pm b/Koha/REST/V1/ERM.pm >index 3f98a8e12d6..26bcc18607f 100644 >--- a/Koha/REST/V1/ERM.pm >+++ b/Koha/REST/V1/ERM.pm >@@ -31,6 +31,28 @@ Koha::REST::V1::Acquisitions::Funds > > =head2 Class methods > >+=head3 config >+ >+Return the configuration options needed for the ERM Vue app >+ >+=cut >+ >+sub config { >+ my $c = shift->openapi->valid_input or return; >+ return $c->render( >+ status => 200, >+ openapi => { >+ settings => { >+ ERMModule => C4::Context->preference('ERMModule'), >+ ERMProviders => [split ',', C4::Context->preference('ERMProviders')] >+ }, >+ #permissions => { >+ # erm => >+ #} >+ }, >+ ) >+} >+ > =head3 list_users > > Return the list of possible ERM' users >diff --git a/api/v1/swagger/definitions/erm_config.yaml b/api/v1/swagger/definitions/erm_config.yaml >new file mode 100644 >index 00000000000..2e980775714 >--- /dev/null >+++ b/api/v1/swagger/definitions/erm_config.yaml >@@ -0,0 +1,7 @@ >+--- >+type: object >+properties: >+ settings: >+ type: object >+ description: List of sysprefs used for the ERM module >+additionalProperties: false >diff --git a/api/v1/swagger/paths/erm_config.yaml b/api/v1/swagger/paths/erm_config.yaml >new file mode 100644 >index 00000000000..d5a7d3933cd >--- /dev/null >+++ b/api/v1/swagger/paths/erm_config.yaml >@@ -0,0 +1,38 @@ >+--- >+/erm/config: >+ get: >+ x-mojo-to: ERM#config >+ operationId: getERMconfig >+ description: This resource returns a list of options needed for the ERM Vue app >+ summary: get the ERM config >+ tags: >+ - ERM >+ produces: >+ - application/json >+ responses: >+ 200: >+ description: The ERM config >+ schema: >+ $ref: "../swagger.yaml#/definitions/erm_config" >+ 400: >+ description: Bad request >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 403: >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 500: >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 503: >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ erm: 1 >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 07f27fd0d4a..fa54ecd1040 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -34,6 +34,8 @@ definitions: > $ref: ./definitions/credit.yaml > debit: > $ref: ./definitions/debit.yaml >+ erm_config: >+ $ref: ./definitions/erm_config.yaml > erm_agreement: > $ref: ./definitions/erm_agreement.yaml > erm_eholdings_title: >@@ -211,6 +213,8 @@ paths: > $ref: ./paths/config_smtp_servers.yaml#/~1config~1smtp_servers > "/config/smtp_servers/{smtp_server_id}": > $ref: "./paths/config_smtp_servers.yaml#/~1config~1smtp_servers~1{smtp_server_id}" >+ /erm/config: >+ $ref: ./paths/erm_config.yaml#/~1erm~1config > /erm/agreements: > $ref: ./paths/erm_agreements.yaml#/~1erm~1agreements > "/erm/agreements/{agreement_id}": >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >index 551b19325c7..2a5822371d9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >@@ -82,7 +82,7 @@ export default { > const { get_lib_from_av, map_av_dt_filter } = AVStore > > const ERMStore = inject("ERMStore") >- const { sysprefs } = ERMStore >+ const { config } = ERMStore > > const table = ref() > const filters = reactive({ >@@ -98,7 +98,7 @@ export default { > get_lib_from_av, > escape_str, > map_av_dt_filter, >- sysprefs, >+ config, > table, > } > }, >@@ -168,7 +168,7 @@ export default { > this.show_table = true > this.local_count_packages = null > >- if (this.sysprefs.ERMProviders.includes("local")) { >+ if (this.config.ERMProviders.includes("local")) { > const client = APIClient.erm > const query = this.filters > ? { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >index dc5cf89c7f0..a3405d50fe5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesList.vue >@@ -85,7 +85,7 @@ export default { > const { get_lib_from_av } = AVStore > > const ERMStore = inject("ERMStore") >- const { sysprefs } = ERMStore >+ const { config } = ERMStore > > const table = ref() > const filters = reactive({ >@@ -99,7 +99,7 @@ export default { > av_title_publication_types, > get_lib_from_av, > escape_str, >- sysprefs, >+ config, > table, > } > }, >@@ -179,7 +179,7 @@ export default { > "/api/v1/erm/eholdings/ebsco/titles" > ) > } >- if (this.sysprefs.ERMProviders.includes("local")) { >+ if (this.config.ERMProviders.includes("local")) { > const client = APIClient.erm > > const q = this.filters >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >index d395c26b446..12e569e28d6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >@@ -1,5 +1,5 @@ > <template> >- <div v-if="initialized && sysprefs.ERMModule == 1"> >+ <div v-if="initialized && config.settings.ERMModule == 1"> > <div id="sub-header"> > <Breadcrumbs /> > <Help /> >@@ -49,13 +49,13 @@ export default { > > const ERMStore = inject("ERMStore") > >- const { sysprefs } = storeToRefs(ERMStore) >+ const { config } = storeToRefs(ERMStore) > > return { > vendorStore, > AVStore, > ERMStore, >- sysprefs, >+ config, > setError, > loading, > loaded, >@@ -128,23 +128,15 @@ export default { > }) > ) > >- promises.push( >- sysprefs_client.sysprefs.get("ERMProviders").then( >- providers => { >- this.sysprefs.ERMProviders = providers.value.split(",") >- }, >- error => {} >- ) >- ) > return Promise.all(promises) > } > >- const sysprefs_client = APIClient.sysprefs >- sysprefs_client.sysprefs >- .get("ERMModule") >- .then(value => { >- this.sysprefs.ERMModule = value.value >- if (this.sysprefs.ERMModule != 1) { >+ const client = APIClient.erm >+ client.config >+ .get() >+ .then(config => { >+ this.config = config >+ if (this.config.settings.ERMModule != 1) { > return this.setError( > this.$__( > 'The e-resource management module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule">ERMModule</a> to use it' >@@ -164,7 +156,7 @@ export default { > const eHoldings = navigationTree.find( > element => element.path === "/cgi-bin/koha/erm/eholdings" > ) >- const providers = this.sysprefs.ERMProviders >+ const providers = this.config.settings.ERMProviders > eHoldings.children = eHoldings.children.filter(element => > providers > .map(provider => `${eHoldings.path}/${provider}`) >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index f9be2c5aa07..0acdcac5a46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >@@ -7,6 +7,15 @@ export class ERMAPIClient extends HttpClient { > }); > } > >+ get config() { >+ return { >+ get: () => >+ this.get({ >+ endpoint: "config", >+ }), >+ }; >+ } >+ > get agreements() { > return { > get: id => >diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts >index 5638fb9d9ee..83080dae380 100644 >--- a/t/cypress/integration/ERM/Agreements_spec.ts >+++ b/t/cypress/integration/ERM/Agreements_spec.ts >@@ -122,13 +122,8 @@ describe("Agreement CRUD operations", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >diff --git a/t/cypress/integration/ERM/Dialog_spec.ts b/t/cypress/integration/ERM/Dialog_spec.ts >index 3333218651d..d09fe8ce100 100644 >--- a/t/cypress/integration/ERM/Dialog_spec.ts >+++ b/t/cypress/integration/ERM/Dialog_spec.ts >@@ -27,13 +27,8 @@ describe("Dialog operations", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts >index 6d79f896334..c296091c1cc 100644 >--- a/t/cypress/integration/ERM/Licenses_spec.ts >+++ b/t/cypress/integration/ERM/Licenses_spec.ts >@@ -38,13 +38,8 @@ describe("License CRUD operations", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts >index 172e9ecf6b2..0c0f73be5ad 100644 >--- a/t/cypress/integration/ERM/Packages_spec.ts >+++ b/t/cypress/integration/ERM/Packages_spec.ts >@@ -29,13 +29,8 @@ describe("Package CRUD operations", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >diff --git a/t/cypress/integration/ERM/Searchbar_spec.ts b/t/cypress/integration/ERM/Searchbar_spec.ts >index a5caf780b1c..af55bf601cc 100644 >--- a/t/cypress/integration/ERM/Searchbar_spec.ts >+++ b/t/cypress/integration/ERM/Searchbar_spec.ts >@@ -6,13 +6,8 @@ describe("Searchbar header changes", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts >index d08b350d313..2f1f6c826ab 100644 >--- a/t/cypress/integration/ERM/Titles_spec.ts >+++ b/t/cypress/integration/ERM/Titles_spec.ts >@@ -23,13 +23,8 @@ describe("Title CRUD operations", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > }); > >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33606
:
150204
|
151276
|
151277
|
151333
|
151334
|
151350
|
151351
|
151352
|
152614
|
152615
|
152616
|
152617
| 153001 |
153002
|
153003
|
153004