Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js')
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js34
1 files changed, 20 insertions, 14 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js b/app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js
index 394f8979a53..4f9bba1e0cb 100644
--- a/app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js
+++ b/app/assets/javascripts/vue_merge_request_widget/extensions/code_quality/index.js
@@ -4,7 +4,7 @@ import { SEVERITY_ICONS_MR_WIDGET } from '~/ci/reports/codequality_report/consta
import { HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status';
import { parseCodeclimateMetrics } from '~/ci/reports/codequality_report/store/utils/codequality_parser';
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
-import { i18n } from './constants';
+import { i18n, codeQualityPrefixes } from './constants';
export default {
name: 'WidgetCodeQuality',
@@ -12,28 +12,36 @@ export default {
props: ['codeQuality', 'blobPath'],
i18n,
computed: {
+ shouldCollapse(data) {
+ const { newErrors, resolvedErrors, parsingInProgress } = data;
+ if (parsingInProgress || (newErrors.length === 0 && resolvedErrors.length === 0)) {
+ return false;
+ }
+ return true;
+ },
summary(data) {
- const { newErrors, resolvedErrors, errorSummary, parsingInProgress } = data;
-
+ const { newErrors, resolvedErrors, parsingInProgress } = data;
if (parsingInProgress) {
return i18n.loading;
- } else if (errorSummary.errored >= 1 && errorSummary.resolved >= 1) {
+ } else if (newErrors.length >= 1 && resolvedErrors.length >= 1) {
return i18n.improvementAndDegradationCopy(
- i18n.pluralReport(resolvedErrors),
- i18n.pluralReport(newErrors),
+ i18n.findings(resolvedErrors, codeQualityPrefixes.fixed),
+ i18n.findings(newErrors, codeQualityPrefixes.new),
);
- } else if (errorSummary.resolved >= 1) {
- return i18n.improvedCopy(i18n.singularReport(resolvedErrors));
- } else if (errorSummary.errored >= 1) {
- return i18n.degradedCopy(i18n.singularReport(newErrors));
+ } else if (resolvedErrors.length >= 1) {
+ return i18n.singularCopy(i18n.findings(resolvedErrors, codeQualityPrefixes.fixed));
+ } else if (newErrors.length >= 1) {
+ return i18n.singularCopy(i18n.findings(newErrors, codeQualityPrefixes.new));
}
return i18n.noChanges;
},
statusIcon() {
- if (this.collapsedData.errorSummary?.errored >= 1) {
+ if (this.collapsedData.newErrors.length >= 1) {
return EXTENSION_ICONS.warning;
+ } else if (this.collapsedData.resolvedErrors.length >= 1) {
+ return EXTENSION_ICONS.success;
}
- return EXTENSION_ICONS.success;
+ return EXTENSION_ICONS.neutral;
},
},
methods: {
@@ -46,8 +54,6 @@ export default {
parsingInProgress: status === HTTP_STATUS_NO_CONTENT,
resolvedErrors: parseCodeclimateMetrics(data.resolved_errors, this.blobPath.head_path),
newErrors: parseCodeclimateMetrics(data.new_errors, this.blobPath.head_path),
- existingErrors: parseCodeclimateMetrics(data.existing_errors, this.blobPath.head_path),
- errorSummary: data.summary,
},
};
});