Bugzilla – Attachment 150204 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.81 KB, created by
Jonathan Druart
on 2023-04-25 13:58:19 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-04-25 13:58:19 UTC
Size:
14.81 KB
patch
obsolete
>From c27916cbb295db18852816ebbf3d43559420558e 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. >--- > Koha/REST/V1/ERM.pm | 22 +++++++++++ > api/v1/swagger/definitions/erm_config.yaml | 7 ++++ > api/v1/swagger/paths/erm_config.yaml | 39 +++++++++++++++++++ > 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 | 3 +- > t/cypress/integration/ERM/Dialog_spec.ts | 3 +- > t/cypress/integration/ERM/Licenses_spec.ts | 3 +- > t/cypress/integration/ERM/Packages_spec.ts | 3 +- > t/cypress/integration/ERM/Searchbar_spec.ts | 3 +- > t/cypress/integration/ERM/Titles_spec.ts | 3 +- > 14 files changed, 104 insertions(+), 36 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..2dc2ecca76c 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..3c46b62244a >--- /dev/null >+++ b/api/v1/swagger/paths/erm_config.yaml >@@ -0,0 +1,39 @@ >+--- >+/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 7d5e04f62d8..3c3aa6ecde0 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -30,6 +30,8 @@ definitions: > $ref: ./definitions/circ-rule-kind.yaml > city: > $ref: ./definitions/city.yaml >+ erm_config: >+ $ref: ./definitions/erm_config.yaml > erm_agreement: > $ref: ./definitions/erm_agreement.yaml > erm_eholdings_title: >@@ -197,6 +199,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 d2573e988fa..f4b84d36288 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 c29c9a2783a..f0ee9525585 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 dd1e27a2d67..95c5f337d7c 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 a78810bb4e6..37e4aff0a07 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 0c65f3d2b91..46930a857da 100644 >--- a/t/cypress/integration/ERM/Agreements_spec.ts >+++ b/t/cypress/integration/ERM/Agreements_spec.ts >@@ -120,8 +120,7 @@ describe("Agreement CRUD operations", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("List agreements", () => { >diff --git a/t/cypress/integration/ERM/Dialog_spec.ts b/t/cypress/integration/ERM/Dialog_spec.ts >index 79665cb7a94..5256cd2beb8 100644 >--- a/t/cypress/integration/ERM/Dialog_spec.ts >+++ b/t/cypress/integration/ERM/Dialog_spec.ts >@@ -25,8 +25,7 @@ describe("Dialog operations", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("There are no ... defined", () => { >diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts >index 5ba6dfd231c..03d2e39673f 100644 >--- a/t/cypress/integration/ERM/Licenses_spec.ts >+++ b/t/cypress/integration/ERM/Licenses_spec.ts >@@ -36,8 +36,7 @@ describe("License CRUD operations", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("List license", () => { >diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts >index 58ea00323c6..90bce30f599 100644 >--- a/t/cypress/integration/ERM/Packages_spec.ts >+++ b/t/cypress/integration/ERM/Packages_spec.ts >@@ -27,8 +27,7 @@ describe("Package CRUD operations", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("List package", () => { >diff --git a/t/cypress/integration/ERM/Searchbar_spec.ts b/t/cypress/integration/ERM/Searchbar_spec.ts >index 21bcc181f69..95013499a27 100644 >--- a/t/cypress/integration/ERM/Searchbar_spec.ts >+++ b/t/cypress/integration/ERM/Searchbar_spec.ts >@@ -3,8 +3,7 @@ describe("Searchbar header changes", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("Default option is agreements", () => { >diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts >index 56aa71dcf3d..2d6a9c7243b 100644 >--- a/t/cypress/integration/ERM/Titles_spec.ts >+++ b/t/cypress/integration/ERM/Titles_spec.ts >@@ -21,8 +21,7 @@ describe("Title CRUD operations", () => { > beforeEach(() => { > cy.login(); > 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"}'); >+ cy.intercept("GET", "/api/v1/erm/config", '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'); > }); > > it("Import titles", () => { >-- >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