2020-04-01 11:07:45 -04:00
|
|
|
import Vue from 'vue';
|
2020-04-27 11:10:16 -04:00
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
2020-05-04 17:09:41 -04:00
|
|
|
import App from './components/app.vue';
|
|
|
|
import createRouter from './router';
|
2020-05-06 11:09:42 -04:00
|
|
|
import createApolloProvider from './graphql';
|
2020-04-01 11:07:45 -04:00
|
|
|
|
|
|
|
const initStaticSiteEditor = el => {
|
2020-07-27 14:09:54 -04:00
|
|
|
const {
|
|
|
|
isSupportedContent,
|
|
|
|
path: sourcePath,
|
|
|
|
baseUrl,
|
|
|
|
namespace,
|
|
|
|
project,
|
|
|
|
mergeRequestsIllustrationPath,
|
2020-10-02 20:08:46 -04:00
|
|
|
// 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,
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
imageUploadPath,
|
|
|
|
mounts,
|
2020-07-27 14:09:54 -04:00
|
|
|
} = el.dataset;
|
2020-10-02 20:08:46 -04:00
|
|
|
// NOTE that the object in 'mounts' is a JSON string from the data attribute, so it must be parsed into an object.
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
const mountsObject = JSON.parse(mounts);
|
2020-05-06 11:09:42 -04:00
|
|
|
const { current_username: username } = window.gon;
|
|
|
|
const returnUrl = el.dataset.returnUrl || null;
|
2020-05-04 17:09:41 -04:00
|
|
|
const router = createRouter(baseUrl);
|
2020-05-06 11:09:42 -04:00
|
|
|
const apolloProvider = createApolloProvider({
|
|
|
|
isSupportedContent: parseBoolean(isSupportedContent),
|
2020-09-30 05:10:11 -04:00
|
|
|
hasSubmittedChanges: false,
|
2020-05-08 11:09:28 -04:00
|
|
|
project: `${namespace}/${project}`,
|
2020-05-06 11:09:42 -04:00
|
|
|
returnUrl,
|
|
|
|
sourcePath,
|
|
|
|
username,
|
|
|
|
});
|
2020-04-01 11:07:45 -04:00
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2020-05-04 17:09:41 -04:00
|
|
|
router,
|
2020-05-06 11:09:42 -04:00
|
|
|
apolloProvider,
|
2020-04-01 11:07:45 -04:00
|
|
|
components: {
|
2020-05-04 17:09:41 -04:00
|
|
|
App,
|
2020-04-01 11:07:45 -04:00
|
|
|
},
|
|
|
|
render(createElement) {
|
2020-07-27 14:09:54 -04:00
|
|
|
return createElement('app', {
|
|
|
|
props: {
|
|
|
|
mergeRequestsIllustrationPath,
|
|
|
|
},
|
|
|
|
});
|
2020-04-01 11:07:45 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default initStaticSiteEditor;
|