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

security_summary.vue « components « security_reports « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e3aa25a294e1f45d5aaf78ee78a7d221063a5612 (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
<script>
import { GlSprintf } from '@gitlab/ui';
import { SEVERITY_CLASS_NAME_MAP } from './constants';

export default {
  components: {
    GlSprintf,
  },
  props: {
    message: {
      type: Object,
      required: true,
    },
  },
  computed: {
    shouldShowCountMessage() {
      return !this.message.status && Boolean(this.message.countMessage);
    },
  },
  methods: {
    getSeverityClass(severity) {
      return SEVERITY_CLASS_NAME_MAP[severity];
    },
  },
  slotNames: ['critical', 'high', 'other'],
  spacingClasses: {
    critical: 'gl-pl-4',
    high: 'gl-px-2',
    other: 'gl-px-2',
  },
};
</script>

<template>
  <span>
    <gl-sprintf :message="message.message">
      <template #total="{ content }">
        <strong>{{ content }}</strong>
      </template>
    </gl-sprintf>
    <span v-if="shouldShowCountMessage" class="gl-font-sm">
      <gl-sprintf :message="message.countMessage">
        <template v-for="slotName in $options.slotNames" #[slotName]="{ content }">
          <span :key="slotName">
            <strong
              v-if="message[slotName] > 0"
              :class="[getSeverityClass(slotName), $options.spacingClasses[slotName]]"
            >
              {{ content }}
            </strong>
            <span v-else :class="$options.spacingClasses[slotName]">
              {{ content }}
            </span>
          </span>
        </template>
      </gl-sprintf>
    </span>
  </span>
</template>