summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/security_configuration/components/configuration_table.vue
blob: 4a3f988296cbd241b6125a2021d47a633d259318 (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
<script>
import { GlLink, GlTable, GlAlert } from '@gitlab/ui';
import { s__, sprintf } from '~/locale';
import {
  REPORT_TYPE_SAST,
  REPORT_TYPE_DAST,
  REPORT_TYPE_DAST_PROFILES,
  REPORT_TYPE_DEPENDENCY_SCANNING,
  REPORT_TYPE_CONTAINER_SCANNING,
  REPORT_TYPE_COVERAGE_FUZZING,
  REPORT_TYPE_API_FUZZING,
  REPORT_TYPE_LICENSE_COMPLIANCE,
} from '~/vue_shared/security_reports/constants';
import ManageSast from './manage_sast.vue';
import { scanners } from './scanners_constants';
import Upgrade from './upgrade.vue';

const borderClasses = 'gl-border-b-1! gl-border-b-solid! gl-border-gray-100!';
const thClass = `gl-text-gray-900 gl-bg-transparent! ${borderClasses}`;

export default {
  components: {
    GlLink,
    GlTable,
    GlAlert,
  },
  data() {
    return {
      errorMessage: '',
    };
  },
  methods: {
    getFeatureDocumentationLinkLabel(item) {
      return sprintf(s__('SecurityConfiguration|Feature documentation for %{featureName}'), {
        featureName: item.name,
      });
    },
    onError(value) {
      this.errorMessage = value;
    },
    getComponentForItem(item) {
      const COMPONENTS = {
        [REPORT_TYPE_SAST]: ManageSast,
        [REPORT_TYPE_DAST]: Upgrade,
        [REPORT_TYPE_DAST_PROFILES]: Upgrade,
        [REPORT_TYPE_DEPENDENCY_SCANNING]: Upgrade,
        [REPORT_TYPE_CONTAINER_SCANNING]: Upgrade,
        [REPORT_TYPE_COVERAGE_FUZZING]: Upgrade,
        [REPORT_TYPE_API_FUZZING]: Upgrade,
        [REPORT_TYPE_LICENSE_COMPLIANCE]: Upgrade,
      };

      return COMPONENTS[item.type];
    },
  },
  table: {
    fields: [
      {
        key: 'feature',
        label: s__('SecurityConfiguration|Security Control'),
        thClass,
      },
      {
        key: 'manage',
        label: s__('SecurityConfiguration|Manage'),
        thClass,
      },
    ],
    items: scanners,
  },
};
</script>

<template>
  <div>
    <gl-alert v-if="errorMessage" variant="danger" :dismissible="false">
      {{ errorMessage }}
    </gl-alert>
    <gl-table :items="$options.table.items" :fields="$options.table.fields" stacked="md">
      <template #cell(feature)="{ item }">
        <div class="gl-text-gray-900">
          {{ item.name }}
        </div>
        <div>
          {{ item.description }}
          <gl-link
            target="_blank"
            data-testid="help-link"
            :href="item.helpPath"
            :aria-label="getFeatureDocumentationLinkLabel(item)"
          >
            {{ s__('SecurityConfiguration|More information') }}
          </gl-link>
        </div>
      </template>

      <template #cell(manage)="{ item }">
        <component :is="getComponentForItem(item)" :data-testid="item.type" @error="onError" />
      </template>
    </gl-table>
  </div>
</template>