summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/components/summary_row.vue
blob: 8eb43bcf1baeb3603fd684ea0bafd999432567c9 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import Popover from '~/vue_shared/components/help_popover.vue';
import { ICON_WARNING } from '../constants';

/**
 * Renders the summary row for each report
 *
 * Used both in MR widget and Pipeline's view for:
 * - Unit tests reports
 * - Security reports
 */

export default {
  name: 'ReportSummaryRow',
  components: {
    CiIcon,
    Popover,
    GlLoadingIcon,
  },
  props: {
    nestedSummary: {
      type: Boolean,
      required: false,
      default: false,
    },
    summary: {
      type: String,
      required: false,
      default: '',
    },
    statusIcon: {
      type: String,
      required: true,
    },
    popoverOptions: {
      type: Object,
      required: false,
      default: null,
    },
  },
  computed: {
    iconStatus() {
      return {
        group: this.statusIcon,
        icon: `status_${this.statusIcon}`,
      };
    },
    rowClasses() {
      if (!this.nestedSummary) {
        return ['gl-px-5'];
      }
      return ['gl-pl-7', 'gl-pr-5', { 'gl-bg-gray-10': this.statusIcon === ICON_WARNING }];
    },
    statusIconSize() {
      if (!this.nestedSummary) {
        return 24;
      }
      return 16;
    },
  },
};
</script>
<template>
  <div
    class="gl-border-t-solid gl-border-t-gray-100 gl-border-t-1 gl-py-3 gl-display-flex gl-align-items-center"
    :class="rowClasses"
  >
    <div class="gl-mr-3">
      <gl-loading-icon
        v-if="statusIcon === 'loading'"
        css-class="report-block-list-loading-icon"
        size="md"
      />
      <ci-icon v-else :status="iconStatus" :size="statusIconSize" data-testid="summary-row-icon" />
    </div>
    <div class="report-block-list-issue-description">
      <div class="report-block-list-issue-description-text" data-testid="summary-row-description">
        <slot name="summary">{{ summary }}</slot
        ><span v-if="popoverOptions" class="text-nowrap"
          >&nbsp;<popover v-if="popoverOptions" :options="popoverOptions" class="align-top" />
        </span>
      </div>
    </div>
    <div
      v-if="$slots.default"
      class="text-right flex-fill d-flex justify-content-end flex-column flex-sm-row"
    >
      <slot></slot>
    </div>
  </div>
</template>