Commit 5ae4b860 authored by Kushal Pandya's avatar Kushal Pandya

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

Add Feature Flag's Active Property to State

See merge request gitlab-org/gitlab!20855
parents 8e18a7cc 2283c9b6
......@@ -66,5 +66,7 @@ export const receiveFeatureFlagError = ({ commit }) => {
createFlash(__('Something went wrong on our end. Please try again!'));
};
export const toggleActive = ({ commit }, active) => commit(types.TOGGLE_ACTIVE, active);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -8,3 +8,5 @@ export const RECEIVE_UPDATE_FEATURE_FLAG_ERROR = 'RECEIVE_UPDATE_FEATURE_FLAG_ER
export const REQUEST_FEATURE_FLAG = 'REQUEST_FEATURE_FLAG';
export const RECEIVE_FEATURE_FLAG_SUCCESS = 'RECEIVE_FEATURE_FLAG_SUCCESS';
export const RECEIVE_FEATURE_FLAG_ERROR = 'RECEIVE_FEATURE_FLAG_ERROR';
export const TOGGLE_ACTIVE = 'TOGGLE_ACTIVE';
......@@ -18,6 +18,7 @@ export default {
state.name = response.name;
state.description = response.description;
state.iid = response.iid;
state.active = response.active;
state.scopes = mapToScopesViewModel(response.scopes);
},
[types.RECEIVE_FEATURE_FLAG_ERROR](state) {
......@@ -35,4 +36,7 @@ export default {
state.isSendingRequest = false;
state.error = error.message || [];
},
[types.TOGGLE_ACTIVE](state, active) {
state.active = active;
},
};
......@@ -10,4 +10,5 @@ export default () => ({
isLoading: false,
hasError: false,
iid: null,
active: true,
});
......@@ -11,6 +11,7 @@ import actions, {
requestFeatureFlag,
receiveFeatureFlagSuccess,
receiveFeatureFlagError,
toggleActive,
} from 'ee/feature_flags/store/modules/edit/actions';
import state from 'ee/feature_flags/store/modules/edit/state';
import * as types from 'ee/feature_flags/store/modules/edit/mutation_types';
......@@ -260,4 +261,17 @@ describe('Feature flags Edit Module actions', () => {
);
});
});
describe('toggelActive', () => {
it('should commit TOGGLE_ACTIVE mutation', done => {
testAction(
toggleActive,
true,
mockedState,
[{ type: types.TOGGLE_ACTIVE, payload: true }],
[],
done,
);
});
});
});
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