]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19157 Remove (s) for 1 failed condition
authorDavid Cho-Lerat <david.cho-lerat@sonarsource.com>
Wed, 26 Jul 2023 10:16:57 +0000 (12:16 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 26 Jul 2023 20:03:24 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx
server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx
server/sonar-web/src/main/js/apps/overview/components/QualityGateStatusHeader.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 4461066dd24634061e03755caf6b6cc54e59bcca..f6cb093a55981a0ec2f43b95e3593fc9d8c0e158 100644 (file)
@@ -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>
index e557ea0f5260c3db39ce21292c397f2ed290c8df..daed4ad5e35cbdec04cd1eb934edd194a7baf75b 100644 (file)
  * 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 />
index bfe09a00d978f80aedf5fddfed6242e628d7b0f0..a81638a29cd93ba5e4eb376a230b108761998d8b 100644 (file)
@@ -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>
index 2fc7369e30c5fe38461f37be014c666edb5a3cdf..40508094631c53d9d42d26c8128a802162d21585 100644 (file)
@@ -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