Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ci_lint_results.vue « components « ci_lint « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 28b2a028b29b899e654b5d0518095eff4c0e8305 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<script>
import { GlAlert, GlTable } from '@gitlab/ui';
import CiLintWarnings from './ci_lint_warnings.vue';
import CiLintResultsValue from './ci_lint_results_value.vue';
import CiLintResultsParam from './ci_lint_results_param.vue';
import { __ } from '~/locale';

const thBorderColor = 'gl-border-gray-100!';

export default {
  correct: { variant: 'success', text: __('syntax is correct') },
  incorrect: { variant: 'danger', text: __('syntax is incorrect') },
  warningTitle: __('The form contains the following warning:'),
  fields: [
    {
      key: 'parameter',
      label: __('Parameter'),
      thClass: thBorderColor,
    },
    {
      key: 'value',
      label: __('Value'),
      thClass: thBorderColor,
    },
  ],
  components: {
    GlAlert,
    GlTable,
    CiLintWarnings,
    CiLintResultsValue,
    CiLintResultsParam,
  },
  props: {
    valid: {
      type: Boolean,
      required: true,
    },
    jobs: {
      type: Array,
      required: true,
    },
    errors: {
      type: Array,
      required: true,
    },
    warnings: {
      type: Array,
      required: true,
    },
    dryRun: {
      type: Boolean,
      required: true,
    },
  },
  data() {
    return {
      isWarningDismissed: false,
    };
  },
  computed: {
    status() {
      return this.valid ? this.$options.correct : this.$options.incorrect;
    },
    shouldShowTable() {
      return this.errors.length === 0;
    },
    shouldShowError() {
      return this.errors.length > 0;
    },
    shouldShowWarning() {
      return this.warnings.length > 0 && !this.isWarningDismissed;
    },
  },
};
</script>

<template>
  <div class="col-sm-12 gl-mt-5">
    <gl-alert
      class="gl-mb-5"
      :variant="status.variant"
      :title="__('Status:')"
      :dismissible="false"
      data-testid="ci-lint-status"
      >{{ status.text }}</gl-alert
    >

    <pre
      v-if="shouldShowError"
      class="gl-mb-5"
      data-testid="ci-lint-errors"
    ><div v-for="error in errors" :key="error">{{ error }}</div></pre>

    <ci-lint-warnings
      v-if="shouldShowWarning"
      :warnings="warnings"
      data-testid="ci-lint-warnings"
      @dismiss="isWarningDismissed = true"
    />

    <gl-table
      v-if="shouldShowTable"
      :items="jobs"
      :fields="$options.fields"
      bordered
      data-testid="ci-lint-table"
    >
      <template #cell(parameter)="{ item }">
        <ci-lint-results-param :stage="item.stage" :job-name="item.name" />
      </template>
      <template #cell(value)="{ item }">
        <ci-lint-results-value :item="item" :dry-run="dryRun" />
      </template>
    </gl-table>
  </div>
</template>