Commit 7a61ecc0 authored by Clement Ho's avatar Clement Ho

Merge branch '9834-translate-severity-values' into 'master'

Resolve "Should we translate severity values"

See merge request gitlab-org/gitlab-ee!10230
parents 73673983 dac4209a
......@@ -2,9 +2,11 @@
import dateFormat from 'dateformat';
import { mapState, mapGetters, mapActions } from 'vuex';
import { GlChart } from '@gitlab/ui/dist/charts';
import { __ } from '~/locale';
import ChartTooltip from './vulnerability_chart_tooltip.vue';
import ChartButtons from './vulnerability_chart_buttons.vue';
import { DAY_IN_MS, DAYS } from '../store/modules/vulnerabilities/constants';
import { SEVERITY_LEVELS } from '../store/constants';
export default {
name: 'VulnerabilityChart',
......@@ -19,23 +21,23 @@ export default {
tooltipEntries: [],
lines: [
{
name: 'Critical',
name: SEVERITY_LEVELS.critical,
color: '#C0341D',
},
{
name: 'High',
name: SEVERITY_LEVELS.high,
color: '#DE7E00',
},
{
name: 'Medium',
name: SEVERITY_LEVELS.medium,
color: '#6E49CB',
},
{
name: 'Low',
name: SEVERITY_LEVELS.low,
color: '#4F4F4F',
},
{
name: 'Total',
name: __('Total'),
color: '#1F78D1',
},
],
......
<script>
import { SEVERITY_LEVELS } from '../store/constants';
export default {
name: 'VulnerabilityCount',
props: {
......@@ -20,13 +22,16 @@ export default {
className() {
return `vulnerability-count-${this.severity}`;
},
severityTitle() {
return SEVERITY_LEVELS[this.severity] || this.severity;
},
},
};
</script>
<template>
<div class="vulnerability-count" :class="className">
<div class="vulnerability-count-header">{{ severity }}</div>
<div class="vulnerability-count-header">{{ severityTitle }}</div>
<div class="vulnerability-count-body">
<span v-if="isLoading">&mdash;</span> <span v-else>{{ count }}</span>
</div>
......
import { s__ } from '~/locale';
export const SEVERITY_LEVELS = {
critical: s__('severity|Critical'),
high: s__('severity|High'),
medium: s__('severity|Medium'),
low: s__('severity|Low'),
unknown: s__('severity|Unknown'),
info: s__('severity|Info'),
undefined: s__('severity|Undefined'),
};
export const CONFIDENCE_LEVELS = {
confirmed: s__('confidence|Confirmed'),
high: s__('confidence|High'),
medium: s__('confidence|Medium'),
low: s__('confidence|Low'),
unknown: s__('confidence|Unknown'),
ignore: s__('confidence|Ignore'),
experimental: s__('confidence|Experimental'),
undefined: s__('confidence|Undefined'),
};
export const REPORT_TYPES = {
container_scanning: s__('ciReport|Container Scanning'),
dast: s__('ciReport|DAST'),
dependency_scanning: s__('ciReport|Dependency Scanning'),
sast: s__('ciReport|SAST'),
};
<script>
import { SEVERITY_LEVELS } from 'ee/security_dashboard/store/constants';
export default {
name: 'SeverityBadge',
props: {
......@@ -9,14 +11,17 @@ export default {
},
computed: {
className() {
return `severity-badge-${this.severity}`;
return `severity-badge-${this.severity.toLowerCase()}`;
},
severityTitle() {
return SEVERITY_LEVELS[this.severity] || this.severity;
},
},
};
</script>
<template>
<div class="severity-badge" :class="className">{{ severity }}</div>
<div class="severity-badge" :class="className">{{ severityTitle }}</div>
</template>
<style>
......
......@@ -52,15 +52,15 @@ describe('Security Dashboard Table Row', () => {
});
it('should render the severity', () => {
expect(vm.$el.querySelectorAll('.table-mobile-content')[0].textContent).toContain(
props.vulnerability.severity,
);
expect(
vm.$el.querySelectorAll('.table-mobile-content')[0].textContent.toLowerCase(),
).toContain(props.vulnerability.severity);
});
it('should render the confidence', () => {
expect(vm.$el.querySelectorAll('.table-mobile-content')[2].textContent).toContain(
props.vulnerability.confidence,
);
expect(
vm.$el.querySelectorAll('.table-mobile-content')[2].textContent.toLowerCase(),
).toContain(props.vulnerability.confidence);
});
describe('the project name', () => {
......
......@@ -23,7 +23,7 @@ describe('Vulnerability Count List', () => {
it('should fetch the counts for each severity', () => {
const firstCount = vm.$el.querySelector('.js-count');
expect(firstCount.textContent).toContain('critical');
expect(firstCount.textContent).toContain('Critical');
expect(firstCount.textContent).toContain(mockData.critical);
});
......
......@@ -21,7 +21,7 @@ describe('Vulnerability Count', () => {
it('should render the severity label', () => {
const header = vm.$el.querySelector('.vulnerability-count-header');
expect(header.textContent).toMatch(props.severity);
expect(header.textContent.toLowerCase()).toMatch(props.severity);
});
it('should render the count', () => {
......
......@@ -172,7 +172,7 @@ describe('Security Reports modal', () => {
it('renders severity with a badge', () => {
const badge = vm.$el.querySelector('.severity-badge');
expect(badge.textContent).toContain('critical');
expect(badge.textContent).toContain('Critical');
});
});
});
......
......@@ -11180,6 +11180,9 @@ msgstr ""
msgid "Too many changes to show."
msgstr ""
msgid "Total"
msgstr ""
msgid "Total Contributions"
msgstr ""
......@@ -12602,6 +12605,30 @@ msgstr ""
msgid "commented on %{link_to_project}"
msgstr ""
msgid "confidence|Confirmed"
msgstr ""
msgid "confidence|Experimental"
msgstr ""
msgid "confidence|High"
msgstr ""
msgid "confidence|Ignore"
msgstr ""
msgid "confidence|Low"
msgstr ""
msgid "confidence|Medium"
msgstr ""
msgid "confidence|Undefined"
msgstr ""
msgid "confidence|Unknown"
msgstr ""
msgid "confidentiality|You are going to turn off the confidentiality. This means <strong>everyone</strong> will be able to see and leave a comment on this issue."
msgstr ""
......@@ -13110,6 +13137,27 @@ msgstr ""
msgid "security Reports|There was an error creating the merge request"
msgstr ""
msgid "severity|Critical"
msgstr ""
msgid "severity|High"
msgstr ""
msgid "severity|Info"
msgstr ""
msgid "severity|Low"
msgstr ""
msgid "severity|Medium"
msgstr ""
msgid "severity|Undefined"
msgstr ""
msgid "severity|Unknown"
msgstr ""
msgid "should be higher than %{access} inherited membership from group %{group_name}"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment