2021-01-29 00:20:46 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
import typeDefs from './graphql/typedefs.graphql';
|
|
|
|
import { resolvers } from './graphql/resolvers';
|
|
|
|
|
|
|
|
import PipelineEditorApp from './pipeline_editor_app.vue';
|
|
|
|
|
|
|
|
export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
|
|
|
|
const el = document.querySelector(selector);
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const {
|
|
|
|
// props
|
|
|
|
ciConfigPath,
|
|
|
|
commitSha,
|
|
|
|
defaultBranch,
|
|
|
|
newMergeRequestPath,
|
|
|
|
|
|
|
|
// `provide/inject` data
|
|
|
|
lintHelpPagePath,
|
|
|
|
projectFullPath,
|
|
|
|
projectPath,
|
|
|
|
projectNamespace,
|
|
|
|
ymlHelpPagePath,
|
|
|
|
} = el?.dataset;
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(resolvers, { typeDefs }),
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
2021-03-08 18:12:59 +05:30
|
|
|
provide: {
|
|
|
|
lintHelpPagePath,
|
|
|
|
projectFullPath,
|
|
|
|
projectPath,
|
|
|
|
projectNamespace,
|
|
|
|
ymlHelpPagePath,
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
render(h) {
|
|
|
|
return h(PipelineEditorApp, {
|
|
|
|
props: {
|
|
|
|
ciConfigPath,
|
2021-03-08 18:12:59 +05:30
|
|
|
commitSha,
|
2021-02-22 17:27:13 +05:30
|
|
|
defaultBranch,
|
|
|
|
newMergeRequestPath,
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|