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

57 lines
1.5 KiB
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 createApolloProvider from './graphql';
2021-03-11 19:13:27 +05:30
import createRouter from './router';
2020-04-22 19:07:51 +05:30
2021-03-08 18:12:59 +05:30
const initStaticSiteEditor = (el) => {
2020-10-24 23:57:45 +05:30
const {
isSupportedContent,
path: sourcePath,
baseUrl,
2021-01-29 00:20:46 +05:30
branch,
2020-10-24 23:57:45 +05:30
namespace,
project,
mergeRequestsIllustrationPath,
2021-01-03 14:25:43 +05:30
// NOTE: The following variables are not yet used, but are supported by the config file,
// so we are adding them here as a convenience for future use.
// eslint-disable-next-line no-unused-vars
staticSiteGenerator,
imageUploadPath,
mounts,
2020-10-24 23:57:45 +05:30
} = el.dataset;
2020-05-24 23:13:21 +05:30
const { current_username: username } = window.gon;
const returnUrl = el.dataset.returnUrl || null;
const router = createRouter(baseUrl);
const apolloProvider = createApolloProvider({
isSupportedContent: parseBoolean(isSupportedContent),
2021-01-03 14:25:43 +05:30
hasSubmittedChanges: false,
2020-05-24 23:13:21 +05:30
project: `${namespace}/${project}`,
2021-01-29 00:20:46 +05:30
mounts: JSON.parse(mounts), // NOTE that the object in 'mounts' is a JSON string from the data attribute, so it must be parsed into an object.
branch,
baseUrl,
2020-05-24 23:13:21 +05:30
returnUrl,
sourcePath,
username,
2021-01-29 00:20:46 +05:30
imageUploadPath,
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-10-24 23:57:45 +05:30
return createElement('app', {
props: {
mergeRequestsIllustrationPath,
},
});
2020-04-22 19:07:51 +05:30
},
});
};
export default initStaticSiteEditor;