diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2020-01-09 17:31:53 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2020-01-13 20:46:38 +0100 |
commit | cc26f2f76379066d93d58fa90288d7d6a2a3334c (patch) | |
tree | d5eddc7ed7a255ec989551795356db280f8d8d62 /server | |
parent | 3f980781b807da928130b472f51cc9a7af8a2eae (diff) | |
download | sonarqube-cc26f2f76379066d93d58fa90288d7d6a2a3334c.tar.gz sonarqube-cc26f2f76379066d93d58fa90288d7d6a2a3334c.zip |
SONAR-12753 Refresh status when commenting
Diffstat (limited to 'server')
5 files changed, 30 insertions, 22 deletions
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap index a99469f0413..5af2220ac69 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap @@ -36,7 +36,7 @@ exports[`should render correctly with hotspots 1`] = ` <Suggestions suggestions="security_hotspots" /> - <HelmetWrapper + <Helmet defer={true} encodeSpecialCharacters={true} title="hotspots.page" @@ -115,7 +115,7 @@ exports[`should render correctly with hotspots 2`] = ` <Suggestions suggestions="security_hotspots" /> - <HelmetWrapper + <Helmet defer={true} encodeSpecialCharacters={true} title="hotspots.page" @@ -201,7 +201,7 @@ exports[`should render correctly: no hotspots 1`] = ` <Suggestions suggestions="security_hotspots" /> - <HelmetWrapper + <Helmet defer={true} encodeSpecialCharacters={true} title="hotspots.page" @@ -230,7 +230,7 @@ exports[`should render correctly: no hotspots with filters 1`] = ` <Suggestions suggestions="security_hotspots" /> - <HelmetWrapper + <Helmet defer={true} encodeSpecialCharacters={true} title="hotspots.page" diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx index 87cff37e935..2018a18feb3 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx @@ -24,12 +24,12 @@ import OutsideClickHandler from 'sonar-ui-common/components/controls/OutsideClic import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon'; import { PopupPlacement } from 'sonar-ui-common/components/ui/popups'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import { Hotspot, HotspotUpdateFields } from '../../../types/security-hotspots'; +import { Hotspot } from '../../../types/security-hotspots'; import HotspotActionsForm from './HotspotActionsForm'; export interface HotspotActionsProps { hotspot: Hotspot; - onSubmit: (hotspot: HotspotUpdateFields) => void; + onSubmit: () => void; } const ESCAPE_KEY = 'Escape'; @@ -64,9 +64,9 @@ export default function HotspotActions(props: HotspotActionsProps) { <DropdownOverlay placement={PopupPlacement.BottomRight}> <HotspotActionsForm hotspot={hotspot} - onSubmit={data => { + onSubmit={() => { setOpen(false); - props.onSubmit(data); + props.onSubmit(); }} /> </DropdownOverlay> 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 86dd3113604..c5564548006 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 @@ -27,14 +27,13 @@ import { Hotspot, HotspotResolution, HotspotStatus, - HotspotStatusOption, - HotspotUpdateFields + HotspotStatusOption } from '../../../types/security-hotspots'; import HotspotActionsFormRenderer from './HotspotActionsFormRenderer'; interface Props { hotspot: Hotspot; - onSubmit: (data: HotspotUpdateFields) => void; + onSubmit: () => void; } interface State { @@ -100,7 +99,7 @@ export default class HotspotActionsForm extends React.Component<Props, State> { .then(() => this.updateAssignee(hotspot, selectedOption, selectedUser)) .then(() => this.addComment(hotspot, comment)) .then(() => { - this.props.onSubmit({ status, resolution }); + this.props.onSubmit(); // No need to set "submitting", we are closing the window }) .catch(() => { diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx index c3b2036255f..480b3001dd0 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { getSecurityHotspotDetails } from '../../../api/security-hotspots'; import { BranchLike } from '../../../types/branch-like'; -import { Hotspot, HotspotUpdate, HotspotUpdateFields } from '../../../types/security-hotspots'; +import { Hotspot, HotspotUpdate } from '../../../types/security-hotspots'; import HotspotViewerRenderer from './HotspotViewerRenderer'; interface Props { @@ -58,16 +58,25 @@ export default class HotspotViewer extends React.PureComponent<Props, State> { fetchHotspot() { this.setState({ loading: true }); return getSecurityHotspotDetails(this.props.hotspotKey) - .then(hotspot => this.mounted && this.setState({ hotspot, loading: false })) + .then(hotspot => { + if (this.mounted) { + this.setState({ hotspot, loading: false }); + } + return hotspot; + }) .catch(() => this.mounted && this.setState({ loading: false })); } - handleHotspotUpdate = (data?: HotspotUpdateFields) => { - if (data) { - this.props.onUpdateHotspot({ key: this.props.hotspotKey, ...data }); - } - - this.fetchHotspot(); + handleHotspotUpdate = () => { + return this.fetchHotspot().then((hotspot?: Hotspot) => { + if (hotspot) { + this.props.onUpdateHotspot({ + key: hotspot.key, + status: hotspot.status, + resolution: hotspot.resolution + }); + } + }); }; render() { diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx index 9359659c5e7..a12ae55ffe6 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx @@ -23,7 +23,7 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; import { isLoggedIn } from '../../../helpers/users'; import { BranchLike } from '../../../types/branch-like'; -import { Hotspot, HotspotUpdateFields } from '../../../types/security-hotspots'; +import { Hotspot } from '../../../types/security-hotspots'; import HotspotActions from './HotspotActions'; import HotspotSnippetContainer from './HotspotSnippetContainer'; import HotspotViewerTabs from './HotspotViewerTabs'; @@ -33,7 +33,7 @@ export interface HotspotViewerRendererProps { currentUser: T.CurrentUser; hotspot?: Hotspot; loading: boolean; - onUpdateHotspot: (data?: HotspotUpdateFields) => void; + onUpdateHotspot: () => void; securityCategories: T.StandardSecurityCategories; } |