Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9723f5a3
Commit
9723f5a3
authored
May 13, 2020
by
Payton Burdette
Committed by
Natalia Tepluhina
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix admin setting bug
Fix admin setting bug where user has enviroment variables enabled by default.
parent
ee8c2f61
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
53 additions
and
2 deletions
+53
-2
app/assets/javascripts/ci_variable_list/components/ci_variable_modal.vue
...scripts/ci_variable_list/components/ci_variable_modal.vue
+8
-0
app/assets/javascripts/ci_variable_list/index.js
app/assets/javascripts/ci_variable_list/index.js
+3
-1
app/assets/javascripts/ci_variable_list/store/actions.js
app/assets/javascripts/ci_variable_list/store/actions.js
+4
-0
app/assets/javascripts/ci_variable_list/store/mutation_types.js
...sets/javascripts/ci_variable_list/store/mutation_types.js
+1
-0
app/assets/javascripts/ci_variable_list/store/mutations.js
app/assets/javascripts/ci_variable_list/store/mutations.js
+4
-0
app/assets/javascripts/ci_variable_list/store/state.js
app/assets/javascripts/ci_variable_list/store/state.js
+1
-0
app/views/ci/variables/_index.html.haml
app/views/ci/variables/_index.html.haml
+1
-1
changelogs/unreleased/fix-protected-vars-by-default.yml
changelogs/unreleased/fix-protected-vars-by-default.yml
+6
-0
spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
...end/ci_variable_list/components/ci_variable_modal_spec.js
+7
-0
spec/frontend/ci_variable_list/store/actions_spec.js
spec/frontend/ci_variable_list/store/actions_spec.js
+10
-0
spec/frontend/ci_variable_list/store/mutations_spec.js
spec/frontend/ci_variable_list/store/mutations_spec.js
+8
-0
No files found.
app/assets/javascripts/ci_variable_list/components/ci_variable_modal.vue
View file @
9723f5a3
...
@@ -46,6 +46,7 @@ export default {
...
@@ -46,6 +46,7 @@ export default {
'
isGroup
'
,
'
isGroup
'
,
'
maskableRegex
'
,
'
maskableRegex
'
,
'
selectedEnvironment
'
,
'
selectedEnvironment
'
,
'
isProtectedByDefault
'
,
]),
]),
canSubmit
()
{
canSubmit
()
{
return
(
return
(
...
@@ -123,6 +124,7 @@ export default {
...
@@ -123,6 +124,7 @@ export default {
'
addWildCardScope
'
,
'
addWildCardScope
'
,
'
resetSelectedEnvironment
'
,
'
resetSelectedEnvironment
'
,
'
setSelectedEnvironment
'
,
'
setSelectedEnvironment
'
,
'
setVariableProtected
'
,
]),
]),
deleteVarAndClose
()
{
deleteVarAndClose
()
{
this
.
deleteVariable
(
this
.
variableBeingEdited
);
this
.
deleteVariable
(
this
.
variableBeingEdited
);
...
@@ -147,6 +149,11 @@ export default {
...
@@ -147,6 +149,11 @@ export default {
}
}
this
.
hideModal
();
this
.
hideModal
();
},
},
setVariableProtectedByDefault
()
{
if
(
this
.
isProtectedByDefault
&&
!
this
.
variableBeingEdited
)
{
this
.
setVariableProtected
();
}
},
},
},
};
};
</
script
>
</
script
>
...
@@ -159,6 +166,7 @@ export default {
...
@@ -159,6 +166,7 @@ export default {
static
static
lazy
lazy
@
hidden=
"resetModalHandler"
@
hidden=
"resetModalHandler"
@
shown=
"setVariableProtectedByDefault"
>
>
<form>
<form>
<ci-key-field
<ci-key-field
...
...
app/assets/javascripts/ci_variable_list/index.js
View file @
9723f5a3
...
@@ -5,14 +5,16 @@ import { parseBoolean } from '~/lib/utils/common_utils';
...
@@ -5,14 +5,16 @@ import { parseBoolean } from '~/lib/utils/common_utils';
export
default
()
=>
{
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
js-ci-project-variables
'
);
const
el
=
document
.
getElementById
(
'
js-ci-project-variables
'
);
const
{
endpoint
,
projectId
,
group
,
maskableRegex
}
=
el
.
dataset
;
const
{
endpoint
,
projectId
,
group
,
maskableRegex
,
protectedByDefault
}
=
el
.
dataset
;
const
isGroup
=
parseBoolean
(
group
);
const
isGroup
=
parseBoolean
(
group
);
const
isProtectedByDefault
=
parseBoolean
(
protectedByDefault
);
const
store
=
createStore
({
const
store
=
createStore
({
endpoint
,
endpoint
,
projectId
,
projectId
,
isGroup
,
isGroup
,
maskableRegex
,
maskableRegex
,
isProtectedByDefault
,
});
});
return
new
Vue
({
return
new
Vue
({
...
...
app/assets/javascripts/ci_variable_list/store/actions.js
View file @
9723f5a3
...
@@ -20,6 +20,10 @@ export const resetEditing = ({ commit, dispatch }) => {
...
@@ -20,6 +20,10 @@ export const resetEditing = ({ commit, dispatch }) => {
commit
(
types
.
RESET_EDITING
);
commit
(
types
.
RESET_EDITING
);
};
};
export
const
setVariableProtected
=
({
commit
})
=>
{
commit
(
types
.
SET_VARIABLE_PROTECTED
);
};
export
const
requestAddVariable
=
({
commit
})
=>
{
export
const
requestAddVariable
=
({
commit
})
=>
{
commit
(
types
.
REQUEST_ADD_VARIABLE
);
commit
(
types
.
REQUEST_ADD_VARIABLE
);
};
};
...
...
app/assets/javascripts/ci_variable_list/store/mutation_types.js
View file @
9723f5a3
...
@@ -2,6 +2,7 @@ export const TOGGLE_VALUES = 'TOGGLE_VALUES';
...
@@ -2,6 +2,7 @@ export const TOGGLE_VALUES = 'TOGGLE_VALUES';
export
const
VARIABLE_BEING_EDITED
=
'
VARIABLE_BEING_EDITED
'
;
export
const
VARIABLE_BEING_EDITED
=
'
VARIABLE_BEING_EDITED
'
;
export
const
RESET_EDITING
=
'
RESET_EDITING
'
;
export
const
RESET_EDITING
=
'
RESET_EDITING
'
;
export
const
CLEAR_MODAL
=
'
CLEAR_MODAL
'
;
export
const
CLEAR_MODAL
=
'
CLEAR_MODAL
'
;
export
const
SET_VARIABLE_PROTECTED
=
'
SET_VARIABLE_PROTECTED
'
;
export
const
REQUEST_VARIABLES
=
'
REQUEST_VARIABLES
'
;
export
const
REQUEST_VARIABLES
=
'
REQUEST_VARIABLES
'
;
export
const
RECEIVE_VARIABLES_SUCCESS
=
'
RECEIVE_VARIABLES_SUCCESS
'
;
export
const
RECEIVE_VARIABLES_SUCCESS
=
'
RECEIVE_VARIABLES_SUCCESS
'
;
...
...
app/assets/javascripts/ci_variable_list/store/mutations.js
View file @
9723f5a3
...
@@ -104,4 +104,8 @@ export default {
...
@@ -104,4 +104,8 @@ export default {
[
types
.
SET_SELECTED_ENVIRONMENT
](
state
,
environment
)
{
[
types
.
SET_SELECTED_ENVIRONMENT
](
state
,
environment
)
{
state
.
selectedEnvironment
=
environment
;
state
.
selectedEnvironment
=
environment
;
},
},
[
types
.
SET_VARIABLE_PROTECTED
](
state
)
{
state
.
variable
.
protected
=
true
;
},
};
};
app/assets/javascripts/ci_variable_list/store/state.js
View file @
9723f5a3
...
@@ -5,6 +5,7 @@ export default () => ({
...
@@ -5,6 +5,7 @@ export default () => ({
projectId
:
null
,
projectId
:
null
,
isGroup
:
null
,
isGroup
:
null
,
maskableRegex
:
null
,
maskableRegex
:
null
,
isProtectedByDefault
:
null
,
isLoading
:
false
,
isLoading
:
false
,
isDeleting
:
false
,
isDeleting
:
false
,
variable
:
{
variable
:
{
...
...
app/views/ci/variables/_index.html.haml
View file @
9723f5a3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
-
if
Feature
.
enabled?
(
:new_variables_ui
,
@project
||
@group
,
default_enabled:
true
)
-
if
Feature
.
enabled?
(
:new_variables_ui
,
@project
||
@group
,
default_enabled:
true
)
-
is_group
=
!
@group
.
nil?
-
is_group
=
!
@group
.
nil?
#js-ci-project-variables
{
data:
{
endpoint:
save_endpoint
,
project_id:
@project
&
.
id
||
''
,
group:
is_group
.
to_s
,
maskable_regex:
ci_variable_maskable_regex
}
}
#js-ci-project-variables
{
data:
{
endpoint:
save_endpoint
,
project_id:
@project
&
.
id
||
''
,
group:
is_group
.
to_s
,
maskable_regex:
ci_variable_maskable_regex
,
protected_by_default:
ci_variable_protected_by_default?
.
to_s
}
}
-
else
-
else
.row
.row
...
...
changelogs/unreleased/fix-protected-vars-by-default.yml
0 → 100644
View file @
9723f5a3
---
title
:
Fixes bug where variables were not protected by default when using the correct
CI/CD admin setting
merge_request
:
31655
author
:
type
:
fixed
spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
View file @
9723f5a3
...
@@ -96,6 +96,13 @@ describe('Ci variable modal', () => {
...
@@ -96,6 +96,13 @@ describe('Ci variable modal', () => {
findModal
().
vm
.
$emit
(
'
hidden
'
);
findModal
().
vm
.
$emit
(
'
hidden
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
clearModal
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
clearModal
'
);
});
});
it
(
'
should dispatch setVariableProtected when admin settings are configured to protect variables
'
,
()
=>
{
store
.
state
.
isProtectedByDefault
=
true
;
findModal
().
vm
.
$emit
(
'
shown
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
setVariableProtected
'
);
});
});
});
describe
(
'
Editing a variable
'
,
()
=>
{
describe
(
'
Editing a variable
'
,
()
=>
{
...
...
spec/frontend/ci_variable_list/store/actions_spec.js
View file @
9723f5a3
...
@@ -75,6 +75,16 @@ describe('CI variable list store actions', () => {
...
@@ -75,6 +75,16 @@ describe('CI variable list store actions', () => {
});
});
});
});
describe
(
'
setVariableProtected
'
,
()
=>
{
it
(
'
commits SET_VARIABLE_PROTECTED mutation
'
,
()
=>
{
testAction
(
actions
.
setVariableProtected
,
{},
{},
[
{
type
:
types
.
SET_VARIABLE_PROTECTED
,
},
]);
});
});
describe
(
'
deleteVariable
'
,
()
=>
{
describe
(
'
deleteVariable
'
,
()
=>
{
it
(
'
dispatch correct actions on successful deleted variable
'
,
done
=>
{
it
(
'
dispatch correct actions on successful deleted variable
'
,
done
=>
{
mock
.
onPatch
(
state
.
endpoint
).
reply
(
200
);
mock
.
onPatch
(
state
.
endpoint
).
reply
(
200
);
...
...
spec/frontend/ci_variable_list/store/mutations_spec.js
View file @
9723f5a3
...
@@ -97,4 +97,12 @@ describe('CI variable list mutations', () => {
...
@@ -97,4 +97,12 @@ describe('CI variable list mutations', () => {
expect
(
stateCopy
.
environments
).
toEqual
([
'
dev
'
,
'
production
'
,
'
staging
'
]);
expect
(
stateCopy
.
environments
).
toEqual
([
'
dev
'
,
'
production
'
,
'
staging
'
]);
});
});
});
});
describe
(
'
SET_VARIABLE_PROTECTED
'
,
()
=>
{
it
(
'
should set protected value to true
'
,
()
=>
{
mutations
[
types
.
SET_VARIABLE_PROTECTED
](
stateCopy
);
expect
(
stateCopy
.
variable
.
protected
).
toBe
(
true
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment