mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 15:01:46 +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>
|
<script>
|
||||||
|
import { NORMAN } from '@shell/config/types';
|
||||||
import { HCI } from '../types';
|
import { HCI } from '../types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -13,10 +14,24 @@ export default {
|
|||||||
const harvesterSettings = await this.$store.dispatch('harvester/findAll', { type: HCI.SETTING });
|
const harvesterSettings = await this.$store.dispatch('harvester/findAll', { type: HCI.SETTING });
|
||||||
|
|
||||||
this.harvesterSettings = harvesterSettings;
|
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() {
|
data() {
|
||||||
return { harvesterSettings: [] };
|
const user = this.$store.getters['auth/v3User'];
|
||||||
|
|
||||||
|
return {
|
||||||
|
harvesterSettings: [],
|
||||||
|
clusterRoleTemplateBinding: [],
|
||||||
|
user,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -31,19 +46,28 @@ export default {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
return isMatch;
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="isMatch">
|
<div>
|
||||||
{{ value }}
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
{{ value }}
|
{{ value }}
|
||||||
<p
|
<p
|
||||||
v-if="value"
|
v-if="shouldShowError"
|
||||||
class="text-error"
|
class="text-error"
|
||||||
>
|
>
|
||||||
{{ t('harvester.backup.matchTarget') }}
|
{{ t('harvester.backup.matchTarget') }}
|
||||||
|
|||||||
@ -112,15 +112,18 @@ export default class HciSetting extends HarvesterResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get parseValue() {
|
get parseValue() {
|
||||||
let parseDefaultValue = {};
|
|
||||||
|
|
||||||
try {
|
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) {
|
} 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() {
|
get isS3() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user