From a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Jun 2021 18:25:58 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-0-stable-ee --- .../feature_flags/components/empty_state.vue | 95 ++++++++ .../components/environments_dropdown.vue | 6 +- .../feature_flags/components/feature_flags.vue | 246 +++++++-------------- .../feature_flags/components/feature_flags_tab.vue | 106 --------- .../components/new_environments_dropdown.vue | 6 +- .../feature_flags/components/user_lists_table.vue | 125 ----------- app/assets/javascripts/feature_flags/constants.js | 3 - app/assets/javascripts/feature_flags/index.js | 4 +- .../feature_flags/store/edit/actions.js | 6 +- .../feature_flags/store/index/actions.js | 34 --- .../feature_flags/store/index/mutation_types.js | 7 - .../feature_flags/store/index/mutations.js | 54 +---- .../javascripts/feature_flags/store/index/state.js | 9 +- 13 files changed, 203 insertions(+), 498 deletions(-) create mode 100644 app/assets/javascripts/feature_flags/components/empty_state.vue delete mode 100644 app/assets/javascripts/feature_flags/components/feature_flags_tab.vue delete mode 100644 app/assets/javascripts/feature_flags/components/user_lists_table.vue (limited to 'app/assets/javascripts/feature_flags') diff --git a/app/assets/javascripts/feature_flags/components/empty_state.vue b/app/assets/javascripts/feature_flags/components/empty_state.vue new file mode 100644 index 00000000000..a6de4972bb1 --- /dev/null +++ b/app/assets/javascripts/feature_flags/components/empty_state.vue @@ -0,0 +1,95 @@ + + diff --git a/app/assets/javascripts/feature_flags/components/environments_dropdown.vue b/app/assets/javascripts/feature_flags/components/environments_dropdown.vue index 7f316d20f9c..70b60b4b113 100644 --- a/app/assets/javascripts/feature_flags/components/environments_dropdown.vue +++ b/app/assets/javascripts/feature_flags/components/environments_dropdown.vue @@ -1,7 +1,7 @@ - diff --git a/app/assets/javascripts/feature_flags/components/new_environments_dropdown.vue b/app/assets/javascripts/feature_flags/components/new_environments_dropdown.vue index efe4ff71a9e..c59e3178b09 100644 --- a/app/assets/javascripts/feature_flags/components/new_environments_dropdown.vue +++ b/app/assets/javascripts/feature_flags/components/new_environments_dropdown.vue @@ -8,7 +8,7 @@ import { GlSearchBoxByType, } from '@gitlab/ui'; import { debounce } from 'lodash'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { __, sprintf } from '~/locale'; @@ -52,7 +52,9 @@ export default { this.results = data || []; }) .catch(() => { - createFlash(__('Something went wrong on our end. Please try again.')); + createFlash({ + message: __('Something went wrong on our end. Please try again.'), + }); }) .finally(() => { this.isLoading = false; diff --git a/app/assets/javascripts/feature_flags/components/user_lists_table.vue b/app/assets/javascripts/feature_flags/components/user_lists_table.vue deleted file mode 100644 index 765f59228a6..00000000000 --- a/app/assets/javascripts/feature_flags/components/user_lists_table.vue +++ /dev/null @@ -1,125 +0,0 @@ - - diff --git a/app/assets/javascripts/feature_flags/constants.js b/app/assets/javascripts/feature_flags/constants.js index 658984456a5..f697f203cf5 100644 --- a/app/assets/javascripts/feature_flags/constants.js +++ b/app/assets/javascripts/feature_flags/constants.js @@ -21,9 +21,6 @@ export const fetchUserIdParams = property(['parameters', 'userIds']); export const NEW_VERSION_FLAG = 'new_version_flag'; export const LEGACY_FLAG = 'legacy_flag'; -export const FEATURE_FLAG_SCOPE = 'featureFlags'; -export const USER_LIST_SCOPE = 'userLists'; - export const EMPTY_PARAMETERS = { parameters: {}, userListId: undefined }; export const STRATEGY_SELECTIONS = [ diff --git a/app/assets/javascripts/feature_flags/index.js b/app/assets/javascripts/feature_flags/index.js index d2371a2aa8b..5c0d9cb8624 100644 --- a/app/assets/javascripts/feature_flags/index.js +++ b/app/assets/javascripts/feature_flags/index.js @@ -22,7 +22,7 @@ export default () => { unleashApiUrl, canUserAdminFeatureFlag, newFeatureFlagPath, - newUserListPath, + userListPath, featureFlagsLimitExceeded, featureFlagsLimit, } = el.dataset; @@ -40,9 +40,9 @@ export default () => { csrfToken: csrf.token, canUserConfigure: canUserAdminFeatureFlag !== undefined, newFeatureFlagPath, - newUserListPath, featureFlagsLimitExceeded: featureFlagsLimitExceeded !== undefined, featureFlagsLimit, + userListPath, }, render(createElement) { return createElement(FeatureFlagsComponent); diff --git a/app/assets/javascripts/feature_flags/store/edit/actions.js b/app/assets/javascripts/feature_flags/store/edit/actions.js index 72b17333832..54c7e8c4453 100644 --- a/app/assets/javascripts/feature_flags/store/edit/actions.js +++ b/app/assets/javascripts/feature_flags/store/edit/actions.js @@ -1,4 +1,4 @@ -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { visitUrl } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; @@ -55,7 +55,9 @@ export const receiveFeatureFlagSuccess = ({ commit }, response) => commit(types.RECEIVE_FEATURE_FLAG_SUCCESS, response); export const receiveFeatureFlagError = ({ commit }) => { commit(types.RECEIVE_FEATURE_FLAG_ERROR); - createFlash(__('Something went wrong on our end. Please try again!')); + createFlash({ + message: __('Something went wrong on our end. Please try again!'), + }); }; export const toggleActive = ({ commit }, active) => commit(types.TOGGLE_ACTIVE, active); diff --git a/app/assets/javascripts/feature_flags/store/index/actions.js b/app/assets/javascripts/feature_flags/store/index/actions.js index 4372c280f39..751f627ca48 100644 --- a/app/assets/javascripts/feature_flags/store/index/actions.js +++ b/app/assets/javascripts/feature_flags/store/index/actions.js @@ -1,4 +1,3 @@ -import Api from '~/api'; import axios from '~/lib/utils/axios_utils'; import * as types from './mutation_types'; @@ -26,19 +25,6 @@ export const receiveFeatureFlagsSuccess = ({ commit }, response) => commit(types.RECEIVE_FEATURE_FLAGS_SUCCESS, response); export const receiveFeatureFlagsError = ({ commit }) => commit(types.RECEIVE_FEATURE_FLAGS_ERROR); -export const fetchUserLists = ({ state, dispatch }) => { - dispatch('requestUserLists'); - - return Api.fetchFeatureFlagUserLists(state.projectId, state.options.page) - .then(({ data, headers }) => dispatch('receiveUserListsSuccess', { data, headers })) - .catch(() => dispatch('receiveUserListsError')); -}; - -export const requestUserLists = ({ commit }) => commit(types.REQUEST_USER_LISTS); -export const receiveUserListsSuccess = ({ commit }, response) => - commit(types.RECEIVE_USER_LISTS_SUCCESS, response); -export const receiveUserListsError = ({ commit }) => commit(types.RECEIVE_USER_LISTS_ERROR); - export const toggleFeatureFlag = ({ dispatch }, flag) => { dispatch('updateFeatureFlag', flag); @@ -57,26 +43,6 @@ export const receiveUpdateFeatureFlagSuccess = ({ commit }, data) => export const receiveUpdateFeatureFlagError = ({ commit }, id) => commit(types.RECEIVE_UPDATE_FEATURE_FLAG_ERROR, id); -export const deleteUserList = ({ state, dispatch }, list) => { - dispatch('requestDeleteUserList', list); - - return Api.deleteFeatureFlagUserList(state.projectId, list.iid) - .then(() => dispatch('fetchUserLists')) - .catch((error) => - dispatch('receiveDeleteUserListError', { - list, - error: error?.response?.data ?? error, - }), - ); -}; - -export const requestDeleteUserList = ({ commit }, list) => - commit(types.REQUEST_DELETE_USER_LIST, list); - -export const receiveDeleteUserListError = ({ commit }, { error, list }) => { - commit(types.RECEIVE_DELETE_USER_LIST_ERROR, { error, list }); -}; - export const rotateInstanceId = ({ state, dispatch }) => { dispatch('requestRotateInstanceId'); diff --git a/app/assets/javascripts/feature_flags/store/index/mutation_types.js b/app/assets/javascripts/feature_flags/store/index/mutation_types.js index 189c763782e..ed05294a6f3 100644 --- a/app/assets/javascripts/feature_flags/store/index/mutation_types.js +++ b/app/assets/javascripts/feature_flags/store/index/mutation_types.js @@ -4,13 +4,6 @@ export const REQUEST_FEATURE_FLAGS = 'REQUEST_FEATURE_FLAGS'; export const RECEIVE_FEATURE_FLAGS_SUCCESS = 'RECEIVE_FEATURE_FLAGS_SUCCESS'; export const RECEIVE_FEATURE_FLAGS_ERROR = 'RECEIVE_FEATURE_FLAGS_ERROR'; -export const REQUEST_USER_LISTS = 'REQUEST_USER_LISTS'; -export const RECEIVE_USER_LISTS_SUCCESS = 'RECEIVE_USER_LISTS_SUCCESS'; -export const RECEIVE_USER_LISTS_ERROR = 'RECEIVE_USER_LISTS_ERROR'; - -export const REQUEST_DELETE_USER_LIST = 'REQUEST_DELETE_USER_LIST'; -export const RECEIVE_DELETE_USER_LIST_ERROR = 'RECEIVE_DELETE_USER_LIST_ERROR'; - export const UPDATE_FEATURE_FLAG = 'UPDATE_FEATURE_FLAG'; export const RECEIVE_UPDATE_FEATURE_FLAG_SUCCESS = 'RECEIVE_UPDATE_FEATURE_FLAG_SUCCESS'; export const RECEIVE_UPDATE_FEATURE_FLAG_ERROR = 'RECEIVE_UPDATE_FEATURE_FLAG_ERROR'; diff --git a/app/assets/javascripts/feature_flags/store/index/mutations.js b/app/assets/javascripts/feature_flags/store/index/mutations.js index 25eb7da1c72..54e48a4b80c 100644 --- a/app/assets/javascripts/feature_flags/store/index/mutations.js +++ b/app/assets/javascripts/feature_flags/store/index/mutations.js @@ -1,17 +1,16 @@ import Vue from 'vue'; import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils'; -import { FEATURE_FLAG_SCOPE, USER_LIST_SCOPE } from '../../constants'; import { mapToScopesViewModel } from '../helpers'; import * as types from './mutation_types'; const mapFlag = (flag) => ({ ...flag, scopes: mapToScopesViewModel(flag.scopes || []) }); const updateFlag = (state, flag) => { - const index = state[FEATURE_FLAG_SCOPE].findIndex(({ id }) => id === flag.id); - Vue.set(state[FEATURE_FLAG_SCOPE], index, flag); + const index = state.featureFlags.findIndex(({ id }) => id === flag.id); + Vue.set(state.featureFlags, index, flag); }; -const createPaginationInfo = (state, headers) => { +const createPaginationInfo = (headers) => { let paginationInfo; if (Object.keys(headers).length) { const normalizedHeaders = normalizeHeaders(headers); @@ -32,44 +31,16 @@ export default { [types.RECEIVE_FEATURE_FLAGS_SUCCESS](state, response) { state.isLoading = false; state.hasError = false; - state[FEATURE_FLAG_SCOPE] = (response.data.feature_flags || []).map(mapFlag); + state.featureFlags = (response.data.feature_flags || []).map(mapFlag); - const paginationInfo = createPaginationInfo(state, response.headers); - state.count = { - ...state.count, - [FEATURE_FLAG_SCOPE]: paginationInfo?.total ?? state[FEATURE_FLAG_SCOPE].length, - }; - state.pageInfo = { - ...state.pageInfo, - [FEATURE_FLAG_SCOPE]: paginationInfo, - }; + const paginationInfo = createPaginationInfo(response.headers); + state.count = paginationInfo?.total ?? state.featureFlags.length; + state.pageInfo = paginationInfo; }, [types.RECEIVE_FEATURE_FLAGS_ERROR](state) { state.isLoading = false; state.hasError = true; }, - [types.REQUEST_USER_LISTS](state) { - state.isLoading = true; - }, - [types.RECEIVE_USER_LISTS_SUCCESS](state, response) { - state.isLoading = false; - state.hasError = false; - state[USER_LIST_SCOPE] = response.data || []; - - const paginationInfo = createPaginationInfo(state, response.headers); - state.count = { - ...state.count, - [USER_LIST_SCOPE]: paginationInfo?.total ?? state[USER_LIST_SCOPE].length, - }; - state.pageInfo = { - ...state.pageInfo, - [USER_LIST_SCOPE]: paginationInfo, - }; - }, - [types.RECEIVE_USER_LISTS_ERROR](state) { - state.isLoading = false; - state.hasError = true; - }, [types.REQUEST_ROTATE_INSTANCE_ID](state) { state.isRotating = true; state.hasRotateError = false; @@ -90,18 +61,9 @@ export default { updateFlag(state, mapFlag(data)); }, [types.RECEIVE_UPDATE_FEATURE_FLAG_ERROR](state, i) { - const flag = state[FEATURE_FLAG_SCOPE].find(({ id }) => i === id); + const flag = state.featureFlags.find(({ id }) => i === id); updateFlag(state, { ...flag, active: !flag.active }); }, - [types.REQUEST_DELETE_USER_LIST](state, list) { - state.userLists = state.userLists.filter((l) => l !== list); - }, - [types.RECEIVE_DELETE_USER_LIST_ERROR](state, { error, list }) { - state.isLoading = false; - state.hasError = false; - state.alerts = [].concat(error.message); - state.userLists = state.userLists.concat(list).sort((l1, l2) => l1.iid - l2.iid); - }, [types.RECEIVE_CLEAR_ALERT](state, index) { state.alerts.splice(index, 1); }, diff --git a/app/assets/javascripts/feature_flags/store/index/state.js b/app/assets/javascripts/feature_flags/store/index/state.js index f8439b02639..488da265b28 100644 --- a/app/assets/javascripts/feature_flags/store/index/state.js +++ b/app/assets/javascripts/feature_flags/store/index/state.js @@ -1,11 +1,8 @@ -import { FEATURE_FLAG_SCOPE, USER_LIST_SCOPE } from '../../constants'; - export default ({ endpoint, projectId, unleashApiInstanceId, rotateInstanceIdPath }) => ({ - [FEATURE_FLAG_SCOPE]: [], - [USER_LIST_SCOPE]: [], + featureFlags: [], alerts: [], - count: {}, - pageInfo: { [FEATURE_FLAG_SCOPE]: {}, [USER_LIST_SCOPE]: {} }, + count: 0, + pageInfo: {}, isLoading: true, hasError: false, endpoint, -- cgit v1.2.3