]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21115 Improve the spotlight tour on Quality Gate page
authorMathieu Suen <mathieu.suen@sonarsource.com>
Mon, 4 Dec 2023 15:56:31 +0000 (16:56 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 8 Dec 2023 20:03:04 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/quality-gates/components/CaYCConditionsSimplificationGuide.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/CaycCondition.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/CaycConditionsTable.tsx [deleted file]
server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/QualityGate-it.tsx
server/sonar-web/src/main/js/apps/quality-gates/styles.css
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index bfd84a3db0f8ad02ea1598783bffac2201e956d1..0a8cb6b2fa6e76cf64cfe2bf016b100d76020f31 100644 (file)
@@ -34,7 +34,7 @@ export default function CaYCConditionsSimplificationGuide() {
 
   const steps: SpotlightTourStep[] = [
     {
-      target: '#cayc-hihlight',
+      target: '#cayc-highlight',
       content: (
         <p>{translate('quality_gates.cayc.condition_simplification_tour.page_1.content1')}</p>
       ),
index 08895159b6b301029bf908ca768aff32e40bbd5a..da15699047537f43f4958ccb48f33c64230e1235 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import styled from '@emotion/styled';
-import { ContentCell, HelperHintIcon, Highlight, TableRow } from 'design-system';
+import { HelperHintIcon, Highlight } from 'design-system';
 import React from 'react';
 import { FormattedMessage } from 'react-intl';
 import withMetricsContext from '../../../app/components/metrics/withMetricsContext';
@@ -44,17 +44,18 @@ function CaycCondition({ condition, metric, metrics }: Readonly<Props>) {
   };
 
   return (
-    <StyledTableRow>
-      <ContentCell
-        data-guiding-id={
-          condition.metric === MetricKey.new_violations ? 'caycConditionsSimplification' : undefined
-        }
-      >
+    <StyledItem
+      data-guiding-id={
+        condition.metric === MetricKey.new_violations ? 'caycConditionsSimplification' : undefined
+      }
+    >
+      <span>
         <Highlight>{translate(`metric.${metric.key}.description.positive`)}</Highlight>
-      </ContentCell>
+      </span>
 
-      <StyledContentCell>
-        {shouldRenderOperator && (
+      {shouldRenderOperator && (
+        <StyledContentCell>
+          (
           <>
             <FormattedMessage
               id="quality_gates.conditions.cayc.metric"
@@ -72,22 +73,34 @@ function CaycCondition({ condition, metric, metrics }: Readonly<Props>) {
               <HelperHintIcon />
             </DocumentationTooltip>
           </>
-        )}
-      </StyledContentCell>
-    </StyledTableRow>
+          )
+        </StyledContentCell>
+      )}
+    </StyledItem>
   );
 }
 
-const StyledTableRow = styled(TableRow)`
-  &:first-child > td {
-    border-top: 0;
+const StyledItem = styled.li`
+  display: flex;
+  justify-content: space-between;
+  padding: 1rem;
+  flex-wrap: wrap;
+
+  &:not(:last-child) {
+    padding-bottom: 0;
   }
-  &:last-child > td {
-    border-bottom: 0;
+
+  &:not(:last-child):after {
+    content: '';
+    border-bottom: 1px solid rgb(235, 235, 235);
+    display: flex;
+    height: 10px;
+    width: 100%;
+    padding-top: 1rem;
   }
 `;
 
-const StyledContentCell = styled(ContentCell)`
+const StyledContentCell = styled.div`
   white-space: nowrap;
 
   & > div {
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CaycConditionsTable.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CaycConditionsTable.tsx
deleted file mode 100644 (file)
index a5bbb25..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-import { HighlightedSection, Table } from 'design-system';
-import * as React from 'react';
-import { Condition as ConditionType, Dict, Metric } from '../../../types/types';
-import CaycCondition from './CaycCondition';
-
-interface Props {
-  metrics: Dict<Metric>;
-  conditions: ConditionType[];
-}
-
-export default function CaycConditionsTable({ metrics, conditions }: Readonly<Props>) {
-  return (
-    <HighlightedSection className="sw-px-4 sw-py-0 sw-my-2" id="cayc-hihlight">
-      <Table
-        columnCount={2}
-        columnWidths={['auto', '1fr']}
-        className="sw-my-2"
-        data-testid="quality-gates__conditions-cayc"
-      >
-        {conditions.map((condition) => (
-          <CaycCondition
-            key={condition.id}
-            condition={condition}
-            metric={metrics[condition.metric]}
-          />
-        ))}
-      </Table>
-    </HighlightedSection>
-  );
-}
index 3278266849795bd0face14f392958b69a8856c72..b814be6f7c260fb17593037b30e249ad5bb5a4f0 100644 (file)
@@ -23,6 +23,7 @@ import {
   FlagMessage,
   HeadingDark,
   HelperHintIcon,
+  HighlightedSection,
   LightPrimary,
   Link,
   Note,
@@ -43,7 +44,7 @@ import { CaycStatus, Condition as ConditionType, QualityGate } from '../../../ty
 import { groupAndSortByPriorityConditions, isQualityGateOptimized } from '../utils';
 import CaYCConditionsSimplificationGuide from './CaYCConditionsSimplificationGuide';
 import CaycCompliantBanner from './CaycCompliantBanner';
-import CaycConditionsTable from './CaycConditionsTable';
+import CaycCondition from './CaycCondition';
 import CaycFixOptimizeBanner from './CaycFixOptimizeBanner';
 import ConditionModal from './ConditionModal';
 import CaycReviewUpdateConditionsModal from './ConditionReviewAndUpdateModal';
@@ -215,7 +216,20 @@ export default function Conditions({ qualityGate }: Readonly<Props>) {
               </DocumentationTooltip>
             </div>
 
-            <CaycConditionsTable metrics={metrics} conditions={caycConditions} />
+            <HighlightedSection className="sw-p-0 sw-my-2 sw-w-3/4" id="cayc-highlight">
+              <ul
+                className="sw-my-2"
+                aria-label={translate('quality_gates.cayc.condition_simplification_list')}
+              >
+                {caycConditions.map((condition) => (
+                  <CaycCondition
+                    key={condition.id}
+                    condition={condition}
+                    metric={metrics[condition.metric]}
+                  />
+                ))}
+              </ul>
+            </HighlightedSection>
 
             {hasFeature(Feature.BranchSupport) && (
               <Note className="sw-mb-2 sw-body-sm">
index 90602910f361697fba5693a7ada29d27a35de59b..c45eb67777913aa1f9f91dbe549fb71c83f0850a 100644 (file)
@@ -483,7 +483,9 @@ it('should render CaYC conditions on a separate table if Sonar way', async () =>
   await user.click(await screen.findByText('Sonar way'));
 
   expect(screen.queryByText('quality_gates.cayc.banner.title')).not.toBeInTheDocument();
-  expect(await screen.findByTestId('quality-gates__conditions-cayc')).toBeInTheDocument();
+  expect(
+    await screen.findByRole('list', { name: 'quality_gates.cayc.condition_simplification_list' }),
+  ).toBeInTheDocument();
 });
 
 it('should display CaYC condition simplification tour for users who didnt dismissed it', async () => {
index 966eec709dc7816095f1e6cb7e9179abf8717336..718c024d839d4bfa0b16fe1beca3e402d6bd9193 100644 (file)
@@ -88,3 +88,8 @@
 .strike-through {
   text-decoration: line-through;
 }
+
+#cayc-highlight.active,
+[data-guiding-id='caycConditionsSimplification'].active {
+  box-shadow: 0px 0px 4px 0px #5d6cd0;
+}
index c68ef607cc079d6b174a753265720a7946e7d55d..a03c68331d364d46b34607ce1d2adc58a372dc73 100644 (file)
@@ -2245,6 +2245,7 @@ quality_gates.cayc_condition.review_optimize=Review and Optimize Quality Gate
 quality_gates.cayc.review_optimize_modal.header=Optimize "{0}" for Clean as You Code
 quality_gates.cayc.review_optimize_modal.confirm_text=Optimize Quality Gate
 quality_gates.cayc.review_optimize_modal.description1=This quality gate will be optimized for {cayc_link}. Please review the changes below.
+quality_gates.cayc.condition_simplification_list=List of conditions to ensure that any code added or changed is clean.
 quality_gates.cayc.condition_simplification_tour.page_1.title='Clean as You Code' ready!
 quality_gates.cayc.condition_simplification_tour.page_1.content1=The conditions in this quality gate have been updated to ensure that any code added or changed is clean.
 quality_gates.cayc.condition_simplification_tour.page_2.title=One condition, zero issues