From c3109dfacd111c6d20ceba354ca0304fa3247413 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Fri, 13 May 2022 16:46:19 +0200 Subject: [PATCH] SONAR-16303 Add advanced rule description tabs for issue --- .../apps/issues/components/IssueTabViewer.tsx | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) 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() { -- 2.39.5