mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
feat: add access/volume mode support and improvements for VM migration (#1074)
* fix: VM migration tab not appear when first login Signed-off-by: Andy Lee <andy.lee@suse.com> * feat: add access/ volume mode model Signed-off-by: Andy Lee <andy.lee@suse.com> * feat: add selected all | clear all actions for selected VM Signed-off-by: Andy Lee <andy.lee@suse.com> * fix: bugs in VM selection table Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: copilot review Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -24,13 +24,14 @@ export function registerAddonSideNav(store, productName, {
|
||||
const kickSideNav = () => {
|
||||
const TRIGGER = 'ui.refresh.trigger';
|
||||
|
||||
store.dispatch('type-map/addFavorite', TRIGGER);
|
||||
|
||||
// SideNav component seem to ignore rapid state changes.
|
||||
// Wait 600ms to ensure the toggle event triggers a re-render.
|
||||
setTimeout(() => {
|
||||
store.dispatch('type-map/removeFavorite', TRIGGER);
|
||||
}, 600);
|
||||
// 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.
|
||||
[0, 600, 1500].forEach((delay) => {
|
||||
setTimeout(() => {
|
||||
store.dispatch('type-map/addFavorite', TRIGGER);
|
||||
setTimeout(() => store.dispatch('type-map/removeFavorite', TRIGGER), 300);
|
||||
}, delay);
|
||||
});
|
||||
};
|
||||
|
||||
const hasAccessibleSchema = (t) => {
|
||||
@@ -92,16 +93,25 @@ export function registerAddonSideNav(store, productName, {
|
||||
// Store is ready. Stop polling.
|
||||
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(
|
||||
(state, getters) => {
|
||||
const addons = getters[`${ productName }/all`](resourceType);
|
||||
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 }
|
||||
);
|
||||
|
||||
@@ -73,8 +73,21 @@ export function buildNetworkMapEntries(entries = [], defaultNamespace) {
|
||||
export function buildStorageMapEntries(entries = []) {
|
||||
return entries
|
||||
.filter((entry) => !!entry.target)
|
||||
.map((entry) => ({
|
||||
source: { name: entry.name, id: entry.id },
|
||||
destination: { storageClass: entry.target },
|
||||
}));
|
||||
.map((entry) => {
|
||||
const destination = { storageClass: entry.target };
|
||||
|
||||
if (entry.volumeMode) {
|
||||
destination.volumeMode = entry.volumeMode;
|
||||
}
|
||||
|
||||
// Forklift StorageMap destination expects a single `accessMode` value.
|
||||
if (Array.isArray(entry.accessModes) && entry.accessModes.length) {
|
||||
destination.accessMode = entry.accessModes[0];
|
||||
}
|
||||
|
||||
return {
|
||||
source: { name: entry.name, id: entry.id },
|
||||
destination,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user