From: Grégoire Aubert Date: Mon, 13 May 2019 13:27:11 +0000 (+0200) Subject: SONAR-12026 Update transition names and description for Vulnerability coming from... X-Git-Tag: 7.8~196 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=582503f4b16b06b08f043f70f6972e9d3d93610d;p=sonarqube.git SONAR-12026 Update transition names and description for Vulnerability coming from a hotspot --- diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx index f464ccab2ce..cc4bba9c6b8 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx @@ -29,7 +29,7 @@ import { updateIssue } from '../actions'; interface Props { hasTransitions: boolean; isOpen: boolean; - issue: Pick; + issue: Pick; onChange: (issue: T.Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -61,7 +61,12 @@ export default class IssueTransition extends React.PureComponent { onRequestClose={this.handleClose} open={this.props.isOpen && this.props.hasTransitions} overlay={ - + }> { expect( shallowRender({ hasTransitions: false, - issue: { key: 'foo1234', transitions: [], status: 'CLOSED' } + issue: { fromHotspot: false, key: 'foo1234', transitions: [], status: 'CLOSED', type: 'BUG' } }) ).toMatchSnapshot(); }); @@ -45,10 +47,12 @@ it('should render with a resolution', () => { expect( shallowRender({ issue: { + fromHotspot: false, key: 'foo1234', transitions: ['reopen'], status: 'RESOLVED', - resolution: 'FIXED' + resolution: 'FIXED', + type: 'BUG' } }) ).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTransition-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTransition-test.tsx.snap index f5decbbd71b..e17d30f0a59 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTransition-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTransition-test.tsx.snap @@ -18,6 +18,7 @@ exports[`should open the popup when the button is clicked 2`] = ` open={true} overlay={ } > @@ -55,12 +57,14 @@ exports[`should render with a resolution 1`] = ` open={false} overlay={ } > @@ -90,6 +94,7 @@ exports[`should render with the action 1`] = ` open={false} overlay={ } > diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx index 28e3b37478b..d6e1dc388c8 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx @@ -20,25 +20,26 @@ import * as React from 'react'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; -import { translate } from '../../../helpers/l10n'; +import { translate, hasMessage } from '../../../helpers/l10n'; import { DropdownOverlay } from '../../controls/Dropdown'; -interface Props { +export interface Props { + fromHotspot: boolean; onSelect: (transition: string) => void; transitions: string[]; + type: T.IssueType; } -export default function SetTransitionPopup({ onSelect, transitions }: Props) { +export default function SetTransitionPopup({ fromHotspot, onSelect, transitions, type }: Props) { + const isManualVulnerability = fromHotspot && type === 'VULNERABILITY'; return ( {transitions.map(transition => { + const [name, description] = translateTransition(transition, isManualVulnerability); return ( - - {translate('issue.transition', transition)} + + {name} ); })} @@ -46,3 +47,15 @@ export default function SetTransitionPopup({ onSelect, transitions }: Props) { ); } + +function translateTransition(transition: string, isManualVulnerability: boolean) { + return isManualVulnerability && hasMessage('vulnerability.transition', transition) + ? [ + translate('vulnerability.transition', transition), + translate('vulnerability.transition', transition, 'description') + ] + : [ + translate('issue.transition', transition), + translate('issue.transition', transition, 'description') + ]; +} diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTransitionPopup-test.tsx b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTransitionPopup-test.tsx index bb6bc6b72fb..dc197d693e4 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTransitionPopup-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTransitionPopup-test.tsx @@ -19,14 +19,36 @@ */ import * as React from 'react'; import { shallow } from 'enzyme'; -import SetTransitionPopup from '../SetTransitionPopup'; +import SetTransitionPopup, { Props } from '../SetTransitionPopup'; +import { hasMessage } from '../../../../helpers/l10n'; -it('should render tags popup correctly', () => { - const element = shallow( +jest.mock('../../../../helpers/l10n', () => ({ + ...jest.requireActual('../../../../helpers/l10n'), + hasMessage: jest.fn().mockReturnValue(false) +})); + +it('should render transition popup correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +it('should render transition popup correctly for vulnerability', () => { + (hasMessage as jest.Mock).mockReturnValueOnce('true'); + expect( + shallowRender({ + fromHotspot: true, + transitions: ['resolveasreviewed', 'confirm'] + }) + ).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( ); - expect(element).toMatchSnapshot(); -}); +} diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTransitionPopup-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTransitionPopup-test.tsx.snap index a9728b1687a..915afea770c 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTransitionPopup-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTransitionPopup-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render tags popup correctly 1`] = ` +exports[`should render transition popup correctly 1`] = ` `; + +exports[`should render transition popup correctly for vulnerability 1`] = ` + + + + vulnerability.transition.resolveasreviewed + + + issue.transition.confirm + + + +`; 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 d089f70e9d4..0990e9f1e5a 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -618,14 +618,19 @@ issue.transition.close=Close issue.transition.close.description= issue.transition.wontfix=Resolve as won't fix issue.transition.wontfix.description=This issue can be ignored because the rule is irrelevant in this context. Its effort won't be counted. -issue.transition.setinreview = Set as In Review -issue.transition.setinreview.description = A review is required to check for a vulnerability -issue.transition.resolveasreviewed = Resolve as Reviewed -issue.transition.resolveasreviewed.description = There is no vulnerability in the code -issue.transition.openasvulnerability = Open as Vulnerability -issue.transition.openasvulnerability.description = There's a vulnerability in the code that must be fixed -issue.transition.resetastoreview = Reset as security hotspot To Review -issue.transition.resetastoreview.description = The security hotspot should be analyzed again +issue.transition.setinreview=Set as In Review +issue.transition.setinreview.description=A review is required to check for a Vulnerability +issue.transition.openasvulnerability=Open as Vulnerability +issue.transition.openasvulnerability.description=There's a Vulnerability in the code that must be fixed +issue.transition.resolveasreviewed=Resolve as Reviewed +issue.transition.resolveasreviewed.description=There is no Vulnerability in the code +issue.transition.resetastoreview=Reset as To Review +issue.transition.resetastoreview.description=The Security Hotspot should be analyzed again +vulnerability.transition.resetastoreview=Reset as Security Hotspot To Review +vulnerability.transition.resetastoreview.description=The Vulnerability can't be fixed as is and needs more details +vulnerability.transition.resolveasreviewed=Resolve as Reviewed Security Hotspot +vulnerability.transition.resolveasreviewed.description=The Vulnerability has been fixed + issue.set_severity=Change Severity issue.set_type=Change Type