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:
@@ -4,7 +4,7 @@ import Loading from '@shell/components/Loading';
|
||||
import MessageLink from '@shell/components/MessageLink';
|
||||
import Masthead from '@shell/components/ResourceList/Masthead';
|
||||
import ResourceTable from '@shell/components/ResourceTable';
|
||||
|
||||
import { isBackupTargetSettingEmpty } from '../utils/setting';
|
||||
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
|
||||
import FilterVMSchedule from '../components/FilterVMSchedule';
|
||||
import { HCI } from '../types';
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
this.settings = hash.settings;
|
||||
if (this.$store.getters[`${ inStore }/schemaFor`](HCI.SETTING)) {
|
||||
const backupTargetResource = hash.settings.find( (O) => O.id === 'backup-target');
|
||||
const isEmpty = this.getBackupTargetValueIsEmpty(backupTargetResource);
|
||||
const isEmpty = isBackupTargetSettingEmpty(backupTargetResource);
|
||||
|
||||
if (backupTargetResource && !isEmpty) {
|
||||
this.testConnect();
|
||||
@@ -78,20 +78,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
getBackupTargetValueIsEmpty(resource) {
|
||||
let out = true;
|
||||
|
||||
if (resource?.value) {
|
||||
try {
|
||||
const valueJson = JSON.parse(resource?.value);
|
||||
|
||||
out = !valueJson.type;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
getRow(row) {
|
||||
return row.status && row.status.source;
|
||||
},
|
||||
@@ -183,11 +169,9 @@ export default {
|
||||
backupTargetResource() {
|
||||
return this.settings.find((O) => O.id === 'backup-target');
|
||||
},
|
||||
|
||||
isEmptyValue() {
|
||||
return this.getBackupTargetValueIsEmpty(this.backupTargetResource);
|
||||
return isBackupTargetSettingEmpty(this.backupTargetResource);
|
||||
},
|
||||
|
||||
canUpdate() {
|
||||
return this?.backupTargetResource?.canUpdate;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user