mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +00:00
fix: hide error message (#305)
Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>
This commit is contained in:
parent
6d8f6579c7
commit
3dcec52aff
@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { NORMAN } from '@shell/config/types';
|
||||
import { HCI } from '../types';
|
||||
|
||||
export default {
|
||||
@ -13,10 +14,24 @@ export default {
|
||||
const harvesterSettings = await this.$store.dispatch('harvester/findAll', { type: HCI.SETTING });
|
||||
|
||||
this.harvesterSettings = harvesterSettings;
|
||||
|
||||
const clusterRoleTemplateBindingSchema = this.$store.getters['rancher/schemaFor'](NORMAN.CLUSTER_ROLE_TEMPLATE_BINDING);
|
||||
|
||||
if (clusterRoleTemplateBindingSchema) {
|
||||
const normanBindings = await this.$store.dispatch('rancher/findAll', { type: NORMAN.CLUSTER_ROLE_TEMPLATE_BINDING }, { root: true });
|
||||
|
||||
this.clusterRoleTemplateBinding = normanBindings;
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return { harvesterSettings: [] };
|
||||
const user = this.$store.getters['auth/v3User'];
|
||||
|
||||
return {
|
||||
harvesterSettings: [],
|
||||
clusterRoleTemplateBinding: [],
|
||||
user,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -31,19 +46,28 @@ export default {
|
||||
} catch (e) {}
|
||||
|
||||
return isMatch;
|
||||
},
|
||||
|
||||
isClusterOwner() {
|
||||
const template = this.clusterRoleTemplateBinding.find((template) => {
|
||||
return template.userId === this.user?.id;
|
||||
});
|
||||
|
||||
return template?.roleTemplateId === 'cluster-owner';
|
||||
},
|
||||
|
||||
shouldShowError() {
|
||||
return this.isClusterOwner && !this.isMatch && this.value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isMatch">
|
||||
{{ value }}
|
||||
</div>
|
||||
<div v-else>
|
||||
<div>
|
||||
{{ value }}
|
||||
<p
|
||||
v-if="value"
|
||||
v-if="shouldShowError"
|
||||
class="text-error"
|
||||
>
|
||||
{{ t('harvester.backup.matchTarget') }}
|
||||
|
||||
@ -112,15 +112,18 @@ export default class HciSetting extends HarvesterResource {
|
||||
}
|
||||
|
||||
get parseValue() {
|
||||
let parseDefaultValue = {};
|
||||
|
||||
try {
|
||||
parseDefaultValue = JSON.parse(this.value);
|
||||
if (this.value) {
|
||||
return JSON.parse(this.value);
|
||||
} else if (this.default) {
|
||||
return JSON.parse(this.default);
|
||||
}
|
||||
} catch (err) {
|
||||
parseDefaultValue = JSON.parse(this.default);
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Failed to parse setting value or default:', err);
|
||||
}
|
||||
|
||||
return parseDefaultValue;
|
||||
return {};
|
||||
}
|
||||
|
||||
get isS3() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user