mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-04 05:06:05 +08:00
* feat: forklift poc first commit
* feat: add migration and plan detail pages with progress tracking
* feat(forklift): UI based on the FIGMA
* feat(forklift): Fixed config based on new figma changes
* feat(forklift): New changes added based on new figma
* feat(forklift): Add the succeded state
* Merge the new APIs
* feat(forklift): Applied fix to select the proper data on network. Added condition to show critical
* feat(forklift): Added icons, critical state, fix grids, action button
* feat(forklift): Change to use the proper provider instead of a hardcoded
* feat(forklift): Added pagination UI
* feat(forklift): FIxed the routing for the extension
* feat(forklift): route and router doesnt work properly on extensions
* feat(forklift): fixed to fix the icon on extension
* feat(forklift): Added overflow hidden to mapping target list
* feat(forklift): Added better handling on the saving and testing
* feat(forklift): Remove test flags
* feat(forklift): Changed based on review
* feat(forklift): fixed title and button
* feat(forklift): Design changes
* feat(forklift): Changed to Wizard
* feat(forklift): added the provider wizard
* feat(forklift): Fixed some UI changes
* feat(forklift): Removed wrong configs used for testing
* feat(forklift): update size
* feat(forklift): small fixes
* feat(forklift): small fixes after Copilot
* feat(forklift): small fixes after Copilot
* feat(forklift): reverted settings.json changes
* feat(forklift): small fixes after Copilot
* feat(forklift): Fix the way it is registered
* feat(forklift): Fixed the type for VMware
* feat(forklift): small changes before rebase
* feat: Added new API for the vms
* feat: Fix some labels
* feat: Added some final fixes to structure
* feat: added loading to provider steps
* feat: added comments from copilot review
---------
(cherry picked from commit 560643d299)
Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
Co-authored-by: marcelofukumoto <marceloyfukumoto@gmail.com>
This commit is contained in:
co-authored by
marcelofukumoto
parent
73126b953c
commit
d3b77e2e41
@@ -0,0 +1,80 @@
|
||||
// Shared helpers for the Forklift VM-migration feature.
|
||||
// Keep the map-spec builders here so the wizard step and the review step
|
||||
// (and any future edit flow) stay in sync instead of drifting apart.
|
||||
|
||||
export const FORKLIFT_API_VERSION = 'forklift.konveyor.io/v1beta1';
|
||||
|
||||
/**
|
||||
* Decode a base64 value stored in a k8s Secret, tolerating malformed input.
|
||||
*/
|
||||
export function decodeSecretValue(val) {
|
||||
try {
|
||||
return atob(val || '');
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bytes → whole GiB (rounded). Returns 0 for falsy input.
|
||||
*/
|
||||
export function bytesToGB(bytes) {
|
||||
return Math.round((bytes || 0) / (1024 * 1024 * 1024));
|
||||
}
|
||||
|
||||
/**
|
||||
* MiB → whole GiB (rounded). Returns 0 for falsy input.
|
||||
*/
|
||||
export function mbToGB(mb) {
|
||||
return Math.round((mb || 0) / 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the `spec.map` entries for a Forklift NetworkMap from wizard entries.
|
||||
* Entries without a chosen target are dropped so we never emit an invalid
|
||||
* multus destination with an empty name.
|
||||
*
|
||||
* @param {Array} entries network mapping entries ({ name, id, target })
|
||||
* @param {string} defaultNamespace namespace to use when the target has no `ns/` prefix
|
||||
*/
|
||||
export function buildNetworkMapEntries(entries = [], defaultNamespace) {
|
||||
return entries
|
||||
.filter((entry) => !!entry.target)
|
||||
.map((entry) => {
|
||||
const source = { name: entry.name, id: entry.id };
|
||||
|
||||
if (entry.target === 'pod') {
|
||||
return { source, destination: { type: 'pod' } };
|
||||
}
|
||||
|
||||
if (entry.target === 'ignored') {
|
||||
return { source, destination: { type: 'ignored' } };
|
||||
}
|
||||
|
||||
const parts = entry.target.split('/');
|
||||
const name = parts.length > 1 ? parts[1] : parts[0];
|
||||
const namespace = parts.length > 1 ? parts[0] : defaultNamespace;
|
||||
|
||||
return {
|
||||
source,
|
||||
destination: {
|
||||
type: 'multus', name, namespace
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the `spec.map` entries for a Forklift StorageMap from wizard entries.
|
||||
* Entries without a chosen target are dropped.
|
||||
*
|
||||
* @param {Array} entries storage mapping entries ({ name, id, target })
|
||||
*/
|
||||
export function buildStorageMapEntries(entries = []) {
|
||||
return entries
|
||||
.filter((entry) => !!entry.target)
|
||||
.map((entry) => ({
|
||||
source: { name: entry.name, id: entry.id },
|
||||
destination: { storageClass: entry.target },
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Mirrors Resource class methods from @shell/plugins/dashboard-store/resource-class.js
|
||||
// useRouter()/useRoute() from vue-router don't work in extension mode,
|
||||
// so we use the same global access pattern the shell uses internally.
|
||||
|
||||
export function currentRouter() {
|
||||
return window.$globalApp.$router;
|
||||
}
|
||||
|
||||
export function currentRoute() {
|
||||
return window.$globalApp.$route;
|
||||
}
|
||||
Reference in New Issue
Block a user