debian-mirror-gitlab/app/assets/javascripts/ci/pipeline_new/index.js
2023-03-17 16:20:25 +05:30

61 lines
1.3 KiB
JavaScript

import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import PipelineNewForm from './components/pipeline_new_form.vue';
import { resolvers } from './graphql/resolvers';
const mountPipelineNewForm = (el) => {
const {
// provide/inject
projectRefsEndpoint,
// props
defaultBranch,
fileParam,
maxWarnings,
pipelinesPath,
projectId,
projectPath,
refParam,
settingsLink,
varParam,
} = el.dataset;
const variableParams = JSON.parse(varParam);
const fileParams = JSON.parse(fileParam);
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(resolvers),
});
return new Vue({
el,
apolloProvider,
provide: {
projectRefsEndpoint,
},
render(createElement) {
return createElement(PipelineNewForm, {
props: {
defaultBranch,
fileParams,
maxWarnings: Number(maxWarnings),
pipelinesPath,
projectId,
projectPath,
refParam,
settingsLink,
variableParams,
},
});
},
});
};
export default () => {
const el = document.getElementById('js-new-pipeline');
mountPipelineNewForm(el);
};