diff options
Diffstat (limited to 'app/assets/javascripts/ci_lint/components')
5 files changed, 4 insertions, 322 deletions
diff --git a/app/assets/javascripts/ci_lint/components/ci_lint.vue b/app/assets/javascripts/ci_lint/components/ci_lint.vue index def45026b35..731ed2ddd01 100644 --- a/app/assets/javascripts/ci_lint/components/ci_lint.vue +++ b/app/assets/javascripts/ci_lint/components/ci_lint.vue @@ -1,8 +1,8 @@ <script> import { GlButton, GlFormCheckbox, GlIcon, GlLink, GlAlert } from '@gitlab/ui'; import EditorLite from '~/vue_shared/components/editor_lite.vue'; -import CiLintResults from './ci_lint_results.vue'; -import lintCIMutation from '../graphql/mutations/lint_ci.mutation.graphql'; +import CiLintResults from '~/pipeline_editor/components/lint/ci_lint_results.vue'; +import lintCiMutation from '~/pipeline_editor/graphql/mutations/lint_ci.mutation.graphql'; export default { components: { @@ -56,7 +56,7 @@ export default { lintCI: { valid, errors, warnings, jobs }, }, } = await this.$apollo.mutate({ - mutation: lintCIMutation, + mutation: lintCiMutation, variables: { endpoint: this.endpoint, content: this.content, dry: this.dryRun }, }); @@ -119,6 +119,7 @@ export default { <ci-lint-results v-if="showingResults" + class="col-sm-12 gl-mt-5" :valid="valid" :jobs="jobs" :errors="errors" diff --git a/app/assets/javascripts/ci_lint/components/ci_lint_results.vue b/app/assets/javascripts/ci_lint/components/ci_lint_results.vue deleted file mode 100644 index 8b37c94de19..00000000000 --- a/app/assets/javascripts/ci_lint/components/ci_lint_results.vue +++ /dev/null @@ -1,143 +0,0 @@ -<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: true, - }, - errors: { - type: Array, - required: true, - }, - warnings: { - type: Array, - required: true, - }, - dryRun: { - type: Boolean, - required: true, - }, - 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 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-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> diff --git a/app/assets/javascripts/ci_lint/components/ci_lint_results_param.vue b/app/assets/javascripts/ci_lint/components/ci_lint_results_param.vue deleted file mode 100644 index 23808bcb292..00000000000 --- a/app/assets/javascripts/ci_lint/components/ci_lint_results_param.vue +++ /dev/null @@ -1,26 +0,0 @@ -<script> -import { __ } from '~/locale'; -import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; - -export default { - props: { - stage: { - type: String, - required: true, - }, - jobName: { - type: String, - required: true, - }, - }, - computed: { - formatParameter() { - return __(`${capitalizeFirstCharacter(this.stage)} Job - ${this.jobName}`); - }, - }, -}; -</script> - -<template> - <span data-testid="ci-lint-parameter">{{ formatParameter }}</span> -</template> diff --git a/app/assets/javascripts/ci_lint/components/ci_lint_results_value.vue b/app/assets/javascripts/ci_lint/components/ci_lint_results_value.vue deleted file mode 100644 index 4929c3206df..00000000000 --- a/app/assets/javascripts/ci_lint/components/ci_lint_results_value.vue +++ /dev/null @@ -1,81 +0,0 @@ -<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> diff --git a/app/assets/javascripts/ci_lint/components/ci_lint_warnings.vue b/app/assets/javascripts/ci_lint/components/ci_lint_warnings.vue deleted file mode 100644 index ac0332cb0bd..00000000000 --- a/app/assets/javascripts/ci_lint/components/ci_lint_warnings.vue +++ /dev/null @@ -1,69 +0,0 @@ -<script> -import { GlAlert, GlSprintf } from '@gitlab/ui'; -import { __, n__ } from '~/locale'; - -export default { - maxWarningsSummary: __('%{total} warnings found: showing first %{warningsDisplayed}'), - components: { - GlAlert, - GlSprintf, - }, - props: { - warnings: { - type: Array, - required: true, - }, - maxWarnings: { - type: Number, - required: false, - default: 25, - }, - title: { - type: String, - required: false, - default: __('The form contains the following warning:'), - }, - }, - computed: { - totalWarnings() { - return this.warnings.length; - }, - overMaxWarningsLimit() { - return this.totalWarnings > this.maxWarnings; - }, - warningsSummary() { - return n__('%d warning found:', '%d warnings found:', this.totalWarnings); - }, - summaryMessage() { - return this.overMaxWarningsLimit ? this.$options.maxWarningsSummary : this.warningsSummary; - }, - limitWarnings() { - return this.warnings.slice(0, this.maxWarnings); - }, - }, -}; -</script> - -<template> - <gl-alert class="gl-mb-4" :title="title" variant="warning" @dismiss="$emit('dismiss')"> - <details> - <summary> - <gl-sprintf :message="summaryMessage"> - <template #total> - {{ totalWarnings }} - </template> - <template #warningsDisplayed> - {{ maxWarnings }} - </template> - </gl-sprintf> - </summary> - <p - v-for="(warning, index) in limitWarnings" - :key="`warning-${index}`" - data-testid="ci-lint-warning" - > - {{ warning }} - </p> - </details> - </gl-alert> -</template> |