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
31a02ff7
Commit
31a02ff7
authored
Sep 23, 2019
by
Andrew Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new Feature Flags Plugin to Access in FF Form
No more accessing the global object!
parent
26578c4c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
16 deletions
+28
-16
ee/app/assets/javascripts/feature_flags/components/form.vue
ee/app/assets/javascripts/feature_flags/components/form.vue
+4
-2
ee/app/assets/javascripts/feature_flags/components/new_feature_flag.vue
...javascripts/feature_flags/components/new_feature_flag.vue
+10
-4
ee/app/assets/javascripts/feature_flags/store/modules/helpers.js
...assets/javascripts/feature_flags/store/modules/helpers.js
+2
-2
ee/spec/frontend/feature_flags/store/helpers_spec.js
ee/spec/frontend/feature_flags/store/helpers_spec.js
+9
-0
ee/spec/javascripts/feature_flags/components/form_spec.js
ee/spec/javascripts/feature_flags/components/form_spec.js
+3
-8
No files found.
ee/app/assets/javascripts/feature_flags/components/form.vue
View file @
31a02ff7
...
...
@@ -3,6 +3,7 @@ import Vue from 'vue';
import
_
from
'
underscore
'
;
import
{
GlButton
,
GlBadge
,
GlTooltip
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
featureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
ToggleButton
from
'
~/vue_shared/components/toggle_button.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
EnvironmentsDropdown
from
'
./environments_dropdown.vue
'
;
...
...
@@ -28,6 +29,7 @@ export default {
directives
:
{
GlTooltip
:
GlTooltipDirective
,
},
mixins
:
[
featureFlagsMixin
()],
props
:
{
name
:
{
type
:
String
,
...
...
@@ -98,7 +100,7 @@ export default {
return
!
this
.
permissionsFlag
||
(
this
.
formScopes
||
[]).
every
(
scope
=>
scope
.
canUpdate
);
},
permissionsFlag
()
{
return
gon
&&
gon
.
features
&&
gon
.
f
eatures
.
featureFlagPermissions
;
return
this
.
glF
eatures
.
featureFlagPermissions
;
},
userIds
()
{
...
...
@@ -137,7 +139,7 @@ export default {
* be used override the default scope options
*/
createNewScope
(
overrides
)
{
this
.
formScopes
.
push
(
createNewEnvironmentScope
(
overrides
));
this
.
formScopes
.
push
(
createNewEnvironmentScope
(
overrides
,
this
.
permissionsFlag
));
this
.
newScope
=
''
;
},
...
...
ee/app/assets/javascripts/feature_flags/components/new_feature_flag.vue
View file @
31a02ff7
...
...
@@ -4,6 +4,8 @@ import store from '../store/index';
import
FeatureFlagForm
from
'
./form.vue
'
;
import
{
createNewEnvironmentScope
}
from
'
../store/modules/helpers
'
;
import
featureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
const
{
mapState
,
mapActions
}
=
createNamespacedHelpers
(
'
new
'
);
export
default
{
...
...
@@ -11,6 +13,7 @@ export default {
components
:
{
FeatureFlagForm
,
},
mixins
:
[
featureFlagsMixin
()],
props
:
{
endpoint
:
{
type
:
String
,
...
...
@@ -29,10 +32,13 @@ export default {
...
mapState
([
'
error
'
]),
scopes
()
{
return
[
createNewEnvironmentScope
({
environmentScope
:
'
*
'
,
active
:
true
,
}),
createNewEnvironmentScope
(
{
environmentScope
:
'
*
'
,
active
:
true
,
},
this
.
glFeatures
.
featureFlagsPermissions
,
),
];
},
},
...
...
ee/app/assets/javascripts/feature_flags/store/modules/helpers.js
View file @
31a02ff7
...
...
@@ -106,7 +106,7 @@ export const mapFromScopesViewModel = params => {
* property values will be used to override the default values.
*
*/
export
const
createNewEnvironmentScope
=
(
overrides
=
{})
=>
{
export
const
createNewEnvironmentScope
=
(
overrides
=
{}
,
featureFlagPermissions
=
false
)
=>
{
const
defaultScope
=
{
environmentScope
:
''
,
active
:
false
,
...
...
@@ -121,7 +121,7 @@ export const createNewEnvironmentScope = (overrides = {}) => {
...
overrides
,
};
if
(
gon
&&
gon
.
features
&&
gon
.
features
.
featureFlagPermissions
)
{
if
(
featureFlagPermissions
)
{
newScope
.
canUpdate
=
true
;
newScope
.
protected
=
false
;
}
...
...
ee/spec/frontend/feature_flags/store/helpers_spec.js
View file @
31a02ff7
...
...
@@ -206,5 +206,14 @@ describe('feature flags helpers spec', () => {
expect
(
actual
).
toEqual
(
expected
);
});
it
(
'
sets canUpdate and protected when called with featureFlagPermissions=true
'
,
()
=>
{
expect
(
createNewEnvironmentScope
({},
true
)).
toEqual
(
expect
.
objectContaining
({
canUpdate
:
true
,
protected
:
false
,
}),
);
});
});
});
ee/spec/javascripts/feature_flags/components/form_spec.js
View file @
31a02ff7
...
...
@@ -25,18 +25,13 @@ describe('feature flag form', () => {
wrapper
=
mount
(
localVue
.
extend
(
Form
),
{
localVue
,
propsData
:
props
,
provide
:
{
glFeatures
:
{
featureFlagPermissions
:
true
},
},
sync
:
false
,
});
};
beforeAll
(()
=>
{
gon
.
features
=
{
featureFlagPermissions
:
true
};
});
afterAll
(()
=>
{
gon
.
features
=
null
;
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
...
...
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