From cf5fbc98ec5ee0493028cb18c2303e4f37804616 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 19 Aug 2026 10:34:32 +0000 Subject: [PATCH] Bug 43091: (RM follow-up) Give the OPAC self-renewal island a Pinia store hydrate() only installs Pinia for an island when its config.stores is non-empty. patron-self-renewal kept config: {} after islands-opac.ts was split out, so it never got one. http-client.js's post() calls submitting(), which needs Pinia's useMainStore(). With none active, it throws before fetch() runs - get() skips submitting() by default, so only the actual renewal submission failed. Test plan: prove t/cypress/integration/Islands/SelfRenewal.ts Signed-off-by: Lucas Gass --- .../prog/js/vue/modules/islands-opac.ts | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands-opac.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands-opac.ts index 780b6e65d3..2a515abdb5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands-opac.ts +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands-opac.ts @@ -1,5 +1,11 @@ export * from "./islands"; -import { hydrate, registerIsland, WebComponentDynamicImport } from "./islands"; +import { + hydrate as hydrateIslands, + registerIsland, + IslandStoreDefinitions, + WebComponentDynamicImport, +} from "./islands"; +import { useMainStore } from "../stores/main"; /** * The islands available in the OPAC. @@ -16,14 +22,35 @@ const islands: Map = new Map([ ); return module.default; }, - config: {}, + config: { + stores: ["mainStore"], + }, }, ], ]); +/** + * The Pinia stores islands in the OPAC may request via config.stores. + * @type {IslandStoreDefinitions} + */ +const storeDefinitions: IslandStoreDefinitions = { + mainStore: useMainStore, +}; + // Core islands take the same registration path as plugin islands. islands.forEach((entry, name) => registerIsland(name, entry)); +/** + * Hydrates islands with the OPAC store set. + * + * This local export takes precedence over the star re-export from ./islands, + * so imports of hydrate from the built islands.esm.js get the stores baked in. + * @returns {void} + */ +export function hydrate(): void { + hydrateIslands(storeDefinitions); +} + if (parseInt(document?.currentScript?.getAttribute("init") ?? "0", 10)) { hydrate(); }