From e55ae17ee70289d4d53a011c94b4ce58a77543fa Mon Sep 17 00:00:00 2001 From: David Cho-Lerat Date: Wed, 26 Jul 2023 12:16:57 +0200 Subject: [PATCH] SONAR-19157 Remove (s) for 1 failed condition --- .../apps/overview/branches/MeasuresPanel.tsx | 5 +- .../branches/QualityGatePanelSection.tsx | 54 ++++++++++--------- .../components/QualityGateStatusHeader.tsx | 6 ++- .../resources/org/sonar/l10n/core.properties | 9 ++-- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx index 4461066dd24..f6cb093a559 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + import { Card, CoverageIndicator, @@ -135,7 +136,9 @@ export function MeasuresPanel(props: MeasuresPanelProps) { selectTab(key)} options={tabs} value={tab} /> {failingConditions > 0 && ( - {translateWithParameters('overview.X_conditions_failed', failingConditions)} + {failingConditions === 1 + ? translate('overview.1_condition_failed') + : translateWithParameters('overview.X_conditions_failed', failingConditions)} )} diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx index e557ea0f526..daed4ad5e35 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + import { Accordion, BasicSeparator, TextMuted } from 'design-system'; import * as React from 'react'; -import { translateWithParameters } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; import { isDiffMetric } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { isApplication } from '../../../types/component'; @@ -90,6 +91,22 @@ export function QualityGatePanelSection(props: QualityGatePanelSectionProps) { ? translateWithParameters('overview.quality_gate.show_project_conditions_x', qgStatus.name) : translateWithParameters('overview.quality_gate.hide_project_conditions_x', qgStatus.name); + const newCodeText = + newCodeFailedConditions.length === 1 + ? translate('quality_gates.conditions.new_code_1') + : translateWithParameters( + 'quality_gates.conditions.new_code_x', + newCodeFailedConditions.length.toString() + ); + + const overallText = + overallFailedConditions.length === 1 + ? translate('quality_gates.conditions.overall_code_1') + : translateWithParameters( + 'quality_gates.conditions.overall_code_x', + overallFailedConditions.length.toString() + ); + const renderFailedConditions = () => { return ( <> @@ -97,15 +114,12 @@ export function QualityGatePanelSection(props: QualityGatePanelSectionProps) { <> {showSectionTitles && ( <> -

- {translateWithParameters( - 'quality_gates.conditions.new_code_x', - newCodeFailedConditions.length.toString() - )} -

+

{newCodeText}

+ )} + {showSectionTitles && ( <> -

- {translateWithParameters( - 'quality_gates.conditions.overall_code_x', - overallFailedConditions.length.toString() - )} -

+

{overallText}

+ )} + {qgStatus.name} + {collapsed && newCodeFailedConditions.length > 0 && ( - + )} + {collapsed && overallFailedConditions.length > 0 && ( - + )} } > + {renderFailedConditions()} diff --git a/server/sonar-web/src/main/js/apps/overview/components/QualityGateStatusHeader.tsx b/server/sonar-web/src/main/js/apps/overview/components/QualityGateStatusHeader.tsx index bfe09a00d97..a81638a29cd 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/QualityGateStatusHeader.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/QualityGateStatusHeader.tsx @@ -45,7 +45,11 @@ export default function QualityGateStatusHeader(props: Props) {
{failedConditionCount > 0 && ( )}
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 2fc7369e30c..40508094631 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2020,11 +2020,13 @@ quality_gates.conditions.metric=Metric quality_gates.conditions.new_code=On New Code quality_gates.conditions.new_code.long=Conditions on New Code quality_gates.conditions.new_code.description=Conditions on New Code apply to all branches and to Pull Requests. -quality_gates.conditions.new_code_x={0} condition(s) failed on new code +quality_gates.conditions.new_code_1=1 condition failed on new code +quality_gates.conditions.new_code_x={0} conditions failed on new code quality_gates.conditions.overall_code=On Overall Code quality_gates.conditions.overall_code.long=Conditions on Overall Code quality_gates.conditions.overall_code.description=Conditions on Overall Code apply to branches only. -quality_gates.conditions.overall_code_x={0} condition(s) failed on overall code +quality_gates.conditions.overall_code_1=1 condition failed on overall code +quality_gates.conditions.overall_code_x={0} conditions failed on overall code quality_gates.conditions.operator=Operator quality_gates.conditions.warning=Warning quality_gates.conditions.warning.tooltip=Warning status is deprecated and will disappear with the next update of the Quality Gate. @@ -3498,7 +3500,8 @@ system.version_is_availble={version} is available # OVERVIEW # #------------------------------------------------------------------------------ -overview.X_conditions_failed={0} failed condition(s) +overview.1_condition_failed=1 failed condition +overview.X_conditions_failed={0} failed conditions overview.fix_failed_conditions_with_sonarlint=Fix issues before they fail your Quality Gate with {link} in your IDE. Power up with connected mode! overview.quality_gate.status=Quality Gate Status overview.quality_gate=Quality Gate -- 2.39.5