mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
* fix: hide VM take backup action if backup target is not available Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: use extracted func Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
26 lines
628 B
JavaScript
26 lines
628 B
JavaScript
|
|
export function isBackupTargetSettingEmpty(setting = {}) {
|
|
let isEmpty = true;
|
|
|
|
if (setting?.value) {
|
|
try {
|
|
const valueJson = JSON.parse(setting?.value);
|
|
|
|
isEmpty = !valueJson.type;
|
|
} catch (e) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('Failed to parse backup target value:', e);
|
|
}
|
|
}
|
|
|
|
return isEmpty;
|
|
}
|
|
|
|
export function isBackupTargetSettingUnavailable(setting = {}) {
|
|
const errorMessage = setting.errorMessage;
|
|
const isEmptyValue = isBackupTargetSettingEmpty(setting);
|
|
const canUpdate = setting.canUpdate;
|
|
|
|
return (errorMessage || isEmptyValue) && canUpdate;
|
|
}
|