1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import { parseBoolean } from '~/lib/utils/common_utils';
import { apolloProvider } from '~/packages_and_registries/package_registry/graphql/index';
import PackageRegistry from '~/packages_and_registries/package_registry/pages/index.vue';
import RegistryBreadcrumb from '~/packages_and_registries/shared/components/registry_breadcrumb.vue';
import { injectVueAppBreadcrumbs } from '~/lib/utils/breadcrumbs';
import createRouter from './router';
Vue.use(Translate);
export default () => {
const el = document.getElementById('js-vue-packages-list');
const {
endpoint,
resourceId,
fullPath,
pageType,
emptyListIllustration,
npmInstanceUrl,
projectListUrl,
groupListUrl,
settingsPath,
canDeletePackages,
} = el.dataset;
const isGroupPage = pageType === 'groups';
// This is a mini state to help the breadcrumb have the correct name in the details page
const breadCrumbState = Vue.observable({
name: '',
updateName(value) {
this.name = value;
},
});
const router = createRouter(endpoint, breadCrumbState);
const attachMainComponent = () =>
new Vue({
el,
name: 'PackageRegistry',
router,
apolloProvider,
provide: {
resourceId,
fullPath,
emptyListIllustration,
isGroupPage,
npmInstanceUrl,
projectListUrl,
groupListUrl,
breadCrumbState,
settingsPath,
canDeletePackages: parseBoolean(canDeletePackages),
},
render(createElement) {
return createElement(PackageRegistry);
},
});
return {
attachBreadcrumb: () => injectVueAppBreadcrumbs(router, RegistryBreadcrumb, apolloProvider),
attachMainComponent,
};
};
|