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
038922f4
Commit
038922f4
authored
Jun 23, 2020
by
Jason Goodman
Committed by
Shinya Maeda
Jun 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete correct strategy when removed from new feature flag
Generate Vue key for strategies without an id
parent
34fce96f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
8 deletions
+47
-8
ee/app/assets/javascripts/feature_flags/components/form.vue
ee/app/assets/javascripts/feature_flags/components/form.vue
+10
-3
ee/app/assets/javascripts/feature_flags/components/strategy.vue
.../assets/javascripts/feature_flags/components/strategy.vue
+6
-1
ee/changelogs/unreleased/new-ff-delete-strategy.yml
ee/changelogs/unreleased/new-ff-delete-strategy.yml
+5
-0
ee/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
.../projects/feature_flags/user_creates_feature_flag_spec.rb
+18
-0
ee/spec/frontend/feature_flags/components/form_spec.js
ee/spec/frontend/feature_flags/components/form_spec.js
+4
-4
ee/spec/support/helpers/feature_flag_helpers.rb
ee/spec/support/helpers/feature_flag_helpers.rb
+4
-0
No files found.
ee/app/assets/javascripts/feature_flags/components/form.vue
View file @
038922f4
<
script
>
<
script
>
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
{
memoize
,
isString
,
cloneDeep
,
isNumber
}
from
'
lodash
'
;
import
{
memoize
,
isString
,
cloneDeep
,
isNumber
,
uniqueId
}
from
'
lodash
'
;
import
{
import
{
GlDeprecatedButton
,
GlDeprecatedButton
,
GlDeprecatedBadge
as
GlBadge
,
GlDeprecatedBadge
as
GlBadge
,
...
@@ -143,7 +143,6 @@ export default {
...
@@ -143,7 +143,6 @@ export default {
supportsStrategies
()
{
supportsStrategies
()
{
return
this
.
glFeatures
.
featureFlagsNewVersion
&&
this
.
version
===
NEW_VERSION_FLAG
;
return
this
.
glFeatures
.
featureFlagsNewVersion
&&
this
.
version
===
NEW_VERSION_FLAG
;
},
},
canDeleteStrategy
()
{
canDeleteStrategy
()
{
return
this
.
formStrategies
.
length
>
1
;
return
this
.
formStrategies
.
length
>
1
;
},
},
...
@@ -160,6 +159,14 @@ export default {
...
@@ -160,6 +159,14 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
keyFor
(
strategy
)
{
if
(
strategy
.
id
)
{
return
strategy
.
id
;
}
return
uniqueId
(
'
strategy_
'
);
},
addStrategy
()
{
addStrategy
()
{
this
.
formStrategies
.
push
({
name
:
''
,
parameters
:
{},
scopes
:
[]
});
this
.
formStrategies
.
push
({
name
:
''
,
parameters
:
{},
scopes
:
[]
});
},
},
...
@@ -321,7 +328,7 @@ export default {
...
@@ -321,7 +328,7 @@ export default {
<div
v-if=
"filteredStrategies.length > 0"
data-testid=
"feature-flag-strategies"
>
<div
v-if=
"filteredStrategies.length > 0"
data-testid=
"feature-flag-strategies"
>
<strategy
<strategy
v-for=
"(strategy, index) in filteredStrategies"
v-for=
"(strategy, index) in filteredStrategies"
:key=
"
strategy.id
"
:key=
"
keyFor(strategy)
"
:strategy=
"strategy"
:strategy=
"strategy"
:index=
"index"
:index=
"index"
:endpoint=
"environmentsEndpoint"
:endpoint=
"environmentsEndpoint"
...
...
ee/app/assets/javascripts/feature_flags/components/strategy.vue
View file @
038922f4
...
@@ -273,7 +273,12 @@ export default {
...
@@ -273,7 +273,12 @@ export default {
</div>
</div>
<div
class=
"align-self-end align-self-md-stretch order-first offset-md-0 order-md-0 ml-auto"
>
<div
class=
"align-self-end align-self-md-stretch order-first offset-md-0 order-md-0 ml-auto"
>
<gl-deprecated-button
v-if=
"canDelete"
variant=
"danger"
@
click=
"$emit('delete')"
>
<gl-deprecated-button
v-if=
"canDelete"
data-testid=
"delete-strategy-button"
variant=
"danger"
@
click=
"$emit('delete')"
>
<span
class=
"d-md-none"
>
<span
class=
"d-md-none"
>
{{
$options
.
translations
.
removeLabel
}}
{{
$options
.
translations
.
removeLabel
}}
</span>
</span>
...
...
ee/changelogs/unreleased/new-ff-delete-strategy.yml
0 → 100644
View file @
038922f4
---
title
:
Remove correct feature flag strategy when removing strategy that is not persisted
merge_request
:
34889
author
:
type
:
fixed
ee/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb
View file @
038922f4
...
@@ -50,6 +50,24 @@ RSpec.describe 'User creates feature flag', :js do
...
@@ -50,6 +50,24 @@ RSpec.describe 'User creates feature flag', :js do
end
end
end
end
it
'removes the correct strategy when a strategy is deleted'
do
visit
(
new_project_feature_flag_path
(
project
))
click_button
'Add strategy'
within_strategy_row
(
1
)
do
select
'All users'
,
from:
'Type'
end
within_strategy_row
(
2
)
do
select
'Percent rollout (logged in users)'
,
from:
'Type'
end
within_strategy_row
(
1
)
do
delete_strategy_button
.
click
end
within_strategy_row
(
1
)
do
expect
(
page
).
to
have_select
(
'Type'
,
selected:
'Percent rollout (logged in users)'
)
end
end
context
'with new version flags disabled'
do
context
'with new version flags disabled'
do
before
do
before
do
stub_feature_flags
(
feature_flags_new_version:
false
)
stub_feature_flags
(
feature_flags_new_version:
false
)
...
...
ee/spec/frontend/feature_flags/components/form_spec.js
View file @
038922f4
...
@@ -406,12 +406,12 @@ describe('feature flag form', () => {
...
@@ -406,12 +406,12 @@ describe('feature flag form', () => {
strategies
:
[
strategies
:
[
{
{
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
paramters
:
{
percentage
:
'
30
'
},
param
e
ters
:
{
percentage
:
'
30
'
},
scopes
:
[],
scopes
:
[],
},
},
{
{
type
:
ROLLOUT_STRATEGY_ALL_USERS
,
type
:
ROLLOUT_STRATEGY_ALL_USERS
,
paramters
:
{},
param
e
ters
:
{},
scopes
:
[{
environment_scope
:
'
review/*
'
}],
scopes
:
[{
environment_scope
:
'
review/*
'
}],
},
},
],
],
...
@@ -429,7 +429,7 @@ describe('feature flag form', () => {
...
@@ -429,7 +429,7 @@ describe('feature flag form', () => {
expect
(
strategy
.
exists
()).
toBe
(
true
);
expect
(
strategy
.
exists
()).
toBe
(
true
);
expect
(
strategy
.
props
(
'
strategy
'
)).
toEqual
({
expect
(
strategy
.
props
(
'
strategy
'
)).
toEqual
({
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
paramters
:
{
percentage
:
'
30
'
},
param
e
ters
:
{
percentage
:
'
30
'
},
scopes
:
[],
scopes
:
[],
});
});
});
});
...
@@ -446,7 +446,7 @@ describe('feature flag form', () => {
...
@@ -446,7 +446,7 @@ describe('feature flag form', () => {
it
(
'
should remove a strategy on delete
'
,
()
=>
{
it
(
'
should remove a strategy on delete
'
,
()
=>
{
const
strategy
=
{
const
strategy
=
{
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
type
:
ROLLOUT_STRATEGY_PERCENT_ROLLOUT
,
paramters
:
{
percentage
:
'
30
'
},
param
e
ters
:
{
percentage
:
'
30
'
},
scopes
:
[],
scopes
:
[],
};
};
wrapper
.
find
(
Strategy
).
vm
.
$emit
(
'
delete
'
);
wrapper
.
find
(
Strategy
).
vm
.
$emit
(
'
delete
'
);
...
...
ee/spec/support/helpers/feature_flag_helpers.rb
View file @
038922f4
...
@@ -60,6 +60,10 @@ module FeatureFlagHelpers
...
@@ -60,6 +60,10 @@ module FeatureFlagHelpers
find
(
'.js-feature-flag-edit-button'
)
find
(
'.js-feature-flag-edit-button'
)
end
end
def
delete_strategy_button
find
(
"button[data-testid='delete-strategy-button']"
)
end
def
status_toggle_button
def
status_toggle_button
find
(
'.js-feature-flag-status button'
)
find
(
'.js-feature-flag-status button'
)
end
end
...
...
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