diff options
Diffstat (limited to 'app/assets/javascripts/feature_flags/store')
10 files changed, 31 insertions, 36 deletions
diff --git a/app/assets/javascripts/feature_flags/store/edit/actions.js b/app/assets/javascripts/feature_flags/store/edit/actions.js index 3678c2f7788..c4515e07a00 100644 --- a/app/assets/javascripts/feature_flags/store/edit/actions.js +++ b/app/assets/javascripts/feature_flags/store/edit/actions.js @@ -29,7 +29,7 @@ export const updateFeatureFlag = ({ state, dispatch }, params) => { dispatch('receiveUpdateFeatureFlagSuccess'); visitUrl(state.path); }) - .catch(error => dispatch('receiveUpdateFeatureFlagError', error.response.data)); + .catch((error) => dispatch('receiveUpdateFeatureFlagError', error.response.data)); }; export const requestUpdateFeatureFlag = ({ commit }) => commit(types.REQUEST_UPDATE_FEATURE_FLAG); diff --git a/app/assets/javascripts/feature_flags/store/edit/index.js b/app/assets/javascripts/feature_flags/store/edit/index.js index 81edc791924..65ea61c3025 100644 --- a/app/assets/javascripts/feature_flags/store/edit/index.js +++ b/app/assets/javascripts/feature_flags/store/edit/index.js @@ -4,7 +4,7 @@ import state from './state'; import * as actions from './actions'; import mutations from './mutations'; -export default data => +export default (data) => new Vuex.Store({ actions, mutations, diff --git a/app/assets/javascripts/feature_flags/store/gitlab_user_list/actions.js b/app/assets/javascripts/feature_flags/store/gitlab_user_list/actions.js index d4587713fed..a834524df6c 100644 --- a/app/assets/javascripts/feature_flags/store/gitlab_user_list/actions.js +++ b/app/assets/javascripts/feature_flags/store/gitlab_user_list/actions.js @@ -1,14 +1,14 @@ import Api from '~/api'; import * as types from './mutation_types'; -const getErrorMessages = error => [].concat(error?.response?.data?.message ?? error.message); +const getErrorMessages = (error) => [].concat(error?.response?.data?.message ?? error.message); export const fetchUserLists = ({ commit, state: { filter, projectId } }) => { commit(types.FETCH_USER_LISTS); return Api.searchFeatureFlagUserLists(projectId, filter) .then(({ data }) => commit(types.RECEIVE_USER_LISTS_SUCCESS, data)) - .catch(error => commit(types.RECEIVE_USER_LISTS_ERROR, getErrorMessages(error))); + .catch((error) => commit(types.RECEIVE_USER_LISTS_ERROR, getErrorMessages(error))); }; export const setFilter = ({ commit, dispatch }, filter) => { diff --git a/app/assets/javascripts/feature_flags/store/gitlab_user_list/index.js b/app/assets/javascripts/feature_flags/store/gitlab_user_list/index.js index d25b574981f..5f2726770d5 100644 --- a/app/assets/javascripts/feature_flags/store/gitlab_user_list/index.js +++ b/app/assets/javascripts/feature_flags/store/gitlab_user_list/index.js @@ -3,7 +3,7 @@ import mutations from './mutations'; import * as actions from './actions'; import * as getters from './getters'; -export default data => ({ +export default (data) => ({ state: state(data), actions, getters, diff --git a/app/assets/javascripts/feature_flags/store/helpers.js b/app/assets/javascripts/feature_flags/store/helpers.js index d42e5c504db..2fa20e25f4e 100644 --- a/app/assets/javascripts/feature_flags/store/helpers.js +++ b/app/assets/javascripts/feature_flags/store/helpers.js @@ -17,16 +17,16 @@ import { * objects that is easier/nicer to bind to in Vue. * @param {Array} scopesFromRails An array of scope objects fetched from the API */ -export const mapToScopesViewModel = scopesFromRails => - (scopesFromRails || []).map(s => { +export const mapToScopesViewModel = (scopesFromRails) => + (scopesFromRails || []).map((s) => { const percentStrategy = (s.strategies || []).find( - strat => strat.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT, + (strat) => strat.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT, ); const rolloutPercentage = fetchPercentageParams(percentStrategy) || DEFAULT_PERCENT_ROLLOUT; const userStrategy = (s.strategies || []).find( - strat => strat.name === ROLLOUT_STRATEGY_USER_ID, + (strat) => strat.name === ROLLOUT_STRATEGY_USER_ID, ); const rolloutStrategy = @@ -36,7 +36,7 @@ export const mapToScopesViewModel = scopesFromRails => const rolloutUserIds = (fetchUserIdParams(userStrategy) || '') .split(',') - .filter(id => id) + .filter((id) => id) .join(', '); return { @@ -59,8 +59,8 @@ export const mapToScopesViewModel = scopesFromRails => * the shape that the Rails API expects. * @param {Array} scopesFromVue An array of scope objects from the Vue component */ -export const mapFromScopesViewModel = params => { - const scopes = (params.scopes || []).map(s => { +export const mapFromScopesViewModel = (params) => { + const scopes = (params.scopes || []).map((s) => { const parameters = {}; if (s.rolloutStrategy === ROLLOUT_STRATEGY_PERCENT_ROLLOUT) { parameters.groupId = PERCENT_ROLLOUT_GROUP_ID; @@ -145,32 +145,32 @@ export const createNewEnvironmentScope = (overrides = {}, featureFlagPermissions return newScope; }; -const mapStrategyScopesToRails = scopes => +const mapStrategyScopesToRails = (scopes) => scopes.length === 0 ? [{ environment_scope: '*' }] - : scopes.map(s => ({ + : scopes.map((s) => ({ id: s.id, _destroy: s.shouldBeDestroyed, environment_scope: s.environmentScope, })); -const mapStrategyScopesToView = scopes => - scopes.map(s => ({ +const mapStrategyScopesToView = (scopes) => + scopes.map((s) => ({ id: s.id, // eslint-disable-next-line no-underscore-dangle shouldBeDestroyed: Boolean(s._destroy), environmentScope: s.environment_scope, })); -const mapStrategiesParametersToViewModel = params => { +const mapStrategiesParametersToViewModel = (params) => { if (params.userIds) { return { ...params, userIds: params.userIds.split(',').join(', ') }; } return params; }; -export const mapStrategiesToViewModel = strategiesFromRails => - (strategiesFromRails || []).map(s => ({ +export const mapStrategiesToViewModel = (strategiesFromRails) => + (strategiesFromRails || []).map((s) => ({ id: s.id, name: s.name, parameters: mapStrategiesParametersToViewModel(s.parameters), @@ -180,14 +180,14 @@ export const mapStrategiesToViewModel = strategiesFromRails => scopes: mapStrategyScopesToView(s.scopes), })); -const mapStrategiesParametersToRails = params => { +const mapStrategiesParametersToRails = (params) => { if (params.userIds) { return { ...params, userIds: params.userIds.replace(/\s*,\s*/g, ',') }; } return params; }; -const mapStrategyToRails = strategy => { +const mapStrategyToRails = (strategy) => { const mappedStrategy = { id: strategy.id, name: strategy.name, @@ -202,7 +202,7 @@ const mapStrategyToRails = strategy => { return mappedStrategy; }; -export const mapStrategiesToRails = params => ({ +export const mapStrategiesToRails = (params) => ({ operations_feature_flag: { name: params.name, description: params.description, diff --git a/app/assets/javascripts/feature_flags/store/index/actions.js b/app/assets/javascripts/feature_flags/store/index/actions.js index a8c1a72c016..6b6b3d55e16 100644 --- a/app/assets/javascripts/feature_flags/store/index/actions.js +++ b/app/assets/javascripts/feature_flags/store/index/actions.js @@ -12,7 +12,7 @@ export const fetchFeatureFlags = ({ state, dispatch }) => { .get(state.endpoint, { params: state.options, }) - .then(response => + .then((response) => dispatch('receiveFeatureFlagsSuccess', { data: response.data || {}, headers: response.headers, @@ -46,7 +46,7 @@ export const toggleFeatureFlag = ({ dispatch }, flag) => { .put(flag.update_path, { operations_feature_flag: flag, }) - .then(response => dispatch('receiveUpdateFeatureFlagSuccess', response.data)) + .then((response) => dispatch('receiveUpdateFeatureFlagSuccess', response.data)) .catch(() => dispatch('receiveUpdateFeatureFlagError', flag.id)); }; @@ -62,7 +62,7 @@ export const deleteUserList = ({ state, dispatch }, list) => { return Api.deleteFeatureFlagUserList(state.projectId, list.iid) .then(() => dispatch('fetchUserLists')) - .catch(error => + .catch((error) => dispatch('receiveDeleteUserListError', { list, error: error?.response?.data ?? error, diff --git a/app/assets/javascripts/feature_flags/store/index/index.js b/app/assets/javascripts/feature_flags/store/index/index.js index f737e0517fc..76495a33232 100644 --- a/app/assets/javascripts/feature_flags/store/index/index.js +++ b/app/assets/javascripts/feature_flags/store/index/index.js @@ -3,7 +3,7 @@ import state from './state'; import * as actions from './actions'; import mutations from './mutations'; -export default data => +export default (data) => new Vuex.Store({ actions, mutations, diff --git a/app/assets/javascripts/feature_flags/store/index/mutations.js b/app/assets/javascripts/feature_flags/store/index/mutations.js index bdc23e66214..910b2ec42d4 100644 --- a/app/assets/javascripts/feature_flags/store/index/mutations.js +++ b/app/assets/javascripts/feature_flags/store/index/mutations.js @@ -4,7 +4,7 @@ import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils'; import { FEATURE_FLAG_SCOPE, USER_LIST_SCOPE } from '../../constants'; import { mapToScopesViewModel } from '../helpers'; -const mapFlag = flag => ({ ...flag, scopes: mapToScopesViewModel(flag.scopes || []) }); +const mapFlag = (flag) => ({ ...flag, scopes: mapToScopesViewModel(flag.scopes || []) }); const updateFlag = (state, flag) => { const index = state[FEATURE_FLAG_SCOPE].findIndex(({ id }) => id === flag.id); @@ -74,12 +74,7 @@ export default { state.isRotating = true; state.hasRotateError = false; }, - [types.RECEIVE_ROTATE_INSTANCE_ID_SUCCESS]( - state, - { - data: { token }, - }, - ) { + [types.RECEIVE_ROTATE_INSTANCE_ID_SUCCESS](state, { data: { token } }) { state.isRotating = false; state.instanceId = token; state.hasRotateError = false; @@ -99,7 +94,7 @@ export default { updateFlag(state, { ...flag, active: !flag.active }); }, [types.REQUEST_DELETE_USER_LIST](state, list) { - state.userLists = state.userLists.filter(l => l !== list); + state.userLists = state.userLists.filter((l) => l !== list); }, [types.RECEIVE_DELETE_USER_LIST_ERROR](state, { error, list }) { state.isLoading = false; diff --git a/app/assets/javascripts/feature_flags/store/new/actions.js b/app/assets/javascripts/feature_flags/store/new/actions.js index e21c128cd39..6d595603819 100644 --- a/app/assets/javascripts/feature_flags/store/new/actions.js +++ b/app/assets/javascripts/feature_flags/store/new/actions.js @@ -27,7 +27,7 @@ export const createFeatureFlag = ({ state, dispatch }, params) => { dispatch('receiveCreateFeatureFlagSuccess'); visitUrl(state.path); }) - .catch(error => dispatch('receiveCreateFeatureFlagError', error.response.data)); + .catch((error) => dispatch('receiveCreateFeatureFlagError', error.response.data)); }; export const requestCreateFeatureFlag = ({ commit }) => commit(types.REQUEST_CREATE_FEATURE_FLAG); diff --git a/app/assets/javascripts/feature_flags/store/new/index.js b/app/assets/javascripts/feature_flags/store/new/index.js index 81edc791924..65ea61c3025 100644 --- a/app/assets/javascripts/feature_flags/store/new/index.js +++ b/app/assets/javascripts/feature_flags/store/new/index.js @@ -4,7 +4,7 @@ import state from './state'; import * as actions from './actions'; import mutations from './mutations'; -export default data => +export default (data) => new Vuex.Store({ actions, mutations, |