summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/codequality_report/components/codequality_issue_body.vue
blob: d0a5615bb571c3124cf4ed43b5316978a4c17a16 (plain)
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
<script>
/**
 * Renders Code quality body text
 * Fixed: [name] in [link]:[line]
 */
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import ReportLink from '~/reports/components/report_link.vue';
import { STATUS_SUCCESS } from '~/reports/constants';
import { s__ } from '~/locale';
import { SEVERITY_CLASSES, SEVERITY_ICONS } from '../constants';

export default {
  name: 'CodequalityIssueBody',
  components: {
    GlIcon,
    ReportLink,
  },
  directives: {
    tooltip: GlTooltipDirective,
  },
  props: {
    status: {
      type: String,
      required: true,
    },
    issue: {
      type: Object,
      required: true,
    },
  },
  computed: {
    issueName() {
      return `${this.severityLabel} - ${this.issue.name}`;
    },
    isStatusSuccess() {
      return this.status === STATUS_SUCCESS;
    },
    severityClass() {
      return SEVERITY_CLASSES[this.issue.severity] || SEVERITY_CLASSES.unknown;
    },
    severityIcon() {
      return SEVERITY_ICONS[this.issue.severity] || SEVERITY_ICONS.unknown;
    },
    severityLabel() {
      return this.$options.severityText[this.issue.severity] || 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-fill-1">
      <div>
        <strong v-if="isStatusSuccess">{{ s__('ciReport|Fixed:') }}</strong>
        {{ issueName }}
      </div>

      <report-link v-if="issue.path" :issue="issue" />
    </div>
  </div>
</template>