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

35 lines
887 B
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import Vue from 'vue';
2020-05-24 23:13:21 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
import App from './components/app.vue';
import createRouter from './router';
import createApolloProvider from './graphql';
2020-04-22 19:07:51 +05:30
const initStaticSiteEditor = el => {
2020-05-24 23:13:21 +05:30
const { isSupportedContent, path: sourcePath, baseUrl, namespace, project } = el.dataset;
const { current_username: username } = window.gon;
const returnUrl = el.dataset.returnUrl || null;
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
const router = createRouter(baseUrl);
const apolloProvider = createApolloProvider({
isSupportedContent: parseBoolean(isSupportedContent),
project: `${namespace}/${project}`,
returnUrl,
sourcePath,
username,
2020-04-22 19:07:51 +05:30
});
return new Vue({
el,
2020-05-24 23:13:21 +05:30
router,
apolloProvider,
2020-04-22 19:07:51 +05:30
components: {
2020-05-24 23:13:21 +05:30
App,
2020-04-22 19:07:51 +05:30
},
render(createElement) {
2020-05-24 23:13:21 +05:30
return createElement('app');
2020-04-22 19:07:51 +05:30
},
});
};
export default initStaticSiteEditor;