diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-21 15:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-21 15:09:05 +0300 |
commit | cbf0385d17af276030868aa260af02f3f90ee683 (patch) | |
tree | f2953cb7d17d319ee917c67937d79f341c3be3d0 /app/assets/javascripts/groups | |
parent | ea037b91577f1b645267df9e034f6da3e389626c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/groups')
-rw-r--r-- | app/assets/javascripts/groups/members/components/app.vue | 40 | ||||
-rw-r--r-- | app/assets/javascripts/groups/members/constants.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/groups/members/index.js | 43 | ||||
-rw-r--r-- | app/assets/javascripts/groups/members/utils.js | 47 |
4 files changed, 5 insertions, 129 deletions
diff --git a/app/assets/javascripts/groups/members/components/app.vue b/app/assets/javascripts/groups/members/components/app.vue deleted file mode 100644 index 34a2c67fa9f..00000000000 --- a/app/assets/javascripts/groups/members/components/app.vue +++ /dev/null @@ -1,40 +0,0 @@ -<script> -import { mapState, mapMutations } from 'vuex'; -import { GlAlert } from '@gitlab/ui'; -import MembersTable from '~/members/components/table/members_table.vue'; -import FilterSortContainer from '~/members/components/filter_sort/filter_sort_container.vue'; -import { scrollToElement } from '~/lib/utils/common_utils'; -import { HIDE_ERROR } from '~/members/store/mutation_types'; - -export default { - name: 'GroupMembersApp', - components: { MembersTable, FilterSortContainer, GlAlert }, - computed: { - ...mapState(['showError', 'errorMessage']), - }, - watch: { - showError(value) { - if (value) { - this.$nextTick(() => { - scrollToElement(this.$refs.errorAlert.$el); - }); - } - }, - }, - methods: { - ...mapMutations({ - hideError: HIDE_ERROR, - }), - }, -}; -</script> - -<template> - <div> - <gl-alert v-if="showError" ref="errorAlert" variant="danger" @dismiss="hideError">{{ - errorMessage - }}</gl-alert> - <filter-sort-container /> - <members-table /> - </div> -</template> diff --git a/app/assets/javascripts/groups/members/constants.js b/app/assets/javascripts/groups/members/constants.js index 6d71b666d7a..3315712891d 100644 --- a/app/assets/javascripts/groups/members/constants.js +++ b/app/assets/javascripts/groups/members/constants.js @@ -1,5 +1 @@ export const GROUP_MEMBER_BASE_PROPERTY_NAME = 'group_member'; -export const GROUP_MEMBER_ACCESS_LEVEL_PROPERTY_NAME = 'access_level'; - -export const GROUP_LINK_BASE_PROPERTY_NAME = 'group_link'; -export const GROUP_LINK_ACCESS_LEVEL_PROPERTY_NAME = 'group_access'; diff --git a/app/assets/javascripts/groups/members/index.js b/app/assets/javascripts/groups/members/index.js deleted file mode 100644 index 3ec874b8d36..00000000000 --- a/app/assets/javascripts/groups/members/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; -import { GlToast } from '@gitlab/ui'; -import { parseDataAttributes } from 'ee_else_ce/groups/members/utils'; -import App from './components/app.vue'; -import membersStore from '~/members/store'; - -export const initGroupMembersApp = ( - el, - { - tableFields = [], - tableAttrs = {}, - tableSortableFields = [], - requestFormatter = () => {}, - filteredSearchBar = { show: false }, - }, -) => { - if (!el) { - return () => {}; - } - - Vue.use(Vuex); - Vue.use(GlToast); - - const store = new Vuex.Store( - membersStore({ - ...parseDataAttributes(el), - currentUserId: gon.current_user_id || null, - tableFields, - tableAttrs, - tableSortableFields, - requestFormatter, - filteredSearchBar, - }), - ); - - return new Vue({ - el, - components: { App }, - store, - render: (createElement) => createElement('app'), - }); -}; diff --git a/app/assets/javascripts/groups/members/utils.js b/app/assets/javascripts/groups/members/utils.js index 4fcf348b69f..71918bfe9f0 100644 --- a/app/assets/javascripts/groups/members/utils.js +++ b/app/assets/javascripts/groups/members/utils.js @@ -1,45 +1,8 @@ -import { isUndefined } from 'lodash'; -import { convertObjectPropsToCamelCase, parseBoolean } from '~/lib/utils/common_utils'; -import { - GROUP_MEMBER_BASE_PROPERTY_NAME, - GROUP_MEMBER_ACCESS_LEVEL_PROPERTY_NAME, - GROUP_LINK_BASE_PROPERTY_NAME, - GROUP_LINK_ACCESS_LEVEL_PROPERTY_NAME, -} from './constants'; - -export const parseDataAttributes = (el) => { - const { members, groupId, memberPath, canManageMembers } = el.dataset; - - return { - members: convertObjectPropsToCamelCase(JSON.parse(members), { deep: true }), - sourceId: parseInt(groupId, 10), - memberPath, - canManageMembers: parseBoolean(canManageMembers), - }; -}; - -const baseRequestFormatter = (basePropertyName, accessLevelPropertyName) => ({ - accessLevel, - ...otherProperties -}) => { - const accessLevelProperty = !isUndefined(accessLevel) - ? { [accessLevelPropertyName]: accessLevel } - : {}; +import { baseRequestFormatter } from '~/members/utils'; +import { MEMBER_ACCESS_LEVEL_PROPERTY_NAME } from '~/members/constants'; +import { GROUP_MEMBER_BASE_PROPERTY_NAME } from './constants'; - return { - [basePropertyName]: { - ...accessLevelProperty, - ...otherProperties, - }, - }; -}; - -export const memberRequestFormatter = baseRequestFormatter( +export const groupMemberRequestFormatter = baseRequestFormatter( GROUP_MEMBER_BASE_PROPERTY_NAME, - GROUP_MEMBER_ACCESS_LEVEL_PROPERTY_NAME, -); - -export const groupLinkRequestFormatter = baseRequestFormatter( - GROUP_LINK_BASE_PROPERTY_NAME, - GROUP_LINK_ACCESS_LEVEL_PROPERTY_NAME, + MEMBER_ACCESS_LEVEL_PROPERTY_NAME, ); |