From: Philippe Perrin Date: Fri, 13 May 2022 14:46:19 +0000 (+0200) Subject: SONAR-16303 Add advanced rule description tabs for issue X-Git-Tag: 9.5.0.56709~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3109dfacd111c6d20ceba354ca0304fa3247413;p=sonarqube.git SONAR-16303 Add advanced rule description tabs for issue --- diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssueTabViewer.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssueTabViewer.tsx index f0db6bbddbb..a9a43464f85 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssueTabViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssueTabViewer.tsx @@ -74,21 +74,42 @@ export default class IssueViewerTabs extends React.PureComponent { 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; + + if (ruleDetails.htmlNote) { + tabs[tabs.length - 1].content += '
' + ruleDetails.htmlNote; + } + + return tabs; } render() {