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