debian-mirror-gitlab/app/assets/javascripts/members/index.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { GlToast } from '@gitlab/ui';
2020-11-24 15:15:51 +05:30
import Vue from 'vue';
import Vuex from 'vuex';
2021-06-08 01:23:25 +05:30
import { parseDataAttributes } from '~/members/utils';
2022-08-13 15:12:31 +05:30
import { MEMBER_TYPES } from 'ee_else_ce/members/constants';
2021-09-04 01:27:46 +05:30
import MembersTabs from './components/members_tabs.vue';
2021-03-11 19:13:27 +05:30
import membersStore from './store';
2020-11-24 15:15:51 +05:30
2021-09-04 01:27:46 +05:30
export const initMembersApp = (el, options) => {
2020-11-24 15:15:51 +05:30
if (!el) {
return () => {};
}
Vue.use(Vuex);
2021-01-03 14:25:43 +05:30
Vue.use(GlToast);
2020-11-24 15:15:51 +05:30
2021-10-27 15:23:28 +05:30
const {
sourceId,
canManageMembers,
2023-01-13 00:05:48 +05:30
canManageAccessRequests,
2021-10-27 15:23:28 +05:30
canExportMembers,
2022-05-07 20:08:51 +05:30
canFilterByEnterprise,
2021-10-27 15:23:28 +05:30
exportCsvPath,
...vuexStoreAttributes
} = parseDataAttributes(el);
2021-04-29 21:17:54 +05:30
2021-09-04 01:27:46 +05:30
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,
2021-04-29 21:17:54 +05:30
[namespace]: membersStore({
2021-09-04 01:27:46 +05:30
...vuexStoreAttributes[namespace],
2021-04-29 21:17:54 +05:30
tableFields,
tableAttrs,
tableSortableFields,
requestFormatter,
filteredSearchBar,
}),
2021-09-04 01:27:46 +05:30
};
}, {});
const store = new Vuex.Store({ modules });
2020-11-24 15:15:51 +05:30
return new Vue({
el,
2021-09-04 01:27:46 +05:30
components: { MembersTabs },
2020-11-24 15:15:51 +05:30
store,
2021-04-29 21:17:54 +05:30
provide: {
currentUserId: gon.current_user_id || null,
sourceId,
canManageMembers,
2023-01-13 00:05:48 +05:30
canManageAccessRequests,
2022-05-07 20:08:51 +05:30
canFilterByEnterprise,
2021-10-27 15:23:28 +05:30
canExportMembers,
exportCsvPath,
2021-04-29 21:17:54 +05:30
},
2021-09-04 01:27:46 +05:30
render: (createElement) => createElement('members-tabs'),
2020-11-24 15:15:51 +05:30
});
};