]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16518 Add "How to fix it" context sub title
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Mon, 11 Jul 2022 09:30:16 +0000 (11:30 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 11 Jul 2022 20:13:12 +0000 (20:13 +0000)
server/sonar-web/src/main/js/api/mocks/CodingRulesMock.ts
server/sonar-web/src/main/js/apps/coding-rules/__tests__/CodingRules-it.ts
server/sonar-web/src/main/js/apps/issues/__tests__/IssueApp-it.tsx
server/sonar-web/src/main/js/components/rules/RuleDescription.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index f6e2563257aa6785565f29456e7a48d6a52c35a0..b5ad81cb25640bb6e7a3bda46b247497e5733a92 100644 (file)
@@ -133,12 +133,12 @@ export default class CodingRulesMock {
           },
           {
             key: RuleDescriptionSections.HOW_TO_FIX,
-            content: 'This how to fix for spring',
+            content: 'This is how to fix for spring',
             context: { key: 'spring', displayName: 'Spring' }
           },
           {
             key: RuleDescriptionSections.HOW_TO_FIX,
-            content: 'This how to fix for spring boot',
+            content: 'This is how to fix for spring boot',
             context: { key: 'spring_boot', displayName: 'Spring boot' }
           },
           {
index 140dba40e2b4a42369ae61d3cf0a59c2c2a22ee9..03d8a6a7a1a793cd5eccc4415ef01a9411c49f8d 100644 (file)
@@ -154,14 +154,23 @@ it('should show rule advanced section with context', async () => {
   expect(screen.getByRole('radio', { name: 'Spring' })).toBeInTheDocument();
   expect(screen.getByRole('radio', { name: 'Spring boot' })).toBeInTheDocument();
   expect(
-    screen.getByRole('radio', { name: 'coding_rules.description_context_other' })
+    screen.getByRole('radio', { name: 'coding_rules.description_context.other' })
   ).toBeInTheDocument();
-  expect(screen.getByText('This how to fix for spring')).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('radio', { name: 'Spring boot' }));
-  expect(screen.getByText('This how to fix for spring boot')).toBeInTheDocument();
+  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('radio', { 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'
+    )
+  ).not.toBeInTheDocument();
   expect(screen.getByText('coding_rules.context.others.title')).toBeInTheDocument();
   expect(screen.getByText('coding_rules.context.others.description.first')).toBeInTheDocument();
 
index 8e0a0c3aaee9edbfee0b769c0be6b6243e97c913..ab7c94ca37b71132c553850967cfb446a7ff0829 100644 (file)
@@ -72,7 +72,7 @@ it('should open issue and navigate', async () => {
   expect(screen.getByRole('radio', { name: 'Context 3' })).toBeInTheDocument();
   expect(screen.getByRole('radio', { name: 'Spring' })).toBeInTheDocument();
   expect(
-    screen.getByRole('radio', { name: 'coding_rules.description_context_other' })
+    screen.getByRole('radio', { name: 'coding_rules.description_context.other' })
   ).toBeInTheDocument();
   expect(screen.getByRole('radio', { name: 'Spring' })).toBeChecked();
 
@@ -81,7 +81,7 @@ it('should open issue and navigate', async () => {
   expect(screen.getByText('Context 2 content')).toBeInTheDocument();
 
   // Select the "other" context and check tab content
-  await user.click(screen.getByRole('radio', { name: 'coding_rules.description_context_other' }));
+  await user.click(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();
   expect(screen.getByText('coding_rules.context.others.description.second')).toBeInTheDocument();
index fcf0b3784c0e09e27e021079ca1993bffd9322ec..0044a391fcd530194ce2eb863f4b8bd3bbdc8fef 100644 (file)
@@ -79,7 +79,7 @@ export default class RuleDescription extends React.PureComponent<Props, State> {
 
     if (contexts.length > 0) {
       contexts.push({
-        displayName: translate('coding_rules.description_context_other'),
+        displayName: translate('coding_rules.description_context.other'),
         content: '',
         key: OTHERS_KEY
       });
@@ -125,24 +125,31 @@ export default class RuleDescription extends React.PureComponent<Props, State> {
           })}>
           <div className="rules-context-description">
             <h2 className="rule-contexts-title">
-              {translate('coding_rules.description_context_title')}
+              {translate('coding_rules.description_context.title')}
             </h2>
             {defaultContext && (
               <Alert variant="info" display="inline" className="big-spacer-bottom">
                 {translateWithParameters(
-                  'coding_rules.description_context_default_information',
+                  'coding_rules.description_context.default_information',
                   defaultContext.displayName
                 )}
               </Alert>
             )}
             <div>
               <RadioToggle
-                className="big-spacer-bottom"
                 name="filter"
                 onCheck={this.handleToggleContext}
                 options={options}
                 value={selectedContext.displayName}
               />
+              {selectedContext.key !== OTHERS_KEY && (
+                <h2>
+                  {translateWithParameters(
+                    'coding_rules.description_context.sub_title',
+                    selectedContext.displayName
+                  )}
+                </h2>
+              )}
             </div>
             {selectedContext.key === OTHERS_KEY ? (
               <OtherContextOption />
index 2817269072d9de042b2df9125fa7206f5115b4cd..19eca9ff048cabc5e6cc7b2c0f858df6c889e0ce 100644 (file)
@@ -1913,9 +1913,10 @@ coding_rules.description_section.title.assess_the_problem=Assess the risk?
 coding_rules.description_section.title.how_to_fix=How to fix it?
 coding_rules.description_section.title.more_info=More Info
 
-coding_rules.description_context_title=Which component or framework contains the issue?
-coding_rules.description_context_default_information={0} was detected as the most relevant component or framework for this issue.
-coding_rules.description_context_other=Other
+coding_rules.description_context.title=Which component or framework contains the issue?
+coding_rules.description_context.sub_title=How to fix it in {0}
+coding_rules.description_context.default_information={0} was detected as the most relevant component or framework for this issue.
+coding_rules.description_context.other=Other
 
 coding_rules.more_info.education_principles.title=Security principles
 coding_rules.more_info.resources.title=Resources