From: Mathieu Suen Date: Wed, 6 Oct 2021 09:33:14 +0000 (+0200) Subject: SONAR-15473 Add SonarLint promotion for quick fix on issue X-Git-Tag: 9.2.0.49834~158 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ae8cda9b5442652dfff87819ac45fc3dd03eb36d;p=sonarqube.git SONAR-15473 Add SonarLint promotion for quick fix on issue --- diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx index 3662530064e..bd59dbebd82 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx @@ -18,16 +18,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { FormattedMessage } from 'react-intl'; import { ButtonLink } from '../../../components/controls/buttons'; import Tooltip from '../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { RuleStatus } from '../../../types/rules'; import DocumentationTooltip from '../../common/DocumentationTooltip'; +import SonarLintIcon from '../../icons/SonarLintIcon'; import { WorkspaceContextShape } from '../../workspace/context'; export interface IssueMessageProps { engine?: string; engineName?: string; + quickFixAvailable?: boolean; manualVulnerability: boolean; message: string; onOpenRule: WorkspaceContextShape['openRule']; @@ -36,12 +39,42 @@ export interface IssueMessageProps { } export default function IssueMessage(props: IssueMessageProps) { - const { engine, engineName, manualVulnerability, message, ruleKey, ruleStatus } = props; + const { + engine, + engineName, + quickFixAvailable, + manualVulnerability, + message, + ruleKey, + ruleStatus + } = props; const ruleEngine = engineName ? engineName : engine; return ( -
+
{message} + {quickFixAvailable && ( + + SonarLint + + ) + }} + /> + } + mouseLeaveDelay={0.5}> + + + )} {translate('issue.why_this_issue')} - {ruleStatus && (ruleStatus === RuleStatus.Deprecated || ruleStatus === RuleStatus.Removed) && ( )} - {ruleEngine && (
{ruleEngine}
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx index e4af5329dee..2b3bb81a35b 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx @@ -81,6 +81,7 @@ export default function IssueTitleBar(props: IssueTitleBarProps) { externalRulesRepoNames && externalRulesRepoNames[issue.externalRuleEngine] } + quickFixAvailable={issue.quickFixAvailable} manualVulnerability={issue.fromHotspot && issue.type === 'VULNERABILITY'} message={issue.message} onOpenRule={openRule} diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueMessage-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueMessage-test.tsx index 3e1d43c3c7e..a47a0d59f03 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueMessage-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueMessage-test.tsx @@ -27,6 +27,7 @@ import IssueMessage, { IssueMessageProps } from '../IssueMessage'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); expect(shallowRender({ engine: 'js' })).toMatchSnapshot('with engine info'); + expect(shallowRender({ quickFixAvailable: true })).toMatchSnapshot('with quick fix'); expect(shallowRender({ engineName: 'JS' })).toMatchSnapshot('with engine name'); expect(shallowRender({ manualVulnerability: true })).toMatchSnapshot('is manual vulnerability'); expect(shallowRender({ ruleStatus: RuleStatus.Deprecated })).toMatchSnapshot( 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 05ac47ff7ea..94baa6b09fd 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 @@ -2,7 +2,7 @@ exports[`should render correctly: default 1`] = `
`; + +exports[`should render correctly: with quick fix 1`] = ` +
+ + Reduce the number of conditional operators (4) used in the expression + + + SonarLint + , + } + } + /> + } + > + + + + issue.why_this_issue + +
+`; diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts index 8173bca1ff1..74ccbfd754b 100644 --- a/server/sonar-web/src/main/js/types/types.d.ts +++ b/server/sonar-web/src/main/js/types/types.d.ts @@ -343,6 +343,7 @@ declare namespace T { effort?: string; externalRuleEngine?: string; fromExternalRule?: boolean; + quickFixAvailable?: boolean; key: string; flows: FlowLocation[][]; fromHotspot: boolean; 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 d5da4dd1415..f97f1cfd414 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -808,6 +808,7 @@ issue.assign.assigned_to_x_click_to_change=Assigned to {0}, click to change issue.assign.unassigned_click_to_assign=Unassigned, click to assign issue issue.assign.formlink=Assign issue.assign.to_me=to me +issue.quick_fix_available_with_sonarlint=Quick fix available in {link} issue.comment.add_comment=Add Comment issue.comment.formlink=Comment issue.comment.submit=Comment