From d9bdfa56cf4bbe64d2c9cc30ee1c6258272112eb Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Fri, 15 Nov 2024 16:49:14 +0000 Subject: [PATCH] Revert "backport-pr-12611 (#12619)" This reverts commit 6a92a261c7839c56f2542de6e19ee3f6ab56cdbb. --- shell/assets/translations/en-us.yaml | 8 - .../__tests__/DirectoryConfig.test.ts | 133 +++--------- .../tabs/Advanced.vue | 1 - .../tabs/DirectoryConfig.vue | 203 +++--------------- 4 files changed, 50 insertions(+), 295 deletions(-) diff --git a/shell/assets/translations/en-us.yaml b/shell/assets/translations/en-us.yaml index e217c7522e4..0a98c65af26 100644 --- a/shell/assets/translations/en-us.yaml +++ b/shell/assets/translations/en-us.yaml @@ -1467,14 +1467,6 @@ cluster: placeholder: A unique name for the cluster directoryConfig: title: Data directory configuration - banner: Data directory configuration can not be changed once the cluster has been created - radioInput: - defaultLabel: Use default data directory configuration - commonLabel: Use a common base directory for data directory configuration (sub-directories will be used for the system-agent, provisioning and distro paths) - customLabel: Use custom data directories - common: - label: Data directory base path - tooltip: Data directory base path. We will append the sub-directories appropriate for each directory (/agent, /provisioning and either /rke2 or /k3s) systemAgent: label: System-agent directory path tooltip: Data directory for the system-agent connection info and plans diff --git a/shell/edit/provisioning.cattle.io.cluster/__tests__/DirectoryConfig.test.ts b/shell/edit/provisioning.cattle.io.cluster/__tests__/DirectoryConfig.test.ts index c56eb4e18a1..2203566d6cc 100644 --- a/shell/edit/provisioning.cattle.io.cluster/__tests__/DirectoryConfig.test.ts +++ b/shell/edit/provisioning.cattle.io.cluster/__tests__/DirectoryConfig.test.ts @@ -1,7 +1,6 @@ -import { nextTick } from 'vue'; /* eslint-disable jest/no-hooks */ import { mount, Wrapper } from '@vue/test-utils'; -import DirectoryConfig, { DATA_DIR_RADIO_OPTIONS, DEFAULT_SUBDIRS } from '@shell/edit/provisioning.cattle.io.cluster/tabs/DirectoryConfig.vue'; +import DirectoryConfig from '@shell/edit/provisioning.cattle.io.cluster/tabs/DirectoryConfig.vue'; import { _EDIT, _CREATE } from '@shell/config/query-params'; import { clone } from '@shell/utils/object'; @@ -15,8 +14,7 @@ describe('component: DirectoryConfig', () => { provisioning: '', k8sDistro: '', }, - k8sVersion: 'k3s', - mode: _CREATE, + mode: _CREATE, }, mocks: { $store: { @@ -35,88 +33,48 @@ describe('component: DirectoryConfig', () => { ); const title = wrapper.find('h3'); - const radioInput = wrapper.find('[data-testid="rke2-directory-config-radio-input"]'); - const commonInput = wrapper.find('[data-testid="rke2-directory-config-common-data-dir"]'); const systemAgentInput = wrapper.find('[data-testid="rke2-directory-config-systemAgent-data-dir"]'); const provisioningInput = wrapper.find('[data-testid="rke2-directory-config-provisioning-data-dir"]'); const k8sDistroInput = wrapper.find('[data-testid="rke2-directory-config-k8sDistro-data-dir"]'); expect(title.exists()).toBe(true); - expect(radioInput.exists()).toBe(true); - // for the default config, the default radio input should be "default" - expect(wrapper.vm.dataConfigRadioValue).toBe(DATA_DIR_RADIO_OPTIONS.DEFAULT); - - // since we have all of the vars empty, then the inputs should not be there - expect(commonInput.exists()).toBe(false); - expect(systemAgentInput.exists()).toBe(false); - expect(provisioningInput.exists()).toBe(false); - expect(k8sDistroInput.exists()).toBe(false); - }); - - it('updating common base directory should set the correct values on each data dir variable', async() => { - const newMountOptions = clone(mountOptions); - - wrapper = mount( - DirectoryConfig, - { - ...newMountOptions, - // couldn't use setData, so this is the next best solution - data() { - return { dataConfigRadioValue: DATA_DIR_RADIO_OPTIONS.COMMON }; - } - } - ); - - const inputPath = 'some-data-dir'; - const commonInput = wrapper.find('[data-testid="rke2-directory-config-common-data-dir"]'); - - // update base dir value - expect(commonInput.exists()).toBe(true); - commonInput.setValue(inputPath); - await nextTick(); - - expect(wrapper.vm.value.systemAgent).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.AGENT }`); - expect(wrapper.vm.value.provisioning).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.PROVISIONING }`); - expect(wrapper.vm.value.k8sDistro).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.K8S_DISTRO_K3S }`); + expect(systemAgentInput.exists()).toBe(true); + expect(provisioningInput.exists()).toBe(true); + expect(k8sDistroInput.exists()).toBe(true); }); it('updating each individual data dir should set the correct values on each data dir variable', async() => { - const newMountOptions = clone(mountOptions); - wrapper = mount( DirectoryConfig, - { - ...newMountOptions, - // couldn't use setData, so this is the next best solution - data() { - return { dataConfigRadioValue: DATA_DIR_RADIO_OPTIONS.CUSTOM }; - } - } + mountOptions ); + const inputPath = 'some-data-dir'; - const agentValue = `${ inputPath }/${ DEFAULT_SUBDIRS.AGENT }`; - const provisioningValue = `${ inputPath }/${ DEFAULT_SUBDIRS.PROVISIONING }`; - const k8sDistroValue = `${ inputPath }/${ DEFAULT_SUBDIRS.K8S_DISTRO_RKE2 }`; const systemAgentInput = wrapper.find('[data-testid="rke2-directory-config-systemAgent-data-dir"]'); const provisioningInput = wrapper.find('[data-testid="rke2-directory-config-provisioning-data-dir"]'); const k8sDistroInput = wrapper.find('[data-testid="rke2-directory-config-k8sDistro-data-dir"]'); - systemAgentInput.setValue(agentValue); - provisioningInput.setValue(provisioningValue); - k8sDistroInput.setValue(k8sDistroValue); - await nextTick(); + systemAgentInput.setValue(inputPath); + provisioningInput.setValue(inputPath); + k8sDistroInput.setValue(inputPath); + await wrapper.vm.$nextTick(); - expect(wrapper.vm.value.systemAgent).toStrictEqual(agentValue); - expect(wrapper.vm.value.provisioning).toStrictEqual(provisioningValue); - expect(wrapper.vm.value.k8sDistro).toStrictEqual(k8sDistroValue); + expect(wrapper.vm.value.systemAgent).toStrictEqual(inputPath); + expect(wrapper.vm.value.provisioning).toStrictEqual(inputPath); + expect(wrapper.vm.value.k8sDistro).toStrictEqual(inputPath); }); - it('should render the component with configuration being an empty object, without errors and radio be of value DATA_DIR_RADIO_OPTIONS.CUSTOM (edit scenario)', () => { + it('on a mode different than _CREATE all visible inputs should be disabled (with different values)', () => { const newMountOptions = clone(mountOptions); + const inputPath1 = 'some-data-dir1'; + const inputPath2 = 'some-data-dir2'; + const inputPath3 = 'some-data-dir3'; - newMountOptions.propsData.value = {}; + newMountOptions.propsData.value.systemAgent = inputPath1; + newMountOptions.propsData.value.provisioning = inputPath2; + newMountOptions.propsData.value.k8sDistro = inputPath3; newMountOptions.propsData.mode = _EDIT; wrapper = mount( @@ -124,59 +82,16 @@ describe('component: DirectoryConfig', () => { newMountOptions ); - const title = wrapper.find('h3'); - const radioInput = wrapper.find('[data-testid="rke2-directory-config-radio-input"]'); const systemAgentInput = wrapper.find('[data-testid="rke2-directory-config-systemAgent-data-dir"]'); const provisioningInput = wrapper.find('[data-testid="rke2-directory-config-provisioning-data-dir"]'); const k8sDistroInput = wrapper.find('[data-testid="rke2-directory-config-k8sDistro-data-dir"]'); - expect(title.exists()).toBe(true); - expect(radioInput.isVisible()).toBe(false); - - expect(wrapper.vm.dataConfigRadioValue).toBe(DATA_DIR_RADIO_OPTIONS.CUSTOM); - - // since we have all of the vars empty, then the inputs should not be there expect(systemAgentInput.exists()).toBe(true); expect(provisioningInput.exists()).toBe(true); expect(k8sDistroInput.exists()).toBe(true); - expect(systemAgentInput.attributes().disabled).toBeDefined(); - expect(provisioningInput.attributes().disabled).toBeDefined(); - expect(k8sDistroInput.attributes().disabled).toBeDefined(); - }); - - it('radio input should be set to DATA_DIR_RADIO_OPTIONS.CUSTOM with all data dir values existing and different (edit scenario)', () => { - const newMountOptions = clone(mountOptions); - const inputPath = 'some-data-dir'; - - newMountOptions.propsData.value.systemAgent = `${ inputPath }/${ DEFAULT_SUBDIRS.AGENT }`; - newMountOptions.propsData.value.provisioning = `${ inputPath }/${ DEFAULT_SUBDIRS.PROVISIONING }`; - newMountOptions.propsData.value.k8sDistro = `${ inputPath }/${ DEFAULT_SUBDIRS.K8S_DISTRO_K3S }`; - newMountOptions.propsData.mode = _EDIT; - - wrapper = mount( - DirectoryConfig, - newMountOptions - ); - - expect(wrapper.vm.dataConfigRadioValue).toBe(DATA_DIR_RADIO_OPTIONS.CUSTOM); - - const radioInput = wrapper.find('[data-testid="rke2-directory-config-radio-input"]'); - const systemAgentInput = wrapper.find('[data-testid="rke2-directory-config-systemAgent-data-dir"]'); - const provisioningInput = wrapper.find('[data-testid="rke2-directory-config-provisioning-data-dir"]'); - const k8sDistroInput = wrapper.find('[data-testid="rke2-directory-config-k8sDistro-data-dir"]'); - - expect(radioInput.isVisible()).toBe(false); - expect(systemAgentInput.isVisible()).toBe(true); - expect(provisioningInput.isVisible()).toBe(true); - expect(k8sDistroInput.isVisible()).toBe(true); - - expect(systemAgentInput.attributes().disabled).toBeDefined(); - expect(provisioningInput.attributes().disabled).toBeDefined(); - expect(k8sDistroInput.attributes().disabled).toBeDefined(); - - expect(wrapper.vm.value.systemAgent).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.AGENT }`); - expect(wrapper.vm.value.provisioning).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.PROVISIONING }`); - expect(wrapper.vm.value.k8sDistro).toStrictEqual(`${ inputPath }/${ DEFAULT_SUBDIRS.K8S_DISTRO_K3S }`); + expect(systemAgentInput.attributes('disabled')).toBe('disabled'); + expect(provisioningInput.attributes('disabled')).toBe('disabled'); + expect(k8sDistroInput.attributes('disabled')).toBe('disabled'); }); }); diff --git a/shell/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue b/shell/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue index e2274594482..6b7803d8467 100644 --- a/shell/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue +++ b/shell/edit/provisioning.cattle.io.cluster/tabs/Advanced.vue @@ -101,7 +101,6 @@ export default {