diff options
author | David Cho-Lerat <david.cho-lerat@sonarsource.com> | 2023-07-26 12:16:57 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-07-26 20:03:24 +0000 |
commit | e55ae17ee70289d4d53a011c94b4ce58a77543fa (patch) | |
tree | fe98fc27bffaa8e54c2d8fe39a2ca8bef138dc17 | |
parent | 40f4d52838c974e2a22336c2cea8e087d9f9e558 (diff) | |
download | sonarqube-e55ae17ee70289d4d53a011c94b4ce58a77543fa.tar.gz sonarqube-e55ae17ee70289d4d53a011c94b4ce58a77543fa.zip |
SONAR-19157 Remove (s) for 1 failed condition
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) { <ToggleButton onChange={(key) => selectTab(key)} options={tabs} value={tab} /> {failingConditions > 0 && ( <LightLabel className="sw-body-sm-highlight sw-ml-8"> - {translateWithParameters('overview.X_conditions_failed', failingConditions)} + {failingConditions === 1 + ? translate('overview.1_condition_failed') + : translateWithParameters('overview.X_conditions_failed', failingConditions)} </LightLabel> )} </div> 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 && ( <> - <p className="sw-px-2 sw-py-3"> - {translateWithParameters( - 'quality_gates.conditions.new_code_x', - newCodeFailedConditions.length.toString() - )} - </p> + <p className="sw-px-2 sw-py-3">{newCodeText}</p> + <BasicSeparator /> </> )} + <QualityGateConditions component={qgStatus} branchLike={qgStatus.branchLike} @@ -118,15 +132,12 @@ export function QualityGatePanelSection(props: QualityGatePanelSectionProps) { <> {showSectionTitles && ( <> - <p className="sw-px-2 sw-py-3"> - {translateWithParameters( - 'quality_gates.conditions.overall_code_x', - overallFailedConditions.length.toString() - )} - </p> + <p className="sw-px-2 sw-py-3">{overallText}</p> + <BasicSeparator /> </> )} + <QualityGateConditions component={qgStatus} branchLike={qgStatus.branchLike} @@ -149,26 +160,19 @@ export function QualityGatePanelSection(props: QualityGatePanelSectionProps) { header={ <div className="sw-flex sw-flex-col sw-text-sm"> <span className="sw-body-sm-highlight">{qgStatus.name}</span> + {collapsed && newCodeFailedConditions.length > 0 && ( - <TextMuted - text={translateWithParameters( - 'quality_gates.conditions.new_code_x', - newCodeFailedConditions.length - )} - /> + <TextMuted text={newCodeText} /> )} + {collapsed && overallFailedConditions.length > 0 && ( - <TextMuted - text={translateWithParameters( - 'quality_gates.conditions.overall_code_x', - overallFailedConditions.length - )} - /> + <TextMuted text={overallText} /> )} </div> } > <BasicSeparator /> + {renderFailedConditions()} </Accordion> <BasicSeparator /> 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) { <div className="sw-flex sw-flex-1 sw-justify-end"> {failedConditionCount > 0 && ( <TextError - text={translateWithParameters('overview.X_conditions_failed', failedConditionCount)} + text={ + failedConditionCount === 1 + ? translate('overview.1_condition_failed') + : translateWithParameters('overview.X_conditions_failed', failedConditionCount) + } /> )} </div> 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 |