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

findings_drawer.vue « shared « components « diffs « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2cffe928d7bc4d9f8f6e7b2eb7c5343d42322ba8 (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
107
108
109
110
<script>
import { GlDrawer, GlIcon, GlLink } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
import { s__ } from '~/locale';
import { DRAWER_Z_INDEX } from '~/lib/utils/constants';
import { SEVERITY_CLASSES, SEVERITY_ICONS } from '~/ci/reports/codequality_report/constants';
import { getContentWrapperHeight } from '~/lib/utils/dom_utils';

export const i18n = {
  severity: s__('FindingsDrawer|Severity:'),
  engine: s__('FindingsDrawer|Engine:'),
  category: s__('FindingsDrawer|Category:'),
  otherLocations: s__('FindingsDrawer|Other locations:'),
};

export default {
  i18n,
  components: { GlDrawer, GlIcon, GlLink },
  directives: {
    SafeHtml,
  },
  props: {
    drawer: {
      type: Object,
      required: true,
    },
  },
  safeHtmlConfig: {
    ALLOWED_TAGS: ['a', 'h1', 'h2', 'p'],
    ALLOWED_ATTR: ['href', 'rel'],
  },
  computed: {
    getDrawerHeaderHeight() {
      return getContentWrapperHeight();
    },
  },
  DRAWER_Z_INDEX,
  methods: {
    severityClass(severity) {
      return SEVERITY_CLASSES[severity] || SEVERITY_CLASSES.unknown;
    },
    severityIcon(severity) {
      return SEVERITY_ICONS[severity] || SEVERITY_ICONS.unknown;
    },
  },
};
</script>
<template>
  <gl-drawer
    :header-height="getDrawerHeaderHeight"
    :z-index="$options.DRAWER_Z_INDEX"
    class="findings-drawer"
    :open="Object.keys(drawer).length !== 0"
    @close="$emit('close')"
  >
    <template #title>
      <h2 data-testid="findings-drawer-heading" class="gl-font-size-h2 gl-mt-0 gl-mb-0">
        {{ drawer.description }}
      </h2>
    </template>

    <template #default>
      <ul class="gl-list-style-none gl-border-b-initial gl-mb-0 gl-pb-0!">
        <li data-testid="findings-drawer-severity" class="gl-mb-4">
          <span class="gl-font-weight-bold">{{ $options.i18n.severity }}</span>
          <gl-icon
            data-testid="findings-drawer-severity-icon"
            :size="12"
            :name="severityIcon(drawer.severity)"
            :class="severityClass(drawer.severity)"
            class="codequality-severity-icon"
          />

          {{ drawer.severity }}
        </li>
        <li data-testid="findings-drawer-engine" class="gl-mb-4">
          <span class="gl-font-weight-bold">{{ $options.i18n.engine }}</span>
          {{ drawer.engineName }}
        </li>
        <li data-testid="findings-drawer-category" class="gl-mb-4">
          <span class="gl-font-weight-bold">{{ $options.i18n.category }}</span>
          {{ drawer.categories ? drawer.categories[0] : '' }}
        </li>
        <li data-testid="findings-drawer-other-locations" class="gl-mb-4">
          <span class="gl-font-weight-bold gl-mb-3 gl-display-block">{{
            $options.i18n.otherLocations
          }}</span>
          <ul class="gl-pl-6">
            <li
              v-for="otherLocation in drawer.otherLocations"
              :key="otherLocation.path"
              class="gl-mb-1"
            >
              <gl-link
                data-testid="findings-drawer-other-locations-link"
                :href="otherLocation.href"
                >{{ otherLocation.path }}</gl-link
              >
            </li>
          </ul>
        </li>
      </ul>
      <span
        v-safe-html:[$options.safeHtmlConfig]="drawer.content ? drawer.content.body : ''"
        data-testid="findings-drawer-body"
        class="drawer-body gl-display-block gl-px-3 gl-py-0!"
      ></span>
    </template>
  </gl-drawer>
</template>