From a4f68e401d861e24eacc9f761561ad2288b9b364 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Fri, 29 Jul 2022 15:34:21 +0200 Subject: SONAR-16538 Moving sonarlint and badges in the issue header --- .../main/js/apps/issues/components/IssueHeader.tsx | 65 +++++++++++++++++++++- .../components/issue/components/IssueMessage.tsx | 4 +- .../__snapshots__/IssueMessage-test.tsx.snap | 4 +- .../main/resources/org/sonar/l10n/core.properties | 4 +- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx index 355e5e5586e..d2a6c9709d0 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx @@ -18,18 +18,23 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { deleteIssueComment, editIssueComment, setIssueAssignee } from '../../../api/issues'; +import DocumentationTooltip from '../../../components/common/DocumentationTooltip'; +import Tooltip from '../../../components/controls/Tooltip'; import LinkIcon from '../../../components/icons/LinkIcon'; +import SonarLintIcon from '../../../components/icons/SonarLintIcon'; import { updateIssue } from '../../../components/issue/actions'; import IssueActionsBar from '../../../components/issue/components/IssueActionsBar'; import IssueChangelog from '../../../components/issue/components/IssueChangelog'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../../helpers/keycodes'; -import { translate } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getComponentIssuesUrl, getRuleUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; +import { RuleStatus } from '../../../types/rules'; import { Issue, RuleDetails } from '../../../types/types'; interface Props { @@ -122,10 +127,66 @@ export default class IssueHeader extends React.PureComponent { open: issue.key, types: issue.type === 'SECURITY_HOTSPOT' ? issue.type : undefined }); + const ruleStatus = issue.ruleStatus as RuleStatus | undefined; + const ruleEngine = issue.externalRuleEngine; + const manualVulnerability = issue.fromHotspot && issue.type === 'VULNERABILITY'; + const { quickFixAvailable } = issue; + return ( <>
-

{issue.message}

+

+ {issue.message} + {quickFixAvailable && ( + + SonarLint + + ) + }} + /> + } + mouseLeaveDelay={0.5}> + + + )} +

+ {(ruleStatus === RuleStatus.Deprecated || ruleStatus === RuleStatus.Removed) && ( + + + {translate('issue.resolution.badge', ruleStatus)} + + + )} + {ruleEngine && ( + +
{ruleEngine}
+
+ )} + {manualVulnerability && ( + +
+ {translate('issue.manual_vulnerability')} +
+
+ )}
- {ruleStatus === RuleStatus.Deprecated - ? translate('issue.resolution.DEPRECATED.rule_deprecated') - : translate('issue.resolution.REMOVED.rule_removed')} + {translate('issue.resolution.badge', ruleStatus)} )} diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueMessage-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueMessage-test.tsx.snap index efae668c86c..824d917edb0 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueMessage-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueMessage-test.tsx.snap @@ -60,7 +60,7 @@ exports[`should render correctly: is deprecated rule 1`] = ` - issue.resolution.DEPRECATED.rule_deprecated + issue.resolution.badge.DEPRECATED
@@ -129,7 +129,7 @@ exports[`should render correctly: is removed rule 1`] = ` - issue.resolution.REMOVED.rule_removed + issue.resolution.badge.REMOVED
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 308aad4f448..515cffc68d4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -900,8 +900,8 @@ issue.resolution.WONTFIX=Won't Fix issue.resolution.WONTFIX.description=Issues that are accepted in this context. They and their effort will be ignored. issue.resolution.REMOVED=Removed issue.resolution.REMOVED.description=Either the rule or the resource was changed (removed, relocated, parameters changed, etc.) so that analysis no longer finds these issues. -issue.resolution.REMOVED.rule_removed=Rule removed -issue.resolution.DEPRECATED.rule_deprecated=Rule deprecated +issue.resolution.badge.REMOVED=Rule removed +issue.resolution.badge.DEPRECATED=Rule deprecated issue.unresolved.description=Unresolved issues have not been addressed in any way. issue.action.permalink=Get permalink -- cgit v1.2.3