Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issues_list.vue « components « reports « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee07efea3b09cffda14f272fa0de8ee1d9aa56ab (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
94
95
96
97
98
99
100
101
102
103
104
105
106
<script>
import ReportItem from '~/reports/components/report_item.vue';
import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants';
import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue';

const wrapIssueWithState = (status, isNew = false) => issue => ({
  status: issue.status || status,
  isNew,
  issue,
});

/**
 * Renders block of issues
 */
export default {
  components: {
    SmartVirtualList,
    ReportItem,
  },
  // Typical height of a report item in px
  typicalReportItemHeight: 32,
  /*
   The maximum amount of shown issues. This is calculated by
   ( max-height of report-block-list / typicalReportItemHeight ) + some safety margin
   We will use VirtualList if we have more items than this number.
   For entries lower than this number, the virtual scroll list calculates the total height of the element wrongly.
   */
  maxShownReportItems: 20,
  props: {
    newIssues: {
      type: Array,
      required: false,
      default: () => [],
    },
    unresolvedIssues: {
      type: Array,
      required: false,
      default: () => [],
    },
    resolvedIssues: {
      type: Array,
      required: false,
      default: () => [],
    },
    neutralIssues: {
      type: Array,
      required: false,
      default: () => [],
    },
    component: {
      type: String,
      required: false,
      default: '',
    },
    showReportSectionStatusIcon: {
      type: Boolean,
      required: false,
      default: true,
    },
    issuesUlElementClass: {
      type: String,
      required: false,
      default: '',
    },
    issueItemClass: {
      type: String,
      required: false,
      default: null,
    },
  },
  computed: {
    issuesWithState() {
      return [
        ...this.newIssues.map(wrapIssueWithState(STATUS_FAILED, true)),
        ...this.unresolvedIssues.map(wrapIssueWithState(STATUS_FAILED)),
        ...this.neutralIssues.map(wrapIssueWithState(STATUS_NEUTRAL)),
        ...this.resolvedIssues.map(wrapIssueWithState(STATUS_SUCCESS)),
      ];
    },
    wclass() {
      return `report-block-list ${this.issuesUlElementClass}`;
    },
  },
};
</script>
<template>
  <smart-virtual-list
    :length="issuesWithState.length"
    :remain="$options.maxShownReportItems"
    :size="$options.typicalReportItemHeight"
    class="report-block-container"
    wtag="ul"
    :wclass="wclass"
  >
    <report-item
      v-for="(wrapped, index) in issuesWithState"
      :key="index"
      :issue="wrapped.issue"
      :status="wrapped.status"
      :component="component"
      :is-new="wrapped.isNew"
      :show-report-section-status-icon="showReportSectionStatusIcon"
      :class="issueItemClass"
    />
  </smart-virtual-list>
</template>