From efe741fbb248bf4b2a3d2fc93fd74077cc219c94 Mon Sep 17 00:00:00 2001 From: Dominic Couture Date: Fri, 4 Jul 2025 15:02:13 +0100 Subject: [PATCH 1/3] Set CI/CD variable to masked by default CI/CD variable creation interface now selects Masked as the default state. Changelog: changed --- .../components/ci_variable_drawer.vue | 4 ++-- .../components/ci_variable_drawer_spec.js | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue index 55f1bac06d9da5..30bbee76de73f1 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue @@ -188,7 +188,7 @@ export default { return { isMutationAlertVisible: false, variable: { ...defaultVariableState, ...this.selectedVariable }, - visibility: VISIBILITY_VISIBLE, + visibility: VISIBILITY_MASKED, trackedValidationErrorProperty: undefined, }; }, @@ -403,7 +403,7 @@ export default { resetForm() { this.variable = { ...this.defaultVariableState }; - this.visibility = VISIBILITY_VISIBLE; + this.visibility = VISIBILITY_MASKED; }, setEnvironmentScope(scope) { this.variable = { ...this.variable, environmentScope: scope }; diff --git a/spec/frontend/ci/ci_variable_list/components/ci_variable_drawer_spec.js b/spec/frontend/ci/ci_variable_list/components/ci_variable_drawer_spec.js index f4798affa717e9..93cbd2d2b2310a 100644 --- a/spec/frontend/ci/ci_variable_list/components/ci_variable_drawer_spec.js +++ b/spec/frontend/ci/ci_variable_list/components/ci_variable_drawer_spec.js @@ -392,8 +392,8 @@ describe('CI Variable Drawer', () => { createComponent({ props: { areHiddenVariablesAvailable: true } }); }); - it('is set to visible by default', () => { - expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_VISIBLE); + it('is set to masked by default', () => { + expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_MASKED); }); it.each` @@ -423,16 +423,15 @@ describe('CI Variable Drawer', () => { props: { selectedVariable: { ...mockProjectVariableFileType, - masked: true, - hidden: true, + masked: false, }, }, }); - expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_HIDDEN); + expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_VISIBLE); await wrapper.setProps({ mutationResponse: { message: 'Success', hasError: false } }); - expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_VISIBLE); + expect(findVisibilityRadioGroup().attributes('checked')).toBe(VISIBILITY_MASKED); }); }); -- GitLab From 1586a884754cbe6ab77d98ba9ab97b50d7259be4 Mon Sep 17 00:00:00 2001 From: Dominic Couture Date: Mon, 14 Jul 2025 12:00:12 -0400 Subject: [PATCH 2/3] Fix default initial state --- .../ci/ci_variable_list/components/ci_variable_drawer.vue | 2 +- .../features/variable_list_drawer_shared_examples.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue index 30bbee76de73f1..106e5183ba5829 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue @@ -324,7 +324,7 @@ export default { return this.variable; }, defaultVariableState() { - return { ...defaultVariableState, protected: this.isProtectedByDefault }; + return { ...defaultVariableState, masked: true, protected: this.isProtectedByDefault }; }, }, watch: { diff --git a/spec/support/shared_examples/features/variable_list_drawer_shared_examples.rb b/spec/support/shared_examples/features/variable_list_drawer_shared_examples.rb index 19751bdf27d17a..e07d4d8d487c7c 100644 --- a/spec/support/shared_examples/features/variable_list_drawer_shared_examples.rb +++ b/spec/support/shared_examples/features/variable_list_drawer_shared_examples.rb @@ -50,7 +50,7 @@ end end - it 'defaults to unmasked, expanded' do + it 'defaults to masked, expanded' do open_drawer fill_variable('NEW_KEY') @@ -61,7 +61,7 @@ page.within('[data-testid="ci-variable-table"]') do key_column = first(".js-ci-variable-row:nth-child(1) td[data-label='#{s_('CiVariables|Key')}']") - expect(key_column).not_to have_content(s_('CiVariables|Masked')) + expect(key_column).to have_content(s_('CiVariables|Masked')) expect(key_column).to have_content(s_('CiVariables|Expanded')) end end -- GitLab From 4e77f581b01affd75e511cb13b9d2ce322ff65e0 Mon Sep 17 00:00:00 2001 From: Dominic Couture Date: Wed, 16 Jul 2025 08:08:39 -0400 Subject: [PATCH 3/3] Move default value to constants file --- .../ci/ci_variable_list/components/ci_variable_drawer.vue | 2 +- app/assets/javascripts/ci/ci_variable_list/constants.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue index 106e5183ba5829..30bbee76de73f1 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue @@ -324,7 +324,7 @@ export default { return this.variable; }, defaultVariableState() { - return { ...defaultVariableState, masked: true, protected: this.isProtectedByDefault }; + return { ...defaultVariableState, protected: this.isProtectedByDefault }; }, }, watch: { diff --git a/app/assets/javascripts/ci/ci_variable_list/constants.js b/app/assets/javascripts/ci/ci_variable_list/constants.js index 21faa7e6115788..3966489e3c166c 100644 --- a/app/assets/javascripts/ci/ci_variable_list/constants.js +++ b/app/assets/javascripts/ci/ci_variable_list/constants.js @@ -32,7 +32,7 @@ export const defaultVariableState = { description: null, environmentScope: '*', key: '', - masked: false, + masked: true, hidden: false, protected: false, raw: false, -- GitLab