summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci_lint/components/ci_lint_results_value.vue
blob: 4929c3206dfaf6bf2efa05444fa48050f216b3b7 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script>
import { isEmpty } from 'lodash';

export default {
  props: {
    item: {
      type: Object,
      required: true,
    },
    dryRun: {
      type: Boolean,
      required: true,
    },
  },
  computed: {
    tagList() {
      return this.item.tagList.join(', ');
    },
    onlyPolicy() {
      return this.item.only ? this.item.only.refs.join(', ') : this.item.only;
    },
    exceptPolicy() {
      return this.item.except ? this.item.except.refs.join(', ') : this.item.except;
    },
    scripts() {
      return {
        beforeScript: {
          show: !isEmpty(this.item.beforeScript),
          content: this.item.beforeScript.join('\n'),
        },
        script: {
          show: !isEmpty(this.item.script),
          content: this.item.script.join('\n'),
        },
        afterScript: {
          show: !isEmpty(this.item.afterScript),
          content: this.item.afterScript.join('\n'),
        },
      };
    },
  },
};
</script>

<template>
  <div>
    <pre v-if="scripts.beforeScript.show" data-testid="ci-lint-before-script">{{
      scripts.beforeScript.content
    }}</pre>
    <pre v-if="scripts.script.show" data-testid="ci-lint-script">{{ scripts.script.content }}</pre>
    <pre v-if="scripts.afterScript.show" data-testid="ci-lint-after-script">{{
      scripts.afterScript.content
    }}</pre>

    <ul class="gl-list-style-none gl-pl-0 gl-mb-0">
      <li>
        <b>{{ __('Tag list:') }}</b>
        {{ tagList }}
      </li>
      <div v-if="!dryRun" data-testid="ci-lint-only-except">
        <li>
          <b>{{ __('Only policy:') }}</b>
          {{ onlyPolicy }}
        </li>
        <li>
          <b>{{ __('Except policy:') }}</b>
          {{ exceptPolicy }}
        </li>
      </div>
      <li>
        <b>{{ __('Environment:') }}</b>
        {{ item.environment }}
      </li>
      <li>
        <b>{{ __('When:') }}</b>
        {{ item.when }}
        <b v-if="item.allowFailure">{{ __('Allowed to fail') }}</b>
      </li>
    </ul>
  </div>
</template>