]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19345 Adapt issues education tabs to the new design system (#8349)
authorAmbroise C <ambroise.christea@sonarsource.com>
Fri, 26 May 2023 08:54:39 +0000 (10:54 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 9 Jun 2023 20:03:09 +0000 (20:03 +0000)
server/sonar-web/design-system/src/components/icons/index.ts
server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts
server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx
server/sonar-web/src/main/js/components/rules/OtherContextOption.tsx
server/sonar-web/src/main/js/components/rules/RuleDescription.tsx

index b811ad0071dca111d3aeb373557b098c31f18e99..d81089a367a90d35d5e93d2d59df8fc1d51bf6d0 100644 (file)
 export { BranchIcon } from './BranchIcon';
 export { BugIcon } from './BugIcon';
 export { CalendarIcon } from './CalendarIcon';
+export { CheckIcon } from './CheckIcon';
 export { ChevronDownIcon } from './ChevronDownIcon';
 export { ChevronLeftIcon } from './ChevronLeftIcon';
 export { ChevronRightIcon } from './ChevronRightIcon';
 export { ClockIcon } from './ClockIcon';
+export { CloseIcon } from './CloseIcon';
 export { CodeSmellIcon } from './CodeSmellIcon';
 export { CommentIcon } from './CommentIcon';
 export { CopyIcon } from './CopyIcon';
index 5556b269f63ac70abc549257c6502a8e3c79deb1..75ce058a6f9dc258e780c047091261f5805b24b2 100644 (file)
@@ -163,21 +163,21 @@ it('should show rule advanced section with context', async () => {
       name: 'coding_rules.description_section.title.how_to_fix',
     })
   );
-  expect(screen.getByRole('button', { name: 'Spring' })).toBeInTheDocument();
-  expect(screen.getByRole('button', { name: 'Spring boot' })).toBeInTheDocument();
+  expect(screen.getByRole('radio', { name: 'Spring' })).toBeInTheDocument();
+  expect(screen.getByRole('radio', { name: 'Spring boot' })).toBeInTheDocument();
   expect(
-    screen.getByRole('button', { name: 'coding_rules.description_context.other' })
+    screen.getByRole('radio', { name: 'coding_rules.description_context.other' })
   ).toBeInTheDocument();
   expect(screen.getByText('coding_rules.description_context.sub_title.Spring')).toBeInTheDocument();
   expect(screen.getByText('This is how to fix for spring')).toBeInTheDocument();
 
-  await user.click(screen.getByRole('button', { name: 'Spring boot' }));
+  await user.click(screen.getByRole('radio', { name: 'Spring boot' }));
   expect(
     screen.getByText('coding_rules.description_context.sub_title.Spring boot')
   ).toBeInTheDocument();
   expect(screen.getByText('This is how to fix for spring boot')).toBeInTheDocument();
 
-  await user.click(screen.getByRole('button', { name: 'coding_rules.description_context.other' }));
+  await user.click(screen.getByRole('radio', { name: 'coding_rules.description_context.other' }));
   expect(
     screen.queryByText(
       'coding_rules.description_context.sub_title.coding_rules.description_context.other'
@@ -187,7 +187,7 @@ it('should show rule advanced section with context', async () => {
   expect(screen.getByText('coding_rules.context.others.description.first')).toBeInTheDocument();
 
   const productBoardLink = screen.getByRole('link', {
-    name: 'opens_in_new_window coding_rules.context.others.feedback_description.link',
+    name: 'coding_rules.context.others.feedback_description.link',
   });
   expect(productBoardLink).toBeInTheDocument();
   expect(productBoardLink).toHaveAttribute('target', '_blank');
index f501e8d97f1048f911f3b18ae66a98b22cb22a85..34de8e4547d53dc9e3da0521b4bf0d3ce437c391 100644 (file)
@@ -136,21 +136,21 @@ describe('issues app', () => {
       );
 
       // Is the context selector present with the expected values and default selection?
-      expect(screen.getByRole('button', { name: 'Context 2' })).toBeInTheDocument();
-      expect(screen.getByRole('button', { name: 'Context 3' })).toBeInTheDocument();
-      expect(screen.getByRole('button', { name: 'Spring' })).toBeInTheDocument();
+      expect(screen.getByRole('radio', { name: 'Context 2' })).toBeInTheDocument();
+      expect(screen.getByRole('radio', { name: 'Context 3' })).toBeInTheDocument();
+      expect(screen.getByRole('radio', { name: 'Spring' })).toBeInTheDocument();
       expect(
-        screen.getByRole('button', { name: 'coding_rules.description_context.other' })
+        screen.getByRole('radio', { name: 'coding_rules.description_context.other' })
       ).toBeInTheDocument();
-      expect(screen.getByRole('button', { name: 'Spring' })).toHaveClass('selected');
+      expect(screen.getByRole('radio', { name: 'Spring', current: true })).toBeInTheDocument();
 
       // Select context 2 and check tab content
-      await user.click(screen.getByRole('button', { name: 'Context 2' }));
+      await user.click(screen.getByRole('radio', { name: 'Context 2' }));
       expect(screen.getByText('Context 2 content')).toBeInTheDocument();
 
       // Select the "other" context and check tab content
       await user.click(
-        screen.getByRole('button', { name: 'coding_rules.description_context.other' })
+        screen.getByRole('radio', { name: 'coding_rules.description_context.other' })
       );
       expect(screen.getByText('coding_rules.context.others.title')).toBeInTheDocument();
       expect(screen.getByText('coding_rules.context.others.description.first')).toBeInTheDocument();
index 0134e2892f80ad9c41d5427f73015f9d8f1d14b0..3f17a2a7510a068b565acfc7f25a799e7bff85c5 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 { CheckIcon, CloseIcon, Link } from 'design-system';
 import * as React from 'react';
 import { translate } from '../../helpers/l10n';
-import Link from '../common/Link';
-import CheckIcon from '../icons/CheckIcon';
-import ClearIcon from '../icons/ClearIcon';
 
 export default function OtherContextOption() {
   return (
@@ -30,12 +28,12 @@ export default function OtherContextOption() {
       <p>{translate('coding_rules.context.others.description.first')}</p>
       <p>{translate('coding_rules.context.others.description.second')}</p>
       <p>
-        <span className="display-block big-spacer-left">
-          <CheckIcon className="spacer-right" fill="green" />
+        <span className="sw-flex sw-items-center sw-ml-4">
+          <CheckIcon className="sw-mr-2" fill="iconSuccess" />
           {translate('coding_rules.context.others.description.do')}
         </span>
-        <span className="display-block big-spacer-left">
-          <ClearIcon className="spacer-right" fill="red" />
+        <span className="sw-flex sw-items-center sw-ml-4">
+          <CloseIcon className="sw-mr-2" fill="iconError" />
           {translate('coding_rules.context.others.description.dont')}
         </span>
       </p>
index 4d979bd2bbc1be714910058d4158fd79b953e745..582a72514036980c528579fb5f20d0641bf59442 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import styled from '@emotion/styled';
-import { HtmlFormatter, themeBorder, themeColor } from 'design-system';
+import { FlagMessage, HtmlFormatter, themeBorder, themeColor, ToggleButton } from 'design-system';
 import * as React from 'react';
 import { RuleDescriptionSection } from '../../apps/coding-rules/rule';
 import applyCodeDifferences from '../../helpers/code-difference';
 import { translate, translateWithParameters } from '../../helpers/l10n';
 import { sanitizeString } from '../../helpers/sanitize';
-import ButtonToggle from '../controls/ButtonToggle';
-import { Alert } from '../ui/Alert';
 import OtherContextOption from './OtherContextOption';
 
 const OTHERS_KEY = 'others';
@@ -122,7 +120,7 @@ export default class RuleDescription extends React.PureComponent<Props, State> {
       return (
         <StyledHtmlFormatter
           className={className}
-          ref={(node) => {
+          ref={(node: HTMLDivElement) => {
             applyCodeDifferences(node);
           }}
         >
@@ -130,17 +128,24 @@ export default class RuleDescription extends React.PureComponent<Props, State> {
             {translate('coding_rules.description_context.title')}
           </h2>
           {defaultContext && (
-            <Alert variant="info" display="inline" className="big-spacer-bottom">
+            <FlagMessage
+              variant="info"
+              className="sw-mb-4"
+              ariaLabel={translateWithParameters(
+                'coding_rules.description_context.default_information',
+                defaultContext.displayName
+              )}
+            >
               {translateWithParameters(
                 'coding_rules.description_context.default_information',
                 defaultContext.displayName
               )}
-            </Alert>
+            </FlagMessage>
           )}
-          <div className="big-spacer-bottom">
-            <ButtonToggle
+          <div className="sw-mb-4">
+            <ToggleButton
               label={translate('coding_rules.description_context.title')}
-              onCheck={this.handleToggleContext}
+              onChange={this.handleToggleContext}
               options={options}
               value={selectedContext.displayName}
             />
@@ -168,7 +173,7 @@ export default class RuleDescription extends React.PureComponent<Props, State> {
     return (
       <StyledHtmlFormatter
         className={className}
-        ref={(node) => {
+        ref={(node: HTMLDivElement) => {
           applyCodeDifferences(node);
         }}
         // eslint-disable-next-line react/no-danger