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 @@ ...@@ -2,9 +2,11 @@
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { GlChart } from '@gitlab/ui/dist/charts'; import { GlChart } from '@gitlab/ui/dist/charts';
import { __ } from '~/locale';
import ChartTooltip from './vulnerability_chart_tooltip.vue'; import ChartTooltip from './vulnerability_chart_tooltip.vue';
import ChartButtons from './vulnerability_chart_buttons.vue'; import ChartButtons from './vulnerability_chart_buttons.vue';
import { DAY_IN_MS, DAYS } from '../store/modules/vulnerabilities/constants'; import { DAY_IN_MS, DAYS } from '../store/modules/vulnerabilities/constants';
import { SEVERITY_LEVELS } from '../store/constants';
export default { export default {
name: 'VulnerabilityChart', name: 'VulnerabilityChart',
...@@ -19,23 +21,23 @@ export default { ...@@ -19,23 +21,23 @@ export default {
tooltipEntries: [], tooltipEntries: [],
lines: [ lines: [
{ {
name: 'Critical', name: SEVERITY_LEVELS.critical,
color: '#C0341D', color: '#C0341D',
}, },
{ {
name: 'High', name: SEVERITY_LEVELS.high,
color: '#DE7E00', color: '#DE7E00',
}, },
{ {
name: 'Medium', name: SEVERITY_LEVELS.medium,
color: '#6E49CB', color: '#6E49CB',
}, },
{ {
name: 'Low', name: SEVERITY_LEVELS.low,
color: '#4F4F4F', color: '#4F4F4F',
}, },
{ {
name: 'Total', name: __('Total'),
color: '#1F78D1', color: '#1F78D1',
}, },
], ],
......
<script> <script>
import { SEVERITY_LEVELS } from '../store/constants';
export default { export default {
name: 'VulnerabilityCount', name: 'VulnerabilityCount',
props: { props: {
...@@ -20,13 +22,16 @@ export default { ...@@ -20,13 +22,16 @@ export default {
className() { className() {
return `vulnerability-count-${this.severity}`; return `vulnerability-count-${this.severity}`;
}, },
severityTitle() {
return SEVERITY_LEVELS[this.severity] || this.severity;
},
}, },
}; };
</script> </script>
<template> <template>
<div class="vulnerability-count" :class="className"> <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"> <div class="vulnerability-count-body">
<span v-if="isLoading">&mdash;</span> <span v-else>{{ count }}</span> <span v-if="isLoading">&mdash;</span> <span v-else>{{ count }}</span>
</div> </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> <script>
import { SEVERITY_LEVELS } from 'ee/security_dashboard/store/constants';
export default { export default {
name: 'SeverityBadge', name: 'SeverityBadge',
props: { props: {
...@@ -9,14 +11,17 @@ export default { ...@@ -9,14 +11,17 @@ export default {
}, },
computed: { computed: {
className() { className() {
return `severity-badge-${this.severity}`; return `severity-badge-${this.severity.toLowerCase()}`;
},
severityTitle() {
return SEVERITY_LEVELS[this.severity] || this.severity;
}, },
}, },
}; };
</script> </script>
<template> <template>
<div class="severity-badge" :class="className">{{ severity }}</div> <div class="severity-badge" :class="className">{{ severityTitle }}</div>
</template> </template>
<style> <style>
......
...@@ -52,15 +52,15 @@ describe('Security Dashboard Table Row', () => { ...@@ -52,15 +52,15 @@ describe('Security Dashboard Table Row', () => {
}); });
it('should render the severity', () => { it('should render the severity', () => {
expect(vm.$el.querySelectorAll('.table-mobile-content')[0].textContent).toContain( expect(
props.vulnerability.severity, vm.$el.querySelectorAll('.table-mobile-content')[0].textContent.toLowerCase(),
); ).toContain(props.vulnerability.severity);
}); });
it('should render the confidence', () => { it('should render the confidence', () => {
expect(vm.$el.querySelectorAll('.table-mobile-content')[2].textContent).toContain( expect(
props.vulnerability.confidence, vm.$el.querySelectorAll('.table-mobile-content')[2].textContent.toLowerCase(),
); ).toContain(props.vulnerability.confidence);
}); });
describe('the project name', () => { describe('the project name', () => {
......
...@@ -23,7 +23,7 @@ describe('Vulnerability Count List', () => { ...@@ -23,7 +23,7 @@ describe('Vulnerability Count List', () => {
it('should fetch the counts for each severity', () => { it('should fetch the counts for each severity', () => {
const firstCount = vm.$el.querySelector('.js-count'); const firstCount = vm.$el.querySelector('.js-count');
expect(firstCount.textContent).toContain('critical'); expect(firstCount.textContent).toContain('Critical');
expect(firstCount.textContent).toContain(mockData.critical); expect(firstCount.textContent).toContain(mockData.critical);
}); });
......
...@@ -21,7 +21,7 @@ describe('Vulnerability Count', () => { ...@@ -21,7 +21,7 @@ describe('Vulnerability Count', () => {
it('should render the severity label', () => { it('should render the severity label', () => {
const header = vm.$el.querySelector('.vulnerability-count-header'); 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', () => { it('should render the count', () => {
......
...@@ -172,7 +172,7 @@ describe('Security Reports modal', () => { ...@@ -172,7 +172,7 @@ describe('Security Reports modal', () => {
it('renders severity with a badge', () => { it('renders severity with a badge', () => {
const badge = vm.$el.querySelector('.severity-badge'); const badge = vm.$el.querySelector('.severity-badge');
expect(badge.textContent).toContain('critical'); expect(badge.textContent).toContain('Critical');
}); });
}); });
}); });
......
...@@ -11180,6 +11180,9 @@ msgstr "" ...@@ -11180,6 +11180,9 @@ msgstr ""
msgid "Too many changes to show." msgid "Too many changes to show."
msgstr "" msgstr ""
msgid "Total"
msgstr ""
msgid "Total Contributions" msgid "Total Contributions"
msgstr "" msgstr ""
...@@ -12602,6 +12605,30 @@ msgstr "" ...@@ -12602,6 +12605,30 @@ msgstr ""
msgid "commented on %{link_to_project}" msgid "commented on %{link_to_project}"
msgstr "" 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." 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 "" msgstr ""
...@@ -13110,6 +13137,27 @@ msgstr "" ...@@ -13110,6 +13137,27 @@ msgstr ""
msgid "security Reports|There was an error creating the merge request" msgid "security Reports|There was an error creating the merge request"
msgstr "" 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}" msgid "should be higher than %{access} inherited membership from group %{group_name}"
msgstr "" 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