All files / app/assets/javascripts/pipelines/components/pipelines_list pipelines_status_badge.vue

100% Statements 11/11
87.5% Branches 7/8
100% Functions 6/6
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  4x 4x 4x 4x                                     137x     132x     137x     104x         104x     104x           423x                                
<script>
import CodeQualityWalkthrough from '~/code_quality_walkthrough/components/step.vue';
import { PIPELINE_STATUSES } from '~/code_quality_walkthrough/constants';
import { CHILD_VIEW } from '~/pipelines/constants';
import CiBadge from '~/vue_shared/components/ci_badge_link.vue';
 
export default {
  components: {
    CodeQualityWalkthrough,
    CiBadge,
  },
  props: {
    pipeline: {
      type: Object,
      required: true,
    },
    viewType: {
      type: String,
      required: true,
    },
  },
  computed: {
    pipelineStatus() {
      return this.pipeline?.details?.status ?? {};
    },
    isChildView() {
      return this.viewType === CHILD_VIEW;
    },
    shouldRenderCodeQualityWalkthrough() {
      return Object.values(PIPELINE_STATUSES).includes(this.pipelineStatus.group);
    },
    codeQualityStep() {
      const prefix = [PIPELINE_STATUSES.successWithWarnings, PIPELINE_STATUSES.failed].includes(
        this.pipelineStatus.group,
      )
        ? 'failed'
        : this.pipelineStatus.group;
      return `${prefix}_pipeline`;
    },
    codeQualityBuildPath() {
      return this.pipeline?.details?.code_quality_build_path;
    },
  },
};
</script>
 
<template>
  <div>
    <ci-badge
      id="js-code-quality-walkthrough"
      :status="pipelineStatus"
      :show-text="!isChildView"
      :icon-classes="'gl-vertical-align-middle!'"
      data-qa-selector="pipeline_commit_status"
    />
    <code-quality-walkthrough
      v-if="shouldRenderCodeQualityWalkthrough"
      :step="codeQualityStep"
      :link="codeQualityBuildPath"
    />
  </div>
</template>