]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21394 Fix column alignment on rule details page
authorDavid Cho-Lerat <david.cho-lerat@sonarsource.com>
Tue, 16 Jan 2024 12:24:43 +0000 (13:24 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 16 Jan 2024 20:02:43 +0000 (20:02 +0000)
server/sonar-web/src/main/js/api/mocks/data/ids.ts
server/sonar-web/src/main/js/api/mocks/data/qualityProfiles.ts
server/sonar-web/src/main/js/api/mocks/data/rules.ts
server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx

index cd52cfb80ad5ce0a0e642ba78cd4813f645b7386..53e23bf638e73fe0af6098e36396e8e3208ccfb4 100644 (file)
@@ -57,6 +57,7 @@ export const QP_2 = 'p2';
 export const QP_3 = 'p3';
 export const QP_4 = 'p4';
 export const QP_5 = 'p5';
+export const QP_6 = 'p6';
 
 // Issues.
 export const ISSUE_0 = 'issue0';
index 45bd063dffe910bd2e15d684b165e17789cd158f..48c31a14b94be9ac220e9f484aceefe5c7a9b8f3 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { mockQualityProfile } from '../../../helpers/testMocks';
-import { QP_1, QP_2, QP_3, QP_4, QP_5 } from './ids';
+import { QP_1, QP_2, QP_3, QP_4, QP_5, QP_6 } from './ids';
 
 export function mockQualityProfilesList() {
   return [
@@ -46,5 +46,12 @@ export function mockQualityProfilesList() {
       parentKey: QP_4,
       parentName: 'QP FooBarBaz',
     }),
+    mockQualityProfile({
+      key: QP_6,
+      isBuiltIn: true,
+      name: 'QP Qux',
+      language: 'java',
+      languageName: 'Java',
+    }),
   ];
 }
index 316f21bd1e54ad16af07a70f5fb42f52e15b2dfd..0d20ca629ff8981c05622545c28742db61704b64 100644 (file)
@@ -31,6 +31,7 @@ import {
   QP_2,
   QP_4,
   QP_5,
+  QP_6,
   RULE_1,
   RULE_10,
   RULE_11,
@@ -263,6 +264,7 @@ export function mockRulesActivationsInQP() {
       mockRuleActivation({ qProfile: QP_1 }),
       mockRuleActivation({ qProfile: QP_4 }),
       mockRuleActivation({ qProfile: QP_5, inherit: 'INHERITED' }),
+      mockRuleActivation({ qProfile: QP_6 }),
     ],
     [RULE_7]: [mockRuleActivation({ qProfile: QP_2 })],
     [RULE_8]: [mockRuleActivation({ qProfile: QP_2 })],
index b7d338639251f13c0e1c8f263d56c0449e089724..6738761cea00159ce52f2a462bb84db5668a05c6 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 styled from '@emotion/styled';
 import {
   ActionCell,
@@ -112,16 +113,16 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
               <ConfirmButton
                 confirmButtonText={translate('yes')}
                 confirmData={profile.key}
+                isDestructive
                 modalBody={translateWithParameters(
                   'coding_rules.revert_to_parent_definition.confirm',
                   profile.parentName,
                 )}
-                isDestructive
                 modalHeader={translate('coding_rules.revert_to_parent_definition')}
                 onConfirm={handleRevert}
               >
                 {({ onClick }) => (
-                  <DangerButtonSecondary className="sw-ml-2" onClick={onClick}>
+                  <DangerButtonSecondary className="sw-ml-2 sw-whitespace-nowrap" onClick={onClick}>
                     {translate('coding_rules.revert_to_parent_definition')}
                   </DangerButtonSecondary>
                 )}
@@ -138,7 +139,7 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
               >
                 {({ onClick }) => (
                   <DangerButtonSecondary
-                    className="sw-ml-2"
+                    className="sw-ml-2 sw-whitespace-nowrap"
                     aria-label={translateWithParameters(
                       'coding_rules.deactivate_in_quality_profile_x',
                       profile.name,
@@ -167,13 +168,15 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
 
     const inheritedProfileSection = profile.parentName
       ? (activation.inherit === 'OVERRIDES' || activation.inherit === 'INHERITED') && (
-          <Note as="div" className="sw-flex sw-items-center sw-mt-2">
+          <Note as="div" className="sw-flex sw-items-center sw-w-full">
             <InheritanceIcon
               fill={activation.inherit === 'OVERRIDES' ? 'destructiveIconFocus' : 'currentColor'}
             />
+
             <DiscreetLink
-              className="sw-ml-1"
               aria-label={`${translate('quality_profiles.parent')} ${profile.parentName}`}
+              className="sw-ml-1 sw-truncate"
+              title={profile.parentName}
               to={getQualityProfileUrl(profile.parentName, profile.language)}
             >
               {profile.parentName}
@@ -184,19 +187,24 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
 
     return (
       <TableRowInteractive key={profile.key}>
-        <ContentCell className="coding-rules-detail-quality-profile-name">
-          <div className="sw-flex sw-flex-col">
-            <div>
-              <Link
-                aria-label={profile.name}
-                to={getQualityProfileUrl(profile.name, profile.language)}
-              >
-                {profile.name}
-              </Link>
-              {profile.isBuiltIn && <BuiltInQualityProfileBadge className="sw-ml-2" />}
-            </div>
-            {inheritedProfileSection}
+        <ContentCell className="sw-flex sw-flex-col sw-gap-2 sw-w-64">
+          <div
+            className="sw-truncate sw-w-full"
+            title={`${profile.name}${
+              profile.isBuiltIn ? ` (${translate('quality_profiles.built_in')})` : ''
+            }`}
+          >
+            <Link
+              aria-label={profile.name}
+              to={getQualityProfileUrl(profile.name, profile.language)}
+            >
+              {profile.name}
+            </Link>
+
+            {profile.isBuiltIn && <BuiltInQualityProfileBadge className="sw-ml-2" />}
           </div>
+
+          {inheritedProfileSection}
         </ContentCell>
 
         {!ruleDetails.templateKey && (
@@ -208,13 +216,17 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
               return (
                 <StyledParameter className="sw-my-4" key={param.key}>
                   <span className="key">{param.key}</span>
+
                   <span className="sep sw-mr-1">: </span>
+
                   <span className="value" title={param.value}>
                     {param.value}
                   </span>
+
                   {parentActivation && param.value !== originalValue && (
                     <div className="sw-flex sw-ml-4">
                       {translate('coding_rules.original')}
+
                       <span className="value sw-ml-1" title={originalValue}>
                         {originalValue}
                       </span>
@@ -225,6 +237,7 @@ export default function RuleDetailsProfiles(props: Readonly<Props>) {
             })}
           </CellComponent>
         )}
+
         {renderRowActions(activation, profile)}
       </TableRowInteractive>
     );