Commit 40ea986b authored by Phil Hughes's avatar Phil Hughes

Merge branch 'add-feature-flag-toggle--form' into 'master'

Add Active Property to Feature Flag Form

See merge request gitlab-org/gitlab!20857
parents 9719ce13 a1b3f121
...@@ -41,6 +41,11 @@ export default { ...@@ -41,6 +41,11 @@ export default {
}, },
mixins: [featureFlagsMixin()], mixins: [featureFlagsMixin()],
props: { props: {
active: {
type: Boolean,
required: false,
default: true,
},
name: { name: {
type: String, type: String,
required: false, required: false,
...@@ -165,6 +170,7 @@ export default { ...@@ -165,6 +170,7 @@ export default {
name: this.formName, name: this.formName,
description: this.formDescription, description: this.formDescription,
scopes: this.formScopes, scopes: this.formScopes,
active: this.active,
}); });
}, },
...@@ -304,7 +310,7 @@ export default { ...@@ -304,7 +310,7 @@ export default {
<div class="table-mobile-content js-feature-flag-status"> <div class="table-mobile-content js-feature-flag-status">
<toggle-button <toggle-button
:value="scope.active" :value="scope.active"
:disabled-input="!canUpdateScope(scope)" :disabled-input="!active || !canUpdateScope(scope)"
@change="status => (scope.active = status)" @change="status => (scope.active = status)"
/> />
</div> </div>
...@@ -436,7 +442,11 @@ export default { ...@@ -436,7 +442,11 @@ export default {
{{ s__('FeatureFlags|Status') }} {{ s__('FeatureFlags|Status') }}
</div> </div>
<div class="table-mobile-content js-feature-flag-status"> <div class="table-mobile-content js-feature-flag-status">
<toggle-button :value="false" @change="createNewScope({ active: true })" /> <toggle-button
:disabled-input="!active"
:value="false"
@change="createNewScope({ active: true })"
/>
</div> </div>
</div> </div>
......
...@@ -113,13 +113,16 @@ export const mapFromScopesViewModel = params => { ...@@ -113,13 +113,16 @@ export const mapFromScopesViewModel = params => {
}; };
}); });
return { const model = {
operations_feature_flag: { operations_feature_flag: {
name: params.name, name: params.name,
description: params.description, description: params.description,
active: params.active,
scopes_attributes: scopes, scopes_attributes: scopes,
}, },
}; };
return model;
}; };
/** /**
......
...@@ -37,7 +37,11 @@ describe('feature flag form', () => { ...@@ -37,7 +37,11 @@ describe('feature flag form', () => {
localVue, localVue,
propsData: props, propsData: props,
provide: { provide: {
glFeatures: { featureFlagPermissions: true, featureFlagsUsersPerEnvironment: true }, glFeatures: {
featureFlagPermissions: true,
featureFlagsUsersPerEnvironment: true,
featureFlagToggle: true,
},
}, },
sync: false, sync: false,
}); });
...@@ -93,6 +97,14 @@ describe('feature flag form', () => { ...@@ -93,6 +97,14 @@ describe('feature flag form', () => {
expect(wrapper.vm.newScope).toEqual(''); expect(wrapper.vm.newScope).toEqual('');
}); });
}); });
it('should be disabled if the feature flag is not active', done => {
wrapper.setProps({ active: false });
wrapper.vm.$nextTick(() => {
expect(wrapper.find(ToggleButton).props('disabledInput')).toBe(true);
done();
});
});
}); });
}); });
}); });
...@@ -103,6 +115,7 @@ describe('feature flag form', () => { ...@@ -103,6 +115,7 @@ describe('feature flag form', () => {
...requiredProps, ...requiredProps,
name: featureFlag.name, name: featureFlag.name,
description: featureFlag.description, description: featureFlag.description,
active: true,
scopes: [ scopes: [
{ {
id: 1, id: 1,
...@@ -156,6 +169,15 @@ describe('feature flag form', () => { ...@@ -156,6 +169,15 @@ describe('feature flag form', () => {
expect(_.first(wrapper.vm.formScopes).active).toBe(false); expect(_.first(wrapper.vm.formScopes).active).toBe(false);
}); });
it('should be disabled if the feature flag is not active', done => {
wrapper.setProps({ active: false });
wrapper.vm.$nextTick(() => {
expect(wrapper.find(ToggleButton).props('disabledInput')).toBe(true);
done();
});
});
}); });
}); });
...@@ -262,6 +284,7 @@ describe('feature flag form', () => { ...@@ -262,6 +284,7 @@ describe('feature flag form', () => {
factory({ factory({
...requiredProps, ...requiredProps,
name: 'feature_flag_1', name: 'feature_flag_1',
active: true,
description: 'this is a feature flag', description: 'this is a feature flag',
scopes: [ scopes: [
{ {
...@@ -316,6 +339,7 @@ describe('feature flag form', () => { ...@@ -316,6 +339,7 @@ describe('feature flag form', () => {
expect(data.name).toEqual('feature_flag_2'); expect(data.name).toEqual('feature_flag_2');
expect(data.description).toEqual('this is a feature flag'); expect(data.description).toEqual('this is a feature flag');
expect(data.active).toBe(true);
expect(data.scopes).toEqual([ expect(data.scopes).toEqual([
{ {
......
...@@ -152,6 +152,7 @@ describe('feature flags helpers spec', () => { ...@@ -152,6 +152,7 @@ describe('feature flags helpers spec', () => {
const input = { const input = {
name: 'name', name: 'name',
description: 'description', description: 'description',
active: true,
scopes: [ scopes: [
{ {
id: 4, id: 4,
...@@ -171,6 +172,7 @@ describe('feature flags helpers spec', () => { ...@@ -171,6 +172,7 @@ describe('feature flags helpers spec', () => {
operations_feature_flag: { operations_feature_flag: {
name: 'name', name: 'name',
description: 'description', description: 'description',
active: true,
scopes_attributes: [ scopes_attributes: [
{ {
id: 4, id: 4,
......
...@@ -59,6 +59,7 @@ describe('Feature flags New Module Actions', () => { ...@@ -59,6 +59,7 @@ describe('Feature flags New Module Actions', () => {
const actionParams = { const actionParams = {
name: 'name', name: 'name',
description: 'description', description: 'description',
active: true,
scopes: [ scopes: [
{ {
id: 1, id: 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment