From 1b183febdc5e13d29d48b655198114f7d38af526 Mon Sep 17 00:00:00 2001 From: Yiya Chen Date: Wed, 19 Nov 2025 17:35:33 +0800 Subject: [PATCH] fix: condition render namespaceOptions (#607) Signed-off-by: Yi-Ya Chen --- .../settings/support-bundle-namespaces.vue | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pkg/harvester/components/settings/support-bundle-namespaces.vue b/pkg/harvester/components/settings/support-bundle-namespaces.vue index 5a2b3607..c8eff54b 100644 --- a/pkg/harvester/components/settings/support-bundle-namespaces.vue +++ b/pkg/harvester/components/settings/support-bundle-namespaces.vue @@ -18,16 +18,20 @@ export default { await this.$store.dispatch('harvester/findAll', { type: NAMESPACE }); - try { - const url = this.$store.getters['harvester-common/getHarvesterClusterUrl']('v1/harvester/namespaces?link=supportbundle'); - const response = await this.$store.dispatch('harvester/request', { url }); + if (this.customSupportBundleFeatureEnabled) { + try { + const url = this.$store.getters['harvester-common/getHarvesterClusterUrl']('v1/harvester/namespaces?link=supportbundle'); + const response = await this.$store.dispatch('harvester/request', { url }); - this.defaultNamespaces = response.data || []; - } catch (error) { + this.defaultNamespaces = response.data || []; + } catch (error) { + this.defaultNamespaces = []; + } + } else { this.defaultNamespaces = []; - } finally { - this.loading = false; } + + this.loading = false; }, data() { @@ -42,24 +46,38 @@ export default { }, computed: { + customSupportBundleFeatureEnabled() { + return this.$store.getters['harvester-common/getFeatureEnabled']('customSupportBundle'); + }, + allNamespaces() { return this.$store.getters['harvester/all'](NAMESPACE).map((ns) => ns.id); }, filteredNamespaces() { + if (!this.customSupportBundleFeatureEnabled) { + return this.allNamespaces; + } + const defaultIds = this.defaultNamespaces.map((ns) => ns.id); return this.allNamespaces.filter((ns) => !defaultIds.includes(ns)); }, namespaceOptions() { + const mappedNamespaces = this.filteredNamespaces.map((ns) => ({ label: ns, value: ns })); + + if (!this.customSupportBundleFeatureEnabled) { + return mappedNamespaces; + } + const allSelected = this.namespaces.length === this.filteredNamespaces.length && this.filteredNamespaces.every((ns) => this.namespaces.includes(ns)); const controlOption = allSelected ? { label: this.t('harvester.modal.bundle.namespaces.unselectAll'), value: UNSELECT_ALL } : { label: this.t('harvester.modal.bundle.namespaces.selectAll'), value: SELECT_ALL }; - return [controlOption, ...this.filteredNamespaces]; + return [controlOption, ...mappedNamespaces]; } },