mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +00:00
Fix undefined error in VM edit as yaml page (#233)
* fix undefined error whenclick save in edit as yaml Signed-off-by: Andy Lee <andy.lee@suse.com> * fix VM isEqual logic and fix undefined error Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
19bea97106
commit
238c660796
@ -97,12 +97,14 @@ export default {
|
||||
});
|
||||
|
||||
const devices = [
|
||||
...this.otherDevices(this.value.domain.devices.hostDevices || []),
|
||||
...this.otherDevices(this.value?.domain?.devices?.hostDevices || []),
|
||||
...formatted,
|
||||
];
|
||||
|
||||
if (devices.length > 0) {
|
||||
set(this.value.domain.devices, 'hostDevices', devices);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -121,7 +123,9 @@ export default {
|
||||
return inUse;
|
||||
}
|
||||
|
||||
vm.hostDevices.forEach((device) => {
|
||||
const hostDevices = vm?.hostDevices || [];
|
||||
|
||||
hostDevices.forEach((device) => {
|
||||
inUse[device.name] = { usedBy: [vm.metadata.name] };
|
||||
});
|
||||
|
||||
|
||||
@ -80,12 +80,14 @@ export default {
|
||||
});
|
||||
|
||||
const devices = [
|
||||
...this.otherDevices(this.value.domain.devices.hostDevices || []),
|
||||
...this.otherDevices(this.value?.domain?.devices?.hostDevices || []),
|
||||
...formatted,
|
||||
];
|
||||
|
||||
if (devices.length > 0) {
|
||||
set(this.value.domain.devices, 'hostDevices', devices);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -121,7 +123,9 @@ export default {
|
||||
return inUse;
|
||||
}
|
||||
|
||||
vm.hostDevices.forEach((device) => {
|
||||
const hostDevices = vm?.hostDevices || [];
|
||||
|
||||
hostDevices.forEach((device) => {
|
||||
inUse[device.name] = { usedBy: [vm.metadata.name] };
|
||||
});
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { mapGetters } from 'vuex';
|
||||
import Tabbed from '@shell/components/Tabbed';
|
||||
import { clone } from '@shell/utils/object';
|
||||
import Tab from '@shell/components/Tabbed/Tab';
|
||||
import { Checkbox } from '@components/Form/Checkbox';
|
||||
import CruResource from '@shell/components/CruResource';
|
||||
@ -17,7 +18,6 @@ import UsbDevices from './VirtualMachineUSBDevices/index';
|
||||
import KeyValue from '@shell/components/form/KeyValue';
|
||||
|
||||
import { clear } from '@shell/utils/array';
|
||||
import { clone } from '@shell/utils/object';
|
||||
import { saferDump } from '@shell/utils/create-yaml';
|
||||
import { exceptionToErrorsArray } from '@shell/utils/error';
|
||||
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
|
||||
@ -410,12 +410,16 @@ export default {
|
||||
const cloneDeepNewVM = clone(this.value);
|
||||
|
||||
delete cloneDeepNewVM?.metadata;
|
||||
delete cloneDeepNewVM?.__clone;
|
||||
|
||||
delete this.cloneVM?.metadata;
|
||||
delete this.cloneVM?.__clone;
|
||||
|
||||
const oldVM = JSON.parse(JSON.stringify(this.cloneVM));
|
||||
const newVM = JSON.parse(JSON.stringify(cloneDeepNewVM));
|
||||
|
||||
// we won't show restart dialog in yaml page as we don't have a way to detect change in yaml editor.
|
||||
// only check VM is changed in form page.
|
||||
if (isEqual(oldVM, newVM)) {
|
||||
return;
|
||||
}
|
||||
@ -424,7 +428,11 @@ export default {
|
||||
this.isOpen = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (this?.$refs?.restartDialog) {
|
||||
this.$refs.restartDialog.resolve = resolve;
|
||||
} else {
|
||||
return resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@ -871,7 +871,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
if (out.length === 0 && !!this.spec.template.spec.accessCredentials) {
|
||||
if (out.length === 0 && !!this.spec.template.spec.accessCredentials === false) {
|
||||
delete this.spec.template.spec.accessCredentials;
|
||||
} else {
|
||||
this.spec.template.spec.accessCredentials = out;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user