From 3cf94b646a3129609544f81b3aebb9b9cc512746 Mon Sep 17 00:00:00 2001 From: 7PH Date: Tue, 5 Dec 2023 14:33:44 +0100 Subject: [PATCH] SONAR-21171 Rework rule items layout and styling --- .../coding-rules/components/RuleListItem.tsx | 197 ++++++++++-------- .../src/main/js/components/tags/TagsList.tsx | 3 + 2 files changed, 118 insertions(+), 82 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index 30dec2d7c4b..b382cc6e72c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -25,6 +25,7 @@ import { InheritanceIcon, Link, OverridenIcon, + SeparatorCircleIcon, TextSubdued, themeBorder, } from 'design-system'; @@ -95,37 +96,37 @@ export default class RuleListItem extends React.PureComponent { renderActivation = () => { const { activation, selectedProfile } = this.props; - if (!activation) { + if (!activation || !selectedProfile?.parentName) { + return null; + } + + if (!['OVERRIDES', 'INHERITED'].includes(activation.inherit)) { return null; } return (
- {selectedProfile?.parentName && ( - <> - {activation.inherit === 'OVERRIDES' && ( - - - + {activation.inherit === 'OVERRIDES' && ( + - - + > + + + )} + {activation.inherit === 'INHERITED' && ( + + > + + )}
); @@ -209,75 +210,107 @@ export default class RuleListItem extends React.PureComponent { data-rule={rule.key} onClick={() => this.props.selectRule(rule.key)} > -
-
- {rule.cleanCodeAttributeCategory !== undefined && ( - - )} -
+
{this.renderActivation()} -
- + {rule.name} + +
+ +
+ {rule.cleanCodeAttributeCategory !== undefined && ( + + )} +
+
+ +
+
+ {rule.impacts.length > 0 && ( + + )} +
+ +
    +
  • {rule.langName}
  • + + +
  • + +

    {translate('coding_rules.type.deprecation.title')}

    +

    {translate('coding_rules.type.deprecation.filter_by')}

    +
+ } + links={[ + { + href: '/user-guide/clean-code', + label: translate('learn_more'), + }, + ]} > - {rule.name} - -
+ + + + + + {rule.isTemplate && ( - - - {translate('coding_rules.rule_template')} - - + <> + +
  • + + + {translate('coding_rules.rule_template')} + + +
  • + )} + {rule.status !== 'READY' && ( - - {translate('rules.status', rule.status)} - + <> + +
  • + {translate('rules.status', rule.status)} +
  • + )} -
    -
    - {rule.langName} - - -

    {translate('coding_rules.type.deprecation.title')}

    -

    {translate('coding_rules.type.deprecation.filter_by')}

    -
    - } - links={[ - { - href: '/user-guide/clean-code', - label: translate('learn_more'), - }, - ]} - > - - - - {allTags.length > 0 && ( - + <> + +
  • + +
  • + )} - {this.renderActions()} -
    + + +
    {this.renderActions()}
    diff --git a/server/sonar-web/src/main/js/components/tags/TagsList.tsx b/server/sonar-web/src/main/js/components/tags/TagsList.tsx index f29a548ee95..2c0fd4dca69 100644 --- a/server/sonar-web/src/main/js/components/tags/TagsList.tsx +++ b/server/sonar-web/src/main/js/components/tags/TagsList.tsx @@ -28,6 +28,7 @@ interface Props { className?: string; tags: string[]; overlay?: React.ReactNode; + tagsClassName?: string; tagsToDisplay?: number; } @@ -36,6 +37,7 @@ export default function TagsList({ className, tags, overlay, + tagsClassName, tagsToDisplay = 2, }: Readonly) { const [open, setOpen] = React.useState(false); @@ -52,6 +54,7 @@ export default function TagsList({ overlay={overlay} popupPlacement={PopupPlacement.Bottom} tags={tags} + tagsClassName={tagsClassName} tagsToDisplay={tagsToDisplay} tooltip={Tooltip} /> -- 2.39.5