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 <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2026-08-19 10:34:32 +00:00 committed by Lucas Gass
parent daa731ca20
commit cf5fbc98ec
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 29 additions and 2 deletions

View File

@ -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<string, WebComponentDynamicImport> = 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();
}