]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21259 Update QG overview measure cards design
authorstanislavh <stanislav.honcharov@sonarsource.com>
Thu, 14 Dec 2023 15:15:09 +0000 (16:15 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 19 Dec 2023 20:02:54 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/overview/components/BranchQualityGateConditions.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCard.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardNumber.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPanel.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/MeasuresCardPercent.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/PullRequestOverview-it.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 957a43f72b18fdd3441686b4bcfebe72c7a3464c..5520b9d4489ce14d4817a110d8004ed1ddb04d3a 100644 (file)
@@ -80,7 +80,7 @@ function FailedQGCondition(
 
   return (
     <StyledConditionButton className="sw-px-3 sw-py-2 sw-rounded-1 sw-body-sm" to={url}>
-      <Badge className="sw-mr-2" variant="deleted">
+      <Badge className="sw-mr-2 sw-px-1" variant="deleted">
         {translate('overview.measures.failed_badge')}
       </Badge>
       <SpanDanger>
index ae195fceafd70205d3d61b64d0c99ffeb565e295..8b451ab348e414edac49138eb65e8a1b68af03b8 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import styled from '@emotion/styled';
-import { Badge, Card, ContentLink, themeColor } from 'design-system';
+import { Badge, Card, ContentLink, themeBorder, themeColor } from 'design-system';
 import * as React from 'react';
 import { To } from 'react-router-dom';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
@@ -40,42 +40,40 @@ export default function MeasuresCard(
   const { failed, children, metric, icon, value, url, label, ...rest } = props;
 
   return (
-    <Card
-      className="sw-h-fit sw-p-8 sw-rounded-2 sw-flex sw-justify-between sw-items-center sw-text-base"
-      {...rest}
-    >
-      <div className="sw-flex sw-flex-col sw-gap-1 sw-justify-between">
-        <div className="sw-flex sw-items-center sw-gap-2 sw-font-semibold">
-          {value ? (
-            <ContentLink
-              aria-label={translateWithParameters(
-                'overview.see_more_details_on_x_of_y',
-                value,
-                localizeMetric(metric),
-              )}
-              className="it__overview-measures-value sw-text-lg"
-              to={url}
-            >
-              {value}
-            </ContentLink>
-          ) : (
-            <StyledNoValue> — </StyledNoValue>
-          )}
-          {translate(label)}
-          {failed && (
-            <Badge className="sw-mt-1/2" variant="deleted">
-              {translate('overview.measures.failed_badge')}
-            </Badge>
-          )}
-        </div>
-        {children && <div className="sw-flex sw-flex-col">{children}</div>}
+    <StyledCard className="sw-h-fit sw-p-6 sw-rounded-2 sw-text-base" {...rest}>
+      <ColorBold className="sw-body-sm-highlight">{translate(label)}</ColorBold>
+      {failed && (
+        <Badge className="sw-mt-1/2 sw-px-1 sw-ml-2" variant="deleted">
+          {translate('overview.measures.failed_badge')}
+        </Badge>
+      )}
+      <div className="sw-flex sw-items-center sw-mt-1 sw-justify-between sw-font-semibold">
+        {value ? (
+          <ContentLink
+            aria-label={translateWithParameters(
+              'overview.see_more_details_on_x_of_y',
+              value,
+              localizeMetric(metric),
+            )}
+            className="it__overview-measures-value sw-text-lg"
+            to={url}
+          >
+            {value}
+          </ContentLink>
+        ) : (
+          <ColorBold> — </ColorBold>
+        )}
+        {icon}
       </div>
-
-      {icon && <div>{icon}</div>}
-    </Card>
+      {children && <div className="sw-flex sw-flex-col">{children}</div>}
+    </StyledCard>
   );
 }
 
-const StyledNoValue = styled.span`
+const StyledCard = styled(Card)`
+  border: ${themeBorder('default')};
+`;
+
+const ColorBold = styled.span`
   color: ${themeColor('pageTitle')};
 `;
index 7f905c97b9eddfcb49d664ffcebaf95176141633..6ab310bb289a0ac4fd434cb48caf52dd46d8c3ee 100644 (file)
@@ -70,12 +70,14 @@ export default function MeasuresCardNumber(
       data-guiding-id={conditionFailed ? guidingKeyOnError : undefined}
       {...rest}
     >
-      {requireLabel &&
-        (conditionFailed ? (
-          <TextError className="sw-mt-2 sw-font-regular" text={requireLabel} />
-        ) : (
-          <LightLabel className="sw-mt-2">{requireLabel}</LightLabel>
-        ))}
+      <span className="sw-body-xs sw-mt-3">
+        {requireLabel &&
+          (conditionFailed ? (
+            <TextError className="sw-font-regular" text={requireLabel} />
+          ) : (
+            <LightLabel>{requireLabel}</LightLabel>
+          ))}
+      </span>
     </MeasuresCard>
   );
 }
index 5f116e4c8228ecff30a7260fd5fad98124387395..68eb13cebb398baf09d433719e7f1156f9317cd9 100644 (file)
@@ -116,7 +116,7 @@ export default function MeasuresCardPanel(props: React.PropsWithChildren<Props>)
           conditions={conditions}
           conditionMetric={MetricKey.new_duplicated_lines_density}
           newLinesMetric={MetricKey.new_lines}
-          afterMergeMetric={MetricKey.duplicated_lines_density}
+          afterMergeMetric={MetricKey.coverage}
           measures={measures}
         />
       </div>
index a7a9a16172ab55e5ec81417f18d00b63fa528caa..8998e9e32a342940f5a3597069d7be2a4accf1da 100644 (file)
@@ -113,46 +113,49 @@ export default function MeasuresCardPercent(
       icon={renderIcon(measurementType, value)}
     >
       <>
-        {requireLabel &&
-          (conditionFailed ? (
-            <TextError className="sw-mt-2 sw-font-regular" text={requireLabel} />
-          ) : (
-            <LightLabel className="sw-mt-2">{requireLabel}</LightLabel>
-          ))}
+        <span className="sw-body-xs sw-mt-3">
+          {requireLabel &&
+            (conditionFailed ? (
+              <TextError className="sw-font-regular" text={requireLabel} />
+            ) : (
+              <LightLabel>{requireLabel}</LightLabel>
+            ))}
+        </span>
 
-        <LightLabel className="sw-flex sw-items-center sw-gap-1 sw-mt-4">
-          <FormattedMessage
-            defaultMessage={translate(newLinesLabel)}
-            id={newLinesLabel}
-            values={{
-              link: (
-                <ContentLink
-                  aria-label={translateWithParameters(
-                    'overview.see_more_details_on_x_y',
-                    newLinesValue ?? '0',
-                    localizeMetric(newLinesMetric),
-                  )}
-                  className="sw-body-md-highlight sw-text-lg"
-                  to={newLinesUrl}
-                >
-                  {formatMeasure(newLinesValue ?? '0', MetricType.ShortInteger)}
-                </ContentLink>
-              ),
-            }}
-          />
-        </LightLabel>
-
-        {afterMergeValue && (
-          <LightLabel className="sw-mt-2">
+        <div className="sw-flex sw-justify-between sw-items-center sw-mt-1">
+          <LightLabel className="sw-flex sw-items-center sw-gap-1 ">
             <FormattedMessage
-              defaultMessage={translate('overview.quality_gate.x_estimated_after_merge')}
-              id="overview.quality_gate.x_estimated_after_merge"
+              defaultMessage={translate(newLinesLabel)}
+              id={newLinesLabel}
               values={{
-                value: <strong>{formatMeasure(afterMergeValue, MetricType.Percent)}</strong>,
+                link: (
+                  <ContentLink
+                    aria-label={translateWithParameters(
+                      'overview.see_more_details_on_x_y',
+                      newLinesValue ?? '0',
+                      localizeMetric(newLinesMetric),
+                    )}
+                    className="sw-body-md-highlight sw-text-lg"
+                    to={newLinesUrl}
+                  >
+                    {formatMeasure(newLinesValue ?? '0', MetricType.ShortInteger)}
+                  </ContentLink>
+                ),
               }}
             />
           </LightLabel>
-        )}
+          <LightLabel className="sw-mt-[1px]">
+            {afterMergeValue && (
+              <FormattedMessage
+                defaultMessage={translate('overview.quality_gate.x_estimated_after_merge')}
+                id="overview.quality_gate.x_estimated_after_merge"
+                values={{
+                  value: <strong>{formatMeasure(afterMergeValue, MetricType.Percent)}</strong>,
+                }}
+              />
+            )}
+          </LightLabel>
+        </div>
       </>
     </MeasuresCard>
   );
index 2755d3b3abfdeca5ccbdde84d24e18762e73b754..f1c6157a6e0d165260ab42ae1f64b85f4ccff70c 100644 (file)
@@ -180,12 +180,12 @@ it('should render correctly for a failed QG', async () => {
 
   expect(
     byRole('link', {
-      name: 'overview.measures.failed_badge overview.failed_condition.x_required 10.0% duplicated_lines ≤ 1.0%',
+      name: 'overview.measures.failed_badge overview.failed_condition.x_required 10.0% duplicated_lines≤ 1.0%',
     }).get(),
   ).toBeInTheDocument();
   expect(
     byRole('link', {
-      name: 'overview.measures.failed_badge overview.failed_condition.x_required 10 new_bugs ≤ 3',
+      name: 'overview.measures.failed_badge overview.failed_condition.x_required 10 new_bugs≤ 3',
     }).get(),
   ).toBeInTheDocument();
 });
index 577e4ae1554ea99dca088a05527f2c1280b063ca..d7af0cf37d262b894f5970cf7a82240d059058a2 100644 (file)
@@ -3831,8 +3831,8 @@ overview.quality_gate.show_project_conditions_x=Show failed conditions for proje
 overview.quality_gate.hide_project_conditions_x=Hide failed conditions for project {0}
 overview.quality_gate.coverage=Coverage
 overview.quality_gate.duplications=Duplications
-overview.quality_gate.on_x_new_lines_to_cover=On {link} New Lines to cover
-overview.quality_gate.on_x_new_lines=On {link} New Lines
+overview.quality_gate.on_x_new_lines_to_cover=On {link} New Lines to cover.
+overview.quality_gate.on_x_new_lines=On {link} New Lines.
 overview.quality_gate.x_estimated_after_merge={value} Estimated after merge
 overview.quality_gate.require_fixing={count, plural, one {requires} other {require}} fixing
 overview.quality_gate.require_reviewing={count, plural, one {requires} other {require}} reviewing