2020-10-24 23:57:45 +05:30
|
|
|
import Vue from 'vue';
|
2022-11-25 23:54:43 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2022-10-11 01:57:18 +05:30
|
|
|
import LegacyPipelineNewForm from './components/legacy_pipeline_new_form.vue';
|
2020-10-24 23:57:45 +05:30
|
|
|
import PipelineNewForm from './components/pipeline_new_form.vue';
|
2022-11-25 23:54:43 +05:30
|
|
|
import { resolvers } from './graphql/resolvers';
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
const mountLegacyPipelineNewForm = (el) => {
|
2020-10-24 23:57:45 +05:30
|
|
|
const {
|
2021-04-17 20:07:23 +05:30
|
|
|
// provide/inject
|
|
|
|
projectRefsEndpoint,
|
|
|
|
|
|
|
|
// props
|
2021-01-03 14:25:43 +05:30
|
|
|
configVariablesPath,
|
2021-02-22 17:27:13 +05:30
|
|
|
defaultBranch,
|
2022-10-11 01:57:18 +05:30
|
|
|
fileParam,
|
|
|
|
maxWarnings,
|
|
|
|
pipelinesPath,
|
|
|
|
projectId,
|
2020-10-24 23:57:45 +05:30
|
|
|
refParam,
|
2022-10-11 01:57:18 +05:30
|
|
|
settingsLink,
|
2020-10-24 23:57:45 +05:30
|
|
|
varParam,
|
2022-10-11 01:57:18 +05:30
|
|
|
} = el.dataset;
|
|
|
|
|
|
|
|
const variableParams = JSON.parse(varParam);
|
|
|
|
const fileParams = JSON.parse(fileParam);
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
provide: {
|
|
|
|
projectRefsEndpoint,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(LegacyPipelineNewForm, {
|
|
|
|
props: {
|
|
|
|
configVariablesPath,
|
|
|
|
defaultBranch,
|
|
|
|
fileParams,
|
|
|
|
maxWarnings: Number(maxWarnings),
|
|
|
|
pipelinesPath,
|
|
|
|
projectId,
|
|
|
|
refParam,
|
|
|
|
settingsLink,
|
|
|
|
variableParams,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const mountPipelineNewForm = (el) => {
|
|
|
|
const {
|
|
|
|
// provide/inject
|
|
|
|
projectRefsEndpoint,
|
|
|
|
|
|
|
|
// props
|
|
|
|
defaultBranch,
|
2020-10-24 23:57:45 +05:30
|
|
|
fileParam,
|
2020-11-24 15:15:51 +05:30
|
|
|
maxWarnings,
|
2022-10-11 01:57:18 +05:30
|
|
|
pipelinesPath,
|
|
|
|
projectId,
|
2022-11-25 23:54:43 +05:30
|
|
|
projectPath,
|
2022-10-11 01:57:18 +05:30
|
|
|
refParam,
|
|
|
|
settingsLink,
|
|
|
|
varParam,
|
2022-07-16 23:28:13 +05:30
|
|
|
} = el.dataset;
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
const variableParams = JSON.parse(varParam);
|
|
|
|
const fileParams = JSON.parse(fileParam);
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(resolvers),
|
|
|
|
});
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
return new Vue({
|
|
|
|
el,
|
2022-11-25 23:54:43 +05:30
|
|
|
apolloProvider,
|
2021-04-17 20:07:23 +05:30
|
|
|
provide: {
|
|
|
|
projectRefsEndpoint,
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement(PipelineNewForm, {
|
|
|
|
props: {
|
2021-02-22 17:27:13 +05:30
|
|
|
defaultBranch,
|
2020-10-24 23:57:45 +05:30
|
|
|
fileParams,
|
2020-11-24 15:15:51 +05:30
|
|
|
maxWarnings: Number(maxWarnings),
|
2022-10-11 01:57:18 +05:30
|
|
|
pipelinesPath,
|
|
|
|
projectId,
|
2022-11-25 23:54:43 +05:30
|
|
|
projectPath,
|
2022-10-11 01:57:18 +05:30
|
|
|
refParam,
|
|
|
|
settingsLink,
|
|
|
|
variableParams,
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2022-10-11 01:57:18 +05:30
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const el = document.getElementById('js-new-pipeline');
|
|
|
|
|
|
|
|
if (gon.features?.runPipelineGraphql) {
|
|
|
|
mountPipelineNewForm(el);
|
|
|
|
} else {
|
|
|
|
mountLegacyPipelineNewForm(el);
|
|
|
|
}
|
|
|
|
};
|