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: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
c4e70ad745
commit
868751b221
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue