mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 15:01:46 +00:00
* feat(vmimport): First working side nav attempt
Add vmimport entries when the related resource actually exists aka addon was enabled
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): improved version that uses 'store.watch' instead of polling
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): further tuning of dynamic side navi load/unload
Code formatting and commits. Also safeguard if something is wrong with the store
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): separate vmimport side nav entries from dynamic logic
function registerAddonSideNav introduced in utils/dynamic-nav.js
Decouples vmimport side nav entries from the hide/unhide based on addon status logic
Makes it reusable in the UI with other AddOns in the future
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add custom headers for HCI.VMIMPORT
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add custom headers for HCI.VMIMPORT_SOURCE_V
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add custom headers for HCI.VMIMPORT_SOURCE_O
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): array instead string passed to configureType
Caused routing issues for CRUD operations
Labels moved to labelTypes section to follow standards
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): registerAddonSideNav improved and refactored
Clear comments, code refactoring, additional checks and validations
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): show correct status for virtualmachineimport
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): custom list components with ns grouping
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): 404 on refresh and missing menu entry
Restores virtualType definitions to register routes synchronously,
preventing 404 errors during page reload.
Updates dynamic-nav to force-fetch addon data if missing, fixing
hidden menu issues on direct page access.
Restores explicit label keys for virtualTypes to ensure correct
naming in the side navigation.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add edit form for VirtualMachineImport resource
Adds a UI form for VirtualMachineImport to replace manual YAML editing.
The form fetches VmwareSource and OpenstackSource objects for the
source selection dropdown.
It validates the VM name against RFC-1123 rules and filters out
internal storage classes. Users can also configure network mappings
via a dynamic list.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add edit form for VmwareSource
Adds a UI to configure VmwareSource resources including the endpoint
and datacenter fields.
For authentication, users can either select an existing Secret or
enter a username and password directly. The form handles creating
the required Kubernetes Secret in the background when new credentials
are provided.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add edit form for OpenstackSource
Custom edit form for OpenstackSource resource. Creates new secret
or lets users select existing secrets. Support all fields the CRD has.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* chore(vmimport): vmware source default endpoint and datacenter renamed
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): add edit form for OvaSource
OvaSource (new in harvester / vm-import-controller v1.7.0).
Imports VMs from an OVA file using via HTTP or HTTPS.
The form supports URL configuration and optional Basic Auth using a
username and password. Users can also provide an optional CA Certificate
for HTTPS verification and configure advanced HTTP timeout settings.
VirtualMachineImport edit page to updated to include OvaSource in
the source dropdown.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* chore(vmimport): align tab names on openstacksource
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): import { TextArea } from '@components/Form/TextArea' not found
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): 'Destination Network' don't list all networks
Online listed the 'mgmt' Network. Adjust to read all Virtual Machine Networks.
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): rename side-nav entry to 'Virtual Machine Imports'
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): OvaSource Auth tab throws error selecting existing secret
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): Add missing caCert input field to vmware source
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): use 'LabeledInput' instead of 'TextAreaAutoGrow' for cacert fields
Changing the type allows labels to show up in the UI
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): Move vars into types files and reference them
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): Use 'currentProduct' value instead of hardcoded 'harvester' string
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): shorten 'selectedOption.raw' usage
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): Checks to make splice() usage more robust
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): re-use existing rfc1123 val function
Move rfc1123 validation error message to l10n/en-us.yaml
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* fix(vmimport): var name typo in vmi edit rfc1123 check
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): vmi use 'FormValidation' and l10n for labels
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): oss use 'FormValidation' and l10n for labels
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): ovas use 'FormValidation' and l10n for labels
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* feat(vmimport): vms use 'FormValidation' and l10n for labels
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
* refactor(vmimport): Display error message at the top of the page
Signed-off-by: Volker Theile <vtheile@suse.com>
---------
Signed-off-by: Dominik Wombacher <dominik.wombacher@suse.com>
Signed-off-by: Volker Theile <vtheile@suse.com>
Co-authored-by: Volker Theile <vtheile@suse.com>
100 lines
3.6 KiB
JavaScript
100 lines
3.6 KiB
JavaScript
/**
|
|
* Dynamically toggles SideNav entries based on the enabled status of a specific Addon.
|
|
*
|
|
* @param {Object} store - The Vuex store instance.
|
|
* @param {String} productName - The product name (e.g. 'harvester').
|
|
* @param {Object} config - Configuration object.
|
|
* @param {String} config.addonName - The name of the addon to watch.
|
|
* @param {String} config.resourceType - The schema ID for addons.
|
|
* @param {String} config.navGroup - The group name in the side nav.
|
|
* @param {Array<String>} config.types - Array of Resource IDs to show/hide.
|
|
*/
|
|
export function registerAddonSideNav(store, productName, {
|
|
addonName, resourceType, navGroup, types
|
|
}) {
|
|
if (typeof window === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
// Forces the SideNav component to re-render by toggling a dummy user preference.
|
|
// Necessary because the menu component does not automatically detect
|
|
// changes to the allowed types list.
|
|
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);
|
|
};
|
|
|
|
// Adds or removes the resource IDs from the product visibility whitelist.
|
|
const setMenuVisibility = (visible) => {
|
|
if (visible) {
|
|
store.commit('type-map/basicType', {
|
|
product: productName,
|
|
group: navGroup,
|
|
types
|
|
});
|
|
} else {
|
|
// Manually delete the keys from the state object to hide them.
|
|
const basicTypes = store.state['type-map'].basicTypes[productName];
|
|
|
|
if (basicTypes) {
|
|
types.forEach((t) => delete basicTypes[t]);
|
|
}
|
|
}
|
|
kickSideNav();
|
|
};
|
|
|
|
// Start polling to check if the store is ready.
|
|
let attempts = 0;
|
|
const MAX_ATTEMPTS = 60;
|
|
|
|
const waitForStore = setInterval(() => {
|
|
attempts++;
|
|
|
|
try {
|
|
// Check if the Schema definitions are loaded.
|
|
const hasSchema = store.getters[`${ productName }/schemaFor`] &&
|
|
store.getters[`${ productName }/schemaFor`](resourceType);
|
|
|
|
// Check if the resource list data is fully loaded to prevent race conditions.
|
|
const hasData = store.getters[`${ productName }/haveAll`] &&
|
|
store.getters[`${ productName }/haveAll`](resourceType);
|
|
|
|
if (hasSchema && hasData) {
|
|
// Store is ready. Stop polling.
|
|
clearInterval(waitForStore);
|
|
|
|
// Watch the specific addon resource for changes to its enabled status.
|
|
store.watch(
|
|
(state, getters) => {
|
|
const addons = getters[`${ productName }/all`](resourceType);
|
|
const addon = addons.find((a) => a.metadata.name === addonName);
|
|
|
|
return addon?.spec?.enabled === true;
|
|
},
|
|
(isEnabled) => {
|
|
setMenuVisibility(isEnabled);
|
|
},
|
|
{ immediate: true, deep: true }
|
|
);
|
|
} else if (hasSchema && !hasData) {
|
|
// If the schema is ready but the data is missing, request the list from the API.
|
|
// Ensures the script does not wait indefinitely if the UI has not loaded the addons yet.
|
|
store.dispatch(`${ productName }/findAll`, { type: resourceType });
|
|
} else if (attempts >= MAX_ATTEMPTS) {
|
|
// Stop checking if the store does not load within the timeout limit.
|
|
clearInterval(waitForStore);
|
|
}
|
|
} catch (e) {
|
|
// Ignore errors if the store module is not yet registered and wait for the next attempt.
|
|
if (attempts >= MAX_ATTEMPTS) clearInterval(waitForStore);
|
|
}
|
|
}, 1000);
|
|
}
|