summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipeline_new/index.js
blob: 0b85184ec902e582cfc28e8f4bdd12e38d55e136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Vue from 'vue';
import PipelineNewForm from './components/pipeline_new_form.vue';
import formatRefs from './utils/format_refs';

export default () => {
  const el = document.getElementById('js-new-pipeline');
  const {
    projectId,
    pipelinesPath,
    configVariablesPath,
    defaultBranch,
    refParam,
    varParam,
    fileParam,
    branchRefs,
    tagRefs,
    settingsLink,
    maxWarnings,
  } = el?.dataset;

  const variableParams = JSON.parse(varParam);
  const fileParams = JSON.parse(fileParam);
  const branches = formatRefs(JSON.parse(branchRefs), 'branch');
  const tags = formatRefs(JSON.parse(tagRefs), 'tag');

  return new Vue({
    el,
    render(createElement) {
      return createElement(PipelineNewForm, {
        props: {
          projectId,
          pipelinesPath,
          configVariablesPath,
          defaultBranch,
          refParam,
          variableParams,
          fileParams,
          branches,
          tags,
          settingsLink,
          maxWarnings: Number(maxWarnings),
        },
      });
    },
  });
};