diff --git a/commitlint.config.js b/commitlint.config.js index d151338f..a05ba967 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -24,7 +24,7 @@ module.exports = { ], 'type-case': [2, 'always', 'lower-case'], 'type-empty': [2, 'never'], - 'subject-case': [2, 'always', 'lower-case'], + 'subject-case': [0, 'never'], 'subject-empty': [2, 'never'], 'subject-full-stop': [2, 'never', '.'], 'subject-max-length': [2, 'always', 72], diff --git a/pkg/harvester/components/settings/support-bundle-namespaces.vue b/pkg/harvester/components/settings/support-bundle-namespaces.vue index 55d2121f..b0aeb9b9 100644 --- a/pkg/harvester/components/settings/support-bundle-namespaces.vue +++ b/pkg/harvester/components/settings/support-bundle-namespaces.vue @@ -3,6 +3,9 @@ import { NAMESPACE } from '@shell/config/types'; import CreateEditView from '@shell/mixins/create-edit-view'; import LabeledSelect from '@shell/components/form/LabeledSelect'; +const SELECT_ALL = 'select_all'; +const UNSELECT_ALL = 'unselect_all'; + export default { name: 'HarvesterBundleNamespaces', @@ -11,47 +14,76 @@ export default { mixins: [CreateEditView], async fetch() { + this.loading = true; + 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 }); + + this.defaultNamespaces = response.data || []; + } catch (error) { + this.defaultNamespaces = []; + } finally { + this.loading = false; + } }, data() { - let namespaces = []; const namespacesStr = this.value?.value || this.value?.default || ''; + const namespaces = namespacesStr ? namespacesStr.split(',') : []; - if (namespacesStr) { - namespaces = namespacesStr.split(','); - } - - return { namespaces }; + return { + namespaces, + defaultNamespaces: [], + loading: true + }; }, computed: { + allNamespaces() { + return this.$store.getters['harvester/all'](NAMESPACE).map((ns) => ns.id); + }, + + filteredNamespaces() { + const defaultIds = this.defaultNamespaces.map((ns) => ns.id); + + return this.allNamespaces.filter((ns) => !defaultIds.includes(ns)); + }, + namespaceOptions() { - return this.$store.getters['harvester/all'](NAMESPACE).map((N) => { - return { - label: N.id, - value: N.id - }; - }); + if (this.availableNamespaces.length === 0) return []; + + 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]; } }, methods: { - update() { - const namespaceStr = this.namespaces.join(','); + update(selected) { + if (selected.includes(SELECT_ALL)) { + this.namespaces = [...this.filteredNamespaces]; + } else if (selected.includes(UNSELECT_ALL)) { + this.namespaces = []; + } else { + this.namespaces = selected.filter((val) => val !== SELECT_ALL && val !== UNSELECT_ALL); + } - this.value['value'] = namespaceStr; + this.value.value = this.namespaces.join(','); } }, watch: { - 'value.value': { - handler(neu) { - if (neu === this.value.default || !neu) { - this.namespaces = []; - } - }, - deep: true + 'value.value'(newVal) { + const raw = newVal || this.value.default || ''; + + this.namespaces = raw ? raw.split(',') : []; } } }; @@ -62,6 +94,7 @@ export default {
upgrade release download URL address. Harvester will get the ISO URL and checksum value from the ($URL/$VERSION/version.yaml) file hosted by the configured URL.