Commit ad367643 authored by Jannik Lehmann's avatar Jannik Lehmann Committed by Jose Ivan Vargas

Refactored Code Quality terms and names

parent ef834f6b
...@@ -55,10 +55,12 @@ export default { ...@@ -55,10 +55,12 @@ export default {
...mapActions(['fetchReports', 'setPaths']), ...mapActions(['fetchReports', 'setPaths']),
}, },
loadingText: sprintf(s__('ciReport|Loading %{reportName} report'), { loadingText: sprintf(s__('ciReport|Loading %{reportName} report'), {
reportName: 'codeclimate', // eslint-disable-next-line @gitlab/require-i18n-strings
reportName: 'Code quality',
}), }),
errorText: sprintf(s__('ciReport|Failed to load %{reportName} report'), { errorText: sprintf(s__('ciReport|Failed to load %{reportName} report'), {
reportName: 'codeclimate', // eslint-disable-next-line @gitlab/require-i18n-strings
reportName: 'Code quality',
}), }),
}; };
</script> </script>
......
import { spriteIcon } from '~/lib/utils/common_utils'; import { spriteIcon } from '~/lib/utils/common_utils';
import { sprintf, __, s__, n__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import { LOADING, ERROR, SUCCESS, STATUS_NOT_FOUND } from '../../constants'; import { LOADING, ERROR, SUCCESS, STATUS_NOT_FOUND } from '../../constants';
export const hasCodequalityIssues = (state) => export const hasCodequalityIssues = (state) =>
...@@ -18,27 +18,23 @@ export const codequalityStatus = (state) => { ...@@ -18,27 +18,23 @@ export const codequalityStatus = (state) => {
export const codequalityText = (state) => { export const codequalityText = (state) => {
const { newIssues, resolvedIssues } = state; const { newIssues, resolvedIssues } = state;
const text = []; let text;
if (!newIssues.length && !resolvedIssues.length) { if (!newIssues.length && !resolvedIssues.length) {
text.push(s__('ciReport|No changes to code quality')); text = s__('ciReport|No changes to code quality');
} else { } else if (newIssues.length && resolvedIssues.length) {
text.push(s__('ciReport|Code quality')); text = sprintf(
s__(`ciReport|Code quality scanning detected %{issueCount} changes in merged results`),
if (resolvedIssues.length) { {
text.push(n__(' improved on %d point', ' improved on %d points', resolvedIssues.length)); issueCount: newIssues.length + resolvedIssues.length,
} },
);
if (newIssues.length && resolvedIssues.length) { } else if (resolvedIssues.length) {
text.push(__(' and')); text = s__(`ciReport|Code quality improved`);
} } else if (newIssues.length) {
text = s__(`ciReport|Code quality degraded`);
if (newIssues.length) {
text.push(n__(' degraded on %d point', ' degraded on %d points', newIssues.length));
}
} }
return text.join(''); return text;
}; };
export const codequalityPopover = (state) => { export const codequalityPopover = (state) => {
......
<script> <script>
import { GlPagination, GlSkeletonLoader } from '@gitlab/ui';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { GlPagination, GlSkeletonLoader } from '@gitlab/ui';
import { componentNames } from 'ee/reports/components/issue_body'; import { componentNames } from 'ee/reports/components/issue_body';
import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin'; import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin';
import { n__, s__, sprintf } from '~/locale'; import { n__, s__, sprintf } from '~/locale';
...@@ -71,8 +71,8 @@ export default { ...@@ -71,8 +71,8 @@ export default {
<report-section <report-section
always-open always-open
:status="codequalityStatus" :status="codequalityStatus"
:loading-text="translateText('codeclimate').loading" :loading-text="translateText('Code Quality').loading"
:error-text="translateText('codeclimate').error" :error-text="translateText('Code Quality').error"
:success-text="codequalityText" :success-text="codequalityText"
:unresolved-issues="codequalityIssues" :unresolved-issues="codequalityIssues"
:resolved-issues="[]" :resolved-issues="[]"
......
...@@ -53,7 +53,7 @@ describe('Codequality report app', () => { ...@@ -53,7 +53,7 @@ describe('Codequality report app', () => {
}); });
it('shows a loading state', () => { it('shows a loading state', () => {
expect(findStatus().text()).toBe('Loading codeclimate report'); expect(findStatus().text()).toBe('Loading Code Quality report');
expect(findSkeletonLoader().exists()).toBe(true); expect(findSkeletonLoader().exists()).toBe(true);
}); });
}); });
...@@ -65,7 +65,7 @@ describe('Codequality report app', () => { ...@@ -65,7 +65,7 @@ describe('Codequality report app', () => {
it('shows a warning icon and error message', () => { it('shows a warning icon and error message', () => {
expect(findWarningIcon().exists()).toBe(true); expect(findWarningIcon().exists()).toBe(true);
expect(findStatus().text()).toBe('Failed to load codeclimate report'); expect(findStatus().text()).toBe('Failed to load Code Quality report');
}); });
}); });
......
...@@ -40,25 +40,12 @@ msgstr "" ...@@ -40,25 +40,12 @@ msgstr ""
msgid " You need to do this before %{grace_period_deadline}." msgid " You need to do this before %{grace_period_deadline}."
msgstr "" msgstr ""
msgid " and"
msgstr ""
msgid " and " msgid " and "
msgstr "" msgstr ""
msgid " and %{sliced}" msgid " and %{sliced}"
msgstr "" msgstr ""
msgid " degraded on %d point"
msgid_plural " degraded on %d points"
msgstr[0] ""
msgstr[1] ""
msgid " improved on %d point"
msgid_plural " improved on %d points"
msgstr[0] ""
msgstr[1] ""
msgid " or " msgid " or "
msgstr "" msgstr ""
...@@ -39986,7 +39973,13 @@ msgstr "" ...@@ -39986,7 +39973,13 @@ msgstr ""
msgid "ciReport|Cluster Image Scanning" msgid "ciReport|Cluster Image Scanning"
msgstr "" msgstr ""
msgid "ciReport|Code quality" msgid "ciReport|Code quality degraded"
msgstr ""
msgid "ciReport|Code quality improved"
msgstr ""
msgid "ciReport|Code quality scanning detected %{issueCount} changes in merged results"
msgstr "" msgstr ""
msgid "ciReport|Container Scanning" msgid "ciReport|Container Scanning"
......
...@@ -60,7 +60,7 @@ describe('Grouped code quality reports app', () => { ...@@ -60,7 +60,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('should render loading text', () => { it('should render loading text', () => {
expect(findWidget().text()).toEqual('Loading codeclimate report'); expect(findWidget().text()).toEqual('Loading Code quality report');
}); });
}); });
...@@ -84,7 +84,7 @@ describe('Grouped code quality reports app', () => { ...@@ -84,7 +84,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('renders summary text', () => { it('renders summary text', () => {
expect(findWidget().text()).toContain('Code quality degraded on 1 point'); expect(findWidget().text()).toContain('Code quality degraded');
}); });
it('renders custom codequality issue body', () => { it('renders custom codequality issue body', () => {
...@@ -99,7 +99,7 @@ describe('Grouped code quality reports app', () => { ...@@ -99,7 +99,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('renders summary text', () => { it('renders summary text', () => {
expect(findWidget().text()).toContain('Code quality improved on 1 point'); expect(findWidget().text()).toContain('Code quality improved');
}); });
it('renders custom codequality issue body', () => { it('renders custom codequality issue body', () => {
...@@ -115,7 +115,7 @@ describe('Grouped code quality reports app', () => { ...@@ -115,7 +115,7 @@ describe('Grouped code quality reports app', () => {
it('renders summary text', () => { it('renders summary text', () => {
expect(findWidget().text()).toContain( expect(findWidget().text()).toContain(
'Code quality improved on 1 point and degraded on 1 point', 'Code quality scanning detected 2 changes in merged results',
); );
}); });
...@@ -132,7 +132,7 @@ describe('Grouped code quality reports app', () => { ...@@ -132,7 +132,7 @@ describe('Grouped code quality reports app', () => {
}); });
it('renders error text', () => { it('renders error text', () => {
expect(findWidget().text()).toContain('Failed to load codeclimate report'); expect(findWidget().text()).toContain('Failed to load Code quality report');
}); });
it('does not render a help icon', () => { it('does not render a help icon', () => {
......
...@@ -61,9 +61,9 @@ describe('Codequality reports store getters', () => { ...@@ -61,9 +61,9 @@ describe('Codequality reports store getters', () => {
it.each` it.each`
resolvedIssues | newIssues | expectedText resolvedIssues | newIssues | expectedText
${0} | ${0} | ${'No changes to code quality'} ${0} | ${0} | ${'No changes to code quality'}
${0} | ${1} | ${'Code quality degraded on 1 point'} ${0} | ${1} | ${'Code quality degraded'}
${2} | ${0} | ${'Code quality improved on 2 points'} ${2} | ${0} | ${'Code quality improved'}
${1} | ${2} | ${'Code quality improved on 1 point and degraded on 2 points'} ${1} | ${2} | ${'Code quality scanning detected 3 changes in merged results'}
`( `(
'returns a summary containing $resolvedIssues resolved issues and $newIssues new issues', 'returns a summary containing $resolvedIssues resolved issues and $newIssues new issues',
({ newIssues, resolvedIssues, expectedText }) => { ({ newIssues, resolvedIssues, expectedText }) => {
......
...@@ -23,7 +23,7 @@ describe('Report section', () => { ...@@ -23,7 +23,7 @@ describe('Report section', () => {
const defaultProps = { const defaultProps = {
component: '', component: '',
status: 'SUCCESS', status: 'SUCCESS',
loadingText: 'Loading codeclimate report', loadingText: 'Loading Code Quality report',
errorText: 'foo', errorText: 'foo',
successText: 'Code quality improved on 1 point and degraded on 1 point', successText: 'Code quality improved on 1 point and degraded on 1 point',
resolvedIssues, resolvedIssues,
...@@ -117,13 +117,13 @@ describe('Report section', () => { ...@@ -117,13 +117,13 @@ describe('Report section', () => {
vm = mountComponent(ReportSection, { vm = mountComponent(ReportSection, {
component: '', component: '',
status: 'LOADING', status: 'LOADING',
loadingText: 'Loading codeclimate report', loadingText: 'Loading Code Quality report',
errorText: 'foo', errorText: 'foo',
successText: 'Code quality improved on 1 point and degraded on 1 point', successText: 'Code quality improved on 1 point and degraded on 1 point',
hasIssues: false, hasIssues: false,
}); });
expect(vm.$el.textContent.trim()).toEqual('Loading codeclimate report'); expect(vm.$el.textContent.trim()).toEqual('Loading Code Quality report');
}); });
}); });
...@@ -229,13 +229,13 @@ describe('Report section', () => { ...@@ -229,13 +229,13 @@ describe('Report section', () => {
vm = mountComponent(ReportSection, { vm = mountComponent(ReportSection, {
component: '', component: '',
status: 'ERROR', status: 'ERROR',
loadingText: 'Loading codeclimate report', loadingText: 'Loading Code Quality report',
errorText: 'Failed to load codeclimate report', errorText: 'Failed to load Code Quality report',
successText: 'Code quality improved on 1 point and degraded on 1 point', successText: 'Code quality improved on 1 point and degraded on 1 point',
hasIssues: false, hasIssues: false,
}); });
expect(vm.$el.textContent.trim()).toEqual('Failed to load codeclimate report'); expect(vm.$el.textContent.trim()).toEqual('Failed to load Code Quality report');
}); });
}); });
......
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