fix: VM migration tab not appear when first login

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2026-07-31 12:05:30 +08:00
parent b87f367583
commit 74ef7b3772
No known key found for this signature in database
GPG Key ID: 39DC4436AE3564D5

View File

@ -24,13 +24,14 @@ export function registerAddonSideNav(store, productName, {
const kickSideNav = () => { const kickSideNav = () => {
const TRIGGER = 'ui.refresh.trigger'; const TRIGGER = 'ui.refresh.trigger';
store.dispatch('type-map/addFavorite', TRIGGER); // Toggle the trigger a few times so an early kick (fired before the SideNav
// has mounted on first login) is retried once the component is listening.
// SideNav component seem to ignore rapid state changes. [0, 600, 1500].forEach((delay) => {
// Wait 600ms to ensure the toggle event triggers a re-render. setTimeout(() => {
setTimeout(() => { store.dispatch('type-map/addFavorite', TRIGGER);
store.dispatch('type-map/removeFavorite', TRIGGER); setTimeout(() => store.dispatch('type-map/removeFavorite', TRIGGER), 300);
}, 600); }, delay);
});
}; };
const hasAccessibleSchema = (t) => { const hasAccessibleSchema = (t) => {
@ -92,16 +93,25 @@ export function registerAddonSideNav(store, productName, {
// Store is ready. Stop polling. // Store is ready. Stop polling.
clearInterval(waitForStore); clearInterval(waitForStore);
// Watch the specific addon resource for changes to its enabled status. // Watch the addon's enabled status together with the schema availability
// of the gated types. Schemas (e.g. forklift CRDs) can load after the
// addon is already enabled, so the watcher must also re-run when they
// become accessible; otherwise the menu never updates until a refresh.
store.watch( store.watch(
(state, getters) => { (state, getters) => {
const addons = getters[`${ productName }/all`](resourceType); const addons = getters[`${ productName }/all`](resourceType);
const addon = addons.find((a) => a.metadata.name === addonName); const addon = addons.find((a) => a.metadata.name === addonName);
const isEnabled = addon?.spec?.enabled === true;
return addon?.spec?.enabled === true; const schemaReady = requireSchema ? types.every(hasAccessibleSchema) : true;
return `${ isEnabled }:${ schemaReady }`;
}, },
(isEnabled) => { () => {
setMenuVisibility(isEnabled); const addons = store.getters[`${ productName }/all`](resourceType);
const addon = addons.find((a) => a.metadata.name === addonName);
setMenuVisibility(addon?.spec?.enabled === true);
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
); );