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
|
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { removeLastSlashInUrlPath } from '~/lib/utils/url_utility';
import csrf from '~/lib/utils/csrf';
import { apolloProvider as createApolloProvider } from './graphql/client';
import App from './pages/app.vue';
import createRouter from './router/index';
Vue.use(VueApollo);
const initKubernetesDashboard = () => {
const el = document.querySelector('.js-kubernetes-app');
if (!el) {
return null;
}
const { basePath, agent, kasTunnelUrl } = el.dataset;
const agentObject = JSON.parse(agent);
const configuration = {
basePath: removeLastSlashInUrlPath(kasTunnelUrl),
headers: {
'GitLab-Agent-Id': agentObject.id,
'Content-Type': 'application/json',
...csrf.headers,
},
credentials: 'include',
};
const router = createRouter({
base: basePath,
});
return new Vue({
el,
name: 'KubernetesDashboardRoot',
router,
apolloProvider: createApolloProvider(),
provide: {
agent: agentObject,
configuration,
},
render: (createElement) => createElement(App),
});
};
export { initKubernetesDashboard };
|