]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16303 Add advanced rule description tabs for issue
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Fri, 13 May 2022 14:46:19 +0000 (16:46 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 24 May 2022 20:10:14 +0000 (20:10 +0000)
server/sonar-web/src/main/js/apps/issues/components/IssueTabViewer.tsx

index f0db6bbddbbbc3922951c78c74114e89d9f75ce3..a9a43464f854b7194127f3d80812b9778311e0c4 100644 (file)
@@ -74,21 +74,42 @@ export default class IssueViewerTabs extends React.PureComponent<Props, State> {
   computeTabs() {
     const { ruleDetails } = this.props;
 
-    return [
+    const tabs = [
       {
         key: TabKeys.Code,
-        label: translate('issue.tabs.code'),
+        label: translate('issue.tabs', TabKeys.Code),
         content: ''
       },
       {
         key: TabKeys.WhyIsThisAnIssue,
-        label: translate('issue.tabs.why'),
-        content:
-          ruleDetails.descriptionSections?.find(
-            section => section.key === RuleDescriptionSections.DEFAULT
-          )?.content ?? ''
+        label: translate('issue.tabs', TabKeys.WhyIsThisAnIssue),
+        content: ruleDetails.descriptionSections?.find(section =>
+          [RuleDescriptionSections.DEFAULT, RuleDescriptionSections.ROOT_CAUSE].includes(
+            section.key
+          )
+        )?.content
+      },
+      {
+        key: TabKeys.HowToFixIt,
+        label: translate('issue.tabs', TabKeys.HowToFixIt),
+        content: ruleDetails.descriptionSections?.find(
+          section => section.key === RuleDescriptionSections.HOW_TO_FIX
+        )?.content
+      },
+      {
+        key: TabKeys.Resources,
+        label: translate('issue.tabs', TabKeys.Resources),
+        content: ruleDetails.descriptionSections?.find(
+          section => section.key === RuleDescriptionSections.RESOURCES
+        )?.content
       }
-    ];
+    ].filter(tab => tab.content !== undefined) as Array<Tab>;
+
+    if (ruleDetails.htmlNote) {
+      tabs[tabs.length - 1].content += '<br/>' + ruleDetails.htmlNote;
+    }
+
+    return tabs;
   }
 
   render() {