Bugzilla – Attachment 151350 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
Pedro Amorim
on 2023-05-17 16:34:11 UTC
(
hide
)
Description:
Bug 33606: Add a erm/config route to retrieve the ERM config needed for the Vue app
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-05-17 16:34:11 UTC
Size:
14.92 KB
patch
obsolete
>From 54829f0656b00d87c75ac9c75661b65bf593ff32 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> >--- > 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 | 29 ++++++-------- > .../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, 109 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 3f98a8e12d..26bcc18607 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 0000000000..2e98077571 >--- /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 0000000000..d5a7d3933c >--- /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 23c59b96a1..6dfb88025e 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: >@@ -209,6 +211,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 d2573e988f..f4b84d3628 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 c29c9a2783..f0ee952558 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, > } > }, >@@ -178,7 +178,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 c9988df104..9338ac393e 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"> > <Breadcrumb /> > <Help /> >@@ -48,7 +48,8 @@ > <li> > <ul> > <li >- v-for="provider in sysprefs.ERMProviders" >+ v-for="provider in config >+ .settings.ERMProviders" > :key="provider" > > > <router-link >@@ -138,13 +139,13 @@ export default { > > const ERMStore = inject("ERMStore") > >- const { sysprefs } = storeToRefs(ERMStore) >+ const { config } = storeToRefs(ERMStore) > > return { > vendorStore, > AVStore, > ERMStore, >- sysprefs, >+ config, > setError, > loading, > loaded, >@@ -217,23 +218,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' >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 f9be2c5aa0..8b1b581dbf 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 5638fb9d9e..83080dae38 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 3333218651..d09fe8ce10 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 6d79f89633..c296091c1c 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 172e9ecf6b..0c0f73be5a 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 a5caf780b1..af55bf601c 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 d08b350d31..2f1f6c826a 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.30.2
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