2020-09-18 00:09:39 +00:00
|
|
|
<script>
|
2021-12-03 12:10:23 +00:00
|
|
|
import { GlAlert, GlLink, GlSprintf, GlTableLite } from '@gitlab/ui';
|
2021-02-01 15:08:56 +00:00
|
|
|
import { __ } from '~/locale';
|
2020-10-06 06:08:38 +00:00
|
|
|
import CiLintResultsParam from './ci_lint_results_param.vue';
|
2021-02-14 18:09:20 +00:00
|
|
|
import CiLintResultsValue from './ci_lint_results_value.vue';
|
|
|
|
import CiLintWarnings from './ci_lint_warnings.vue';
|
2020-10-06 06:08:38 +00:00
|
|
|
|
|
|
|
const thBorderColor = 'gl-border-gray-100!';
|
|
|
|
|
2020-09-18 00:09:39 +00:00
|
|
|
export default {
|
2020-11-13 15:09:24 +00:00
|
|
|
correct: {
|
|
|
|
variant: 'success',
|
2020-12-22 15:09:51 +00:00
|
|
|
text: __('Syntax is correct.'),
|
2020-11-13 15:09:24 +00:00
|
|
|
},
|
|
|
|
incorrect: {
|
|
|
|
variant: 'danger',
|
2020-12-22 15:09:51 +00:00
|
|
|
text: __('Syntax is incorrect.'),
|
2020-11-13 15:09:24 +00:00
|
|
|
},
|
|
|
|
includesText: __(
|
2022-06-07 15:08:12 +00:00
|
|
|
'CI configuration validated, including all configuration added with the %{codeStart}include%{codeEnd} keyword. %{link}',
|
2020-11-13 15:09:24 +00:00
|
|
|
),
|
2020-10-06 06:08:38 +00:00
|
|
|
warningTitle: __('The form contains the following warning:'),
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
key: 'parameter',
|
|
|
|
label: __('Parameter'),
|
|
|
|
thClass: thBorderColor,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'value',
|
|
|
|
label: __('Value'),
|
|
|
|
thClass: thBorderColor,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
components: {
|
|
|
|
GlAlert,
|
2020-11-13 15:09:24 +00:00
|
|
|
GlLink,
|
|
|
|
GlSprintf,
|
2021-12-03 12:10:23 +00:00
|
|
|
GlTableLite,
|
2020-10-06 06:08:38 +00:00
|
|
|
CiLintWarnings,
|
|
|
|
CiLintResultsValue,
|
|
|
|
CiLintResultsParam,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
errors: {
|
|
|
|
type: Array,
|
2020-12-22 15:09:51 +00:00
|
|
|
required: false,
|
|
|
|
default: () => [],
|
2020-10-06 06:08:38 +00:00
|
|
|
},
|
|
|
|
dryRun: {
|
|
|
|
type: Boolean,
|
2020-12-22 15:09:51 +00:00
|
|
|
required: false,
|
|
|
|
default: false,
|
2020-10-06 06:08:38 +00:00
|
|
|
},
|
2021-03-22 21:08:59 +00:00
|
|
|
isValid: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
jobs: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2020-11-13 15:09:24 +00:00
|
|
|
lintHelpPagePath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-03-22 21:08:59 +00:00
|
|
|
warnings: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2020-10-06 06:08:38 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isWarningDismissed: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
status() {
|
2021-03-22 21:08:59 +00:00
|
|
|
return this.isValid ? this.$options.correct : this.$options.incorrect;
|
2020-10-06 06:08:38 +00:00
|
|
|
},
|
|
|
|
shouldShowTable() {
|
|
|
|
return this.errors.length === 0;
|
|
|
|
},
|
|
|
|
shouldShowError() {
|
|
|
|
return this.errors.length > 0;
|
|
|
|
},
|
|
|
|
shouldShowWarning() {
|
|
|
|
return this.warnings.length > 0 && !this.isWarningDismissed;
|
|
|
|
},
|
|
|
|
},
|
2020-09-18 00:09:39 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2020-10-06 06:08:38 +00:00
|
|
|
<template>
|
2020-11-27 12:09:14 +00:00
|
|
|
<div>
|
2020-10-06 06:08:38 +00:00
|
|
|
<gl-alert
|
|
|
|
class="gl-mb-5"
|
|
|
|
:variant="status.variant"
|
|
|
|
:title="__('Status:')"
|
|
|
|
:dismissible="false"
|
|
|
|
data-testid="ci-lint-status"
|
2020-11-13 15:09:24 +00:00
|
|
|
>{{ status.text }}
|
|
|
|
<gl-sprintf :message="$options.includesText">
|
2020-12-23 12:10:26 +00:00
|
|
|
<template #code="{ content }">
|
2020-11-13 15:09:24 +00:00
|
|
|
<code>
|
|
|
|
{{ content }}
|
|
|
|
</code>
|
|
|
|
</template>
|
|
|
|
<template #link>
|
|
|
|
<gl-link :href="lintHelpPagePath" target="_blank">
|
|
|
|
{{ __('More information') }}
|
|
|
|
</gl-link>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</gl-alert>
|
2020-10-06 06:08:38 +00:00
|
|
|
|
|
|
|
<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"
|
|
|
|
/>
|
|
|
|
|
2021-12-03 12:10:23 +00:00
|
|
|
<gl-table-lite
|
2020-10-06 06:08:38 +00:00
|
|
|
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>
|
2021-12-03 12:10:23 +00:00
|
|
|
</gl-table-lite>
|
2020-10-06 06:08:38 +00:00
|
|
|
</div>
|
|
|
|
</template>
|