2022-09-07 05:12:12 -04:00
|
|
|
import Vue from 'vue';
|
2022-09-12 20:10:14 -04:00
|
|
|
import VueRouter from 'vue-router';
|
2022-09-07 05:12:12 -04:00
|
|
|
import { GlToast } from '@gitlab/ui';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import GroupFolder from './components/group_folder.vue';
|
|
|
|
import GroupItem from './components/group_item.vue';
|
|
|
|
import {
|
|
|
|
ACTIVE_TAB_SUBGROUPS_AND_PROJECTS,
|
|
|
|
ACTIVE_TAB_SHARED,
|
|
|
|
ACTIVE_TAB_ARCHIVED,
|
|
|
|
} from './constants';
|
|
|
|
import OverviewTabs from './components/overview_tabs.vue';
|
|
|
|
|
2022-09-12 20:10:14 -04:00
|
|
|
export const createRouter = () => {
|
|
|
|
const routes = [
|
|
|
|
{ name: ACTIVE_TAB_SHARED, path: '/groups/:group*/-/shared' },
|
|
|
|
{ name: ACTIVE_TAB_ARCHIVED, path: '/groups/:group*/-/archived' },
|
|
|
|
{ name: ACTIVE_TAB_SUBGROUPS_AND_PROJECTS, path: '/:group*' },
|
|
|
|
];
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
|
routes,
|
|
|
|
mode: 'history',
|
|
|
|
base: '/',
|
|
|
|
});
|
|
|
|
|
|
|
|
return router;
|
|
|
|
};
|
|
|
|
|
2022-09-07 05:12:12 -04:00
|
|
|
export const initGroupOverviewTabs = () => {
|
|
|
|
const el = document.getElementById('js-group-overview-tabs');
|
|
|
|
|
|
|
|
if (!el) return false;
|
|
|
|
|
|
|
|
Vue.component('GroupFolder', GroupFolder);
|
|
|
|
Vue.component('GroupItem', GroupItem);
|
|
|
|
Vue.use(GlToast);
|
2022-09-12 20:10:14 -04:00
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
|
|
|
const router = createRouter();
|
2022-09-07 05:12:12 -04:00
|
|
|
|
|
|
|
const {
|
|
|
|
newSubgroupPath,
|
|
|
|
newProjectPath,
|
|
|
|
newSubgroupIllustration,
|
|
|
|
newProjectIllustration,
|
|
|
|
emptySubgroupIllustration,
|
|
|
|
canCreateSubgroups,
|
|
|
|
canCreateProjects,
|
|
|
|
currentGroupVisibility,
|
|
|
|
subgroupsAndProjectsEndpoint,
|
|
|
|
sharedProjectsEndpoint,
|
|
|
|
archivedProjectsEndpoint,
|
2022-10-04 17:08:34 -04:00
|
|
|
initialSort,
|
2022-09-07 05:12:12 -04:00
|
|
|
} = el.dataset;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2022-09-12 20:10:14 -04:00
|
|
|
router,
|
2022-09-07 05:12:12 -04:00
|
|
|
provide: {
|
|
|
|
newSubgroupPath,
|
|
|
|
newProjectPath,
|
|
|
|
newSubgroupIllustration,
|
|
|
|
newProjectIllustration,
|
|
|
|
emptySubgroupIllustration,
|
|
|
|
canCreateSubgroups: parseBoolean(canCreateSubgroups),
|
|
|
|
canCreateProjects: parseBoolean(canCreateProjects),
|
|
|
|
currentGroupVisibility,
|
|
|
|
endpoints: {
|
|
|
|
[ACTIVE_TAB_SUBGROUPS_AND_PROJECTS]: subgroupsAndProjectsEndpoint,
|
|
|
|
[ACTIVE_TAB_SHARED]: sharedProjectsEndpoint,
|
|
|
|
[ACTIVE_TAB_ARCHIVED]: archivedProjectsEndpoint,
|
|
|
|
},
|
2022-10-04 17:08:34 -04:00
|
|
|
initialSort,
|
2022-09-07 05:12:12 -04:00
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(OverviewTabs);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|