From: Jeremy Date: Mon, 23 Dec 2019 08:12:09 +0000 (+0100) Subject: SONAR-12720 comment status changes X-Git-Tag: 8.2.0.32929~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=692623ac5c596a3d2eab1c45c4e1bb2ac8b2534f;p=sonarqube.git SONAR-12720 comment status changes --- diff --git a/server/sonar-web/src/main/js/app/styles/init/forms.css b/server/sonar-web/src/main/js/app/styles/init/forms.css index cf79a4db03c..f06098111cc 100644 --- a/server/sonar-web/src/main/js/app/styles/init/forms.css +++ b/server/sonar-web/src/main/js/app/styles/init/forms.css @@ -138,6 +138,10 @@ textarea.width-100 { max-width: 100%; } +textarea.fixed-width { + resize: vertical; +} + select { height: var(--controlHeight); line-height: var(--controlHeight); diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx index b1c998847b5..e0c920dd561 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx @@ -34,6 +34,7 @@ interface Props { } interface State { + comment: string; selectedUser?: T.UserActive; selectedOption: HotspotStatusOptions; submitting: boolean; @@ -41,6 +42,7 @@ interface State { export default class HotspotActionsForm extends React.Component { state: State = { + comment: '', selectedOption: HotspotStatusOptions.FIXED, submitting: false }; @@ -53,17 +55,27 @@ export default class HotspotActionsForm extends React.Component { this.setState({ selectedUser }); }; + handleCommentChange = (comment: string) => { + this.setState({ comment }); + }; + handleSubmit = (event: React.SyntheticEvent) => { event.preventDefault(); const { hotspotKey } = this.props; - const { selectedOption } = this.state; + const { comment, selectedOption, selectedUser } = this.state; const status = selectedOption === HotspotStatusOptions.ADDITIONAL_REVIEW ? HotspotStatus.TO_REVIEW : HotspotStatus.REVIEWED; const data: HotspotSetStatusRequest = { status }; + + // If reassigning, ignore comment for status update. It will be sent with the reassignment below + if (comment && !(selectedOption === HotspotStatusOptions.ADDITIONAL_REVIEW && selectedUser)) { + data.comment = comment; + } + if (selectedOption !== HotspotStatusOptions.ADDITIONAL_REVIEW) { data.resolution = HotspotResolution[selectedOption]; } @@ -71,9 +83,8 @@ export default class HotspotActionsForm extends React.Component { this.setState({ submitting: true }); return setSecurityHotspotStatus(hotspotKey, data) .then(() => { - const { selectedUser } = this.state; if (selectedOption === HotspotStatusOptions.ADDITIONAL_REVIEW && selectedUser) { - return this.assignHotspot(selectedUser); + return this.assignHotspot(selectedUser, comment); } return null; }) @@ -85,22 +96,25 @@ export default class HotspotActionsForm extends React.Component { }); }; - assignHotspot = (assignee: T.UserActive) => { + assignHotspot = (assignee: T.UserActive, comment: string) => { const { hotspotKey } = this.props; return assignSecurityHotspot(hotspotKey, { - assignee: assignee.login + assignee: assignee.login, + comment }); }; render() { const { hotspotKey } = this.props; - const { selectedOption, selectedUser, submitting } = this.state; + const { comment, selectedOption, selectedUser, submitting } = this.state; return ( void; + onChangeComment: (comment: string) => void; onSelectOption: (option: HotspotStatusOptions) => void; onSubmit: (event: React.SyntheticEvent) => void; selectedOption: HotspotStatusOptions; @@ -35,10 +38,10 @@ export interface HotspotActionsFormRendererProps { } export default function HotspotActionsFormRenderer(props: HotspotActionsFormRendererProps) { - const { selectedOption, submitting } = props; + const { comment, selectedOption, submitting } = props; return ( -
+

{translate('hotspots.form.title')}

{renderOption({ @@ -63,6 +66,24 @@ export default function HotspotActionsFormRenderer(props: HotspotActionsFormRend
)} +
+ +