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
|
<script>
import { GlIcon, GlLink, GlLoadingIcon } from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale';
import getAppStatus from '~/ci/pipeline_editor/graphql/queries/client/app_status.query.graphql';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue';
import {
EDITOR_APP_STATUS_EMPTY,
EDITOR_APP_STATUS_LINT_UNAVAILABLE,
EDITOR_APP_STATUS_LOADING,
EDITOR_APP_STATUS_VALID,
} from '../../constants';
export const i18n = {
empty: __(
"We'll continuously validate your pipeline configuration. The validation results will appear here.",
),
learnMore: __('Learn more'),
loading: s__('Pipelines|Validating GitLab CI configuration…'),
invalid: s__('Pipelines|This GitLab CI configuration is invalid.'),
invalidWithReason: s__('Pipelines|This GitLab CI configuration is invalid: %{reason}.'),
unavailableValidation: s__('Pipelines|Configuration validation currently not available.'),
valid: s__('Pipelines|Pipeline syntax is correct.'),
};
export default {
i18n,
components: {
GlIcon,
GlLink,
GlLoadingIcon,
TooltipOnTruncate,
},
inject: {
lintUnavailableHelpPagePath: {
default: '',
},
ymlHelpPagePath: {
default: '',
},
},
props: {
ciConfig: {
type: Object,
required: false,
default: () => ({}),
},
},
apollo: {
appStatus: {
query: getAppStatus,
update(data) {
return data.app.status;
},
},
},
computed: {
helpPath() {
return this.isLintUnavailable ? this.lintUnavailableHelpPagePath : this.ymlHelpPagePath;
},
isEmpty() {
return this.appStatus === EDITOR_APP_STATUS_EMPTY;
},
isLintUnavailable() {
return this.appStatus === EDITOR_APP_STATUS_LINT_UNAVAILABLE;
},
isLoading() {
return this.appStatus === EDITOR_APP_STATUS_LOADING;
},
isValid() {
return this.appStatus === EDITOR_APP_STATUS_VALID;
},
icon() {
switch (this.appStatus) {
case EDITOR_APP_STATUS_EMPTY:
return 'check';
case EDITOR_APP_STATUS_LINT_UNAVAILABLE:
return 'time-out';
case EDITOR_APP_STATUS_VALID:
return 'check';
default:
return 'warning-solid';
}
},
message() {
const [reason] = this.ciConfig?.errors || [];
switch (this.appStatus) {
case EDITOR_APP_STATUS_EMPTY:
return this.$options.i18n.empty;
case EDITOR_APP_STATUS_LINT_UNAVAILABLE:
return this.$options.i18n.unavailableValidation;
case EDITOR_APP_STATUS_VALID:
return this.$options.i18n.valid;
default:
// Only display first error as a reason
return this.ciConfig?.errors?.length > 0
? sprintf(this.$options.i18n.invalidWithReason, { reason }, false)
: this.$options.i18n.invalid;
}
},
},
};
</script>
<template>
<div>
<template v-if="isLoading">
<gl-loading-icon size="sm" inline />
{{ $options.i18n.loading }}
</template>
<span v-else class="gl-display-inline-flex gl-white-space-nowrap gl-max-w-full">
<tooltip-on-truncate :title="message" class="gl-text-truncate">
<gl-icon :name="icon" />
<span data-qa-selector="validation_message_content" data-testid="validationMsg">
{{ message }}
</span>
</tooltip-on-truncate>
<span v-if="!isEmpty" class="gl-flex-shrink-0 gl-pl-2">
<gl-link data-testid="learnMoreLink" :href="helpPath">
{{ $options.i18n.learnMore }}
</gl-link>
</span>
</span>
</div>
</template>
|