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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
<script>
import { GlAlert, GlLink, GlSprintf, 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.'),
},
includesText: __(
'CI configuration validated, including all configuration added with the %{codeStart}includes%{codeEnd} keyword. %{link}',
),
warningTitle: __('The form contains the following warning:'),
fields: [
{
key: 'parameter',
label: __('Parameter'),
thClass: thBorderColor,
},
{
key: 'value',
label: __('Value'),
thClass: thBorderColor,
},
],
components: {
GlAlert,
GlLink,
GlSprintf,
GlTable,
CiLintWarnings,
CiLintResultsValue,
CiLintResultsParam,
},
props: {
valid: {
type: Boolean,
required: true,
},
jobs: {
type: Array,
required: false,
default: () => [],
},
errors: {
type: Array,
required: false,
default: () => [],
},
warnings: {
type: Array,
required: false,
default: () => [],
},
dryRun: {
type: Boolean,
required: false,
default: false,
},
lintHelpPagePath: {
type: String,
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>
<gl-alert
class="gl-mb-5"
:variant="status.variant"
:title="__('Status:')"
:dismissible="false"
data-testid="ci-lint-status"
>{{ status.text }}
<gl-sprintf :message="$options.includesText">
<template #code="{ content }">
<code>
{{ content }}
</code>
</template>
<template #link>
<gl-link :href="lintHelpPagePath" target="_blank">
{{ __('More information') }}
</gl-link>
</template>
</gl-sprintf>
</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>
|