diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-20 03:10:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-20 03:10:36 +0300 |
commit | 872ee21bda808e4c8d206eb167fd05366ad2e978 (patch) | |
tree | d8bd516bb4fd3e361c850e4acbdc72d1b08b324f /app/assets/javascripts/members | |
parent | c1ea2a91648ca8bfdb2e17e3ec7e3358da490dc8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/members')
-rw-r--r-- | app/assets/javascripts/members/components/app.vue | 12 | ||||
-rw-r--r-- | app/assets/javascripts/members/index.js | 47 |
2 files changed, 38 insertions, 21 deletions
diff --git a/app/assets/javascripts/members/components/app.vue b/app/assets/javascripts/members/components/app.vue index 585fabdf3ff..a08518584f3 100644 --- a/app/assets/javascripts/members/components/app.vue +++ b/app/assets/javascripts/members/components/app.vue @@ -9,7 +9,17 @@ import MembersTable from './table/members_table.vue'; export default { name: 'MembersApp', components: { MembersTable, FilterSortContainer, GlAlert }, - inject: ['namespace'], + provide() { + return { + namespace: this.namespace, + }; + }, + props: { + namespace: { + type: String, + required: true, + }, + }, computed: { ...mapState({ showError(state) { diff --git a/app/assets/javascripts/members/index.js b/app/assets/javascripts/members/index.js index 6c913af8a0f..2ed0958d1dc 100644 --- a/app/assets/javascripts/members/index.js +++ b/app/assets/javascripts/members/index.js @@ -2,20 +2,11 @@ import { GlToast } from '@gitlab/ui'; import Vue from 'vue'; import Vuex from 'vuex'; import { parseDataAttributes } from '~/members/utils'; -import App from './components/app.vue'; +import MembersTabs from './components/members_tabs.vue'; +import { MEMBER_TYPES } from './constants'; import membersStore from './store'; -export const initMembersApp = ( - el, - { - namespace, - tableFields = [], - tableAttrs = {}, - tableSortableFields = [], - requestFormatter = () => {}, - filteredSearchBar = { show: false }, - }, -) => { +export const initMembersApp = (el, options) => { if (!el) { return () => {}; } @@ -25,29 +16,45 @@ export const initMembersApp = ( const { sourceId, canManageMembers, ...vuexStoreAttributes } = parseDataAttributes(el); - const store = new Vuex.Store({ - modules: { + const modules = Object.keys(MEMBER_TYPES).reduce((accumulator, namespace) => { + const namespacedOptions = options[namespace]; + + if (!namespacedOptions) { + return accumulator; + } + + const { + tableFields = [], + tableAttrs = {}, + tableSortableFields = [], + requestFormatter = () => {}, + filteredSearchBar = { show: false }, + } = namespacedOptions; + + return { + ...accumulator, [namespace]: membersStore({ - ...vuexStoreAttributes, + ...vuexStoreAttributes[namespace], tableFields, tableAttrs, tableSortableFields, requestFormatter, filteredSearchBar, }), - }, - }); + }; + }, {}); + + const store = new Vuex.Store({ modules }); return new Vue({ el, - components: { App }, + components: { MembersTabs }, store, provide: { - namespace, currentUserId: gon.current_user_id || null, sourceId, canManageMembers, }, - render: (createElement) => createElement('app'), + render: (createElement) => createElement('members-tabs'), }); }; |