All files / app/assets/javascripts/reports/codequality_report/components codequality_issue_body.vue

100% Statements 12/12
100% Branches 8/8
100% Functions 7/7
100% Lines 12/12

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 64 65 66 67 68 69 70 71 72 73 74 75 76 77          8x 8x 8x 8x 8x                                               47x     47x     47x     47x     47x     47x                         165x                              
<script>
/**
 * Renders Code quality body text
 * Fixed: [name] in [link]:[line]
 */
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { s__ } from '~/locale';
import ReportLink from '~/reports/components/report_link.vue';
import { STATUS_SUCCESS, STATUS_NEUTRAL } from '~/reports/constants';
import { SEVERITY_CLASSES, SEVERITY_ICONS } from '../constants';
 
export default {
  name: 'CodequalityIssueBody',
  components: {
    GlIcon,
    ReportLink,
  },
  directives: {
    tooltip: GlTooltipDirective,
  },
  props: {
    status: {
      type: String,
      required: false,
      default: STATUS_NEUTRAL,
    },
    issue: {
      type: Object,
      required: true,
    },
  },
  computed: {
    issueName() {
      return `${this.severityLabel} - ${this.issue.name}`;
    },
    issueSeverity() {
      return this.issue.severity.toLowerCase();
    },
    isStatusSuccess() {
      return this.status === STATUS_SUCCESS;
    },
    severityClass() {
      return SEVERITY_CLASSES[this.issueSeverity] || SEVERITY_CLASSES.unknown;
    },
    severityIcon() {
      return SEVERITY_ICONS[this.issueSeverity] || SEVERITY_ICONS.unknown;
    },
    severityLabel() {
      return this.$options.severityText[this.issueSeverity] || this.$options.severityText.unknown;
    },
  },
  severityText: {
    info: s__('severity|Info'),
    minor: s__('severity|Minor'),
    major: s__('severity|Major'),
    critical: s__('severity|Critical'),
    blocker: s__('severity|Blocker'),
    unknown: s__('severity|Unknown'),
  },
};
</script>
<template>
  <div class="gl-display-flex gl-mt-2 gl-mb-2 gl-w-full">
    <span :class="severityClass" class="gl-mr-5" data-testid="codequality-severity-icon">
      <gl-icon v-tooltip="severityLabel" :name="severityIcon" :size="12" />
    </span>
    <div class="gl-flex-grow-1">
      <div>
        <strong v-if="isStatusSuccess">{{ s__('ciReport|Fixed:') }}</strong>
        {{ issueName }}
      </div>
 
      <report-link v-if="issue.path" :issue="issue" />
    </div>
  </div>
</template>