summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipeline_wizard/pipeline_wizard.vue
blob: 939702fd1b539662b6e658c70de63ad66f89c8a7 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<script>
import { parseDocument } from 'yaml';
import WizardWrapper from './components/wrapper.vue';

export default {
  name: 'PipelineWizard',
  components: {
    WizardWrapper,
  },
  props: {
    template: {
      type: String,
      required: true,
    },
    projectPath: {
      type: String,
      required: true,
    },
    defaultBranch: {
      type: String,
      required: true,
    },
    defaultFilename: {
      type: String,
      required: false,
      default: '.gitlab-ci.yml',
    },
  },
  computed: {
    parsedTemplate() {
      return this.template ? parseDocument(this.template) : null;
    },
    title() {
      return this.parsedTemplate?.get('title');
    },
    description() {
      return this.parsedTemplate?.get('description');
    },
    filename() {
      return this.parsedTemplate?.get('filename') || this.defaultFilename;
    },
    steps() {
      return this.parsedTemplate?.get('steps');
    },
  },
};
</script>

<template>
  <div>
    <div class="gl-my-8">
      <h2 class="gl-mb-4" data-testid="title">{{ title }}</h2>
      <p class="text-tertiary gl-font-lg gl-max-w-80" data-testid="description">
        {{ description }}
      </p>
    </div>
    <wizard-wrapper
      v-if="steps"
      :default-branch="defaultBranch"
      :filename="filename"
      :project-path="projectPath"
      :steps="steps"
      @done="$emit('done')"
    />
  </div>
</template>