mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +00:00
fix unable to detach PCI & USB device in VM edit page (#247)
* fix unable to detach PCI & USB device in VM edit page Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor based on comment Signed-off-by: Andy Lee <andy.lee@suse.com> * using set from shell/utils/object Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
a5d4604dce
commit
2993ddb82c
@ -101,9 +101,7 @@ export default {
|
|||||||
...formatted,
|
...formatted,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (devices.length > 0) {
|
set(this.value.domain.devices, 'hostDevices', devices);
|
||||||
set(this.value.domain.devices, 'hostDevices', devices);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -84,9 +84,7 @@ export default {
|
|||||||
...formatted,
|
...formatted,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (devices.length > 0) {
|
set(this.value.domain.devices, 'hostDevices', devices);
|
||||||
set(this.value.domain.devices, 'hostDevices', devices);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import Tabbed from '@shell/components/Tabbed';
|
import Tabbed from '@shell/components/Tabbed';
|
||||||
import { clone } from '@shell/utils/object';
|
import { clone, set } from '@shell/utils/object';
|
||||||
import Tab from '@shell/components/Tabbed/Tab';
|
import Tab from '@shell/components/Tabbed/Tab';
|
||||||
import { Checkbox } from '@components/Form/Checkbox';
|
import { Checkbox } from '@components/Form/Checkbox';
|
||||||
import CruResource from '@shell/components/CruResource';
|
import CruResource from '@shell/components/CruResource';
|
||||||
@ -16,7 +16,6 @@ import PodAffinity from '@shell/components/form/PodAffinity';
|
|||||||
import VGpuDevices from './VirtualMachineVGpuDevices/index';
|
import VGpuDevices from './VirtualMachineVGpuDevices/index';
|
||||||
import UsbDevices from './VirtualMachineUSBDevices/index';
|
import UsbDevices from './VirtualMachineUSBDevices/index';
|
||||||
import KeyValue from '@shell/components/form/KeyValue';
|
import KeyValue from '@shell/components/form/KeyValue';
|
||||||
|
|
||||||
import { clear } from '@shell/utils/array';
|
import { clear } from '@shell/utils/array';
|
||||||
import { saferDump } from '@shell/utils/create-yaml';
|
import { saferDump } from '@shell/utils/create-yaml';
|
||||||
import { exceptionToErrorsArray } from '@shell/utils/error';
|
import { exceptionToErrorsArray } from '@shell/utils/error';
|
||||||
@ -412,12 +411,21 @@ export default {
|
|||||||
}
|
}
|
||||||
const cloneDeepNewVM = clone(this.value);
|
const cloneDeepNewVM = clone(this.value);
|
||||||
|
|
||||||
|
// new VM
|
||||||
delete cloneDeepNewVM?.metadata;
|
delete cloneDeepNewVM?.metadata;
|
||||||
delete cloneDeepNewVM?.__clone;
|
delete cloneDeepNewVM?.__clone;
|
||||||
|
|
||||||
|
// old VM
|
||||||
delete this.cloneVM?.metadata;
|
delete this.cloneVM?.metadata;
|
||||||
delete this.cloneVM?.__clone;
|
delete this.cloneVM?.__clone;
|
||||||
|
|
||||||
|
// add empty hostDevices to old VM as CRD does not have it.
|
||||||
|
const devicesObj = this.cloneVM?.spec?.template?.spec?.domain?.devices;
|
||||||
|
|
||||||
|
if (devicesObj && devicesObj.hostDevices === undefined) {
|
||||||
|
set(devicesObj, 'hostDevices', []);
|
||||||
|
}
|
||||||
|
|
||||||
const oldVM = JSON.parse(JSON.stringify(this.cloneVM));
|
const oldVM = JSON.parse(JSON.stringify(this.cloneVM));
|
||||||
const newVM = JSON.parse(JSON.stringify(cloneDeepNewVM));
|
const newVM = JSON.parse(JSON.stringify(cloneDeepNewVM));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user