mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
fix: hide VM take backup action if backup target is not available (#512)
* 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>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user