]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12753 Refresh status when commenting
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 9 Jan 2020 16:31:53 +0000 (17:31 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 13 Jan 2020 19:46:38 +0000 (20:46 +0100)
server/sonar-web/src/main/js/apps/securityHotspots/__tests__/__snapshots__/SecurityHotspotsAppRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActionsForm.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx

index a99469f0413980ad15f15c239bb664ff767e312f..5af2220ac699a397fa8462cb964fcbd2b2382466 100644 (file)
@@ -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"
index 87cff37e935a726f460dff142d580dbb10c4e2bc..2018a18feb38423344fff15b32ee26e0db3a75dc 100644 (file)
@@ -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>
index 86dd311360477caf5053f352aeb74846980324f8..c55645480064317f1f20b272a06863dd3fdfc934 100644 (file)
@@ -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(() => {
index c3b2036255ff4178b18131898f408d22ef48025f..480b3001dd0d1ac3f72b5bfcc94d8d955982fe98 100644 (file)
@@ -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() {
index 9359659c5e7fdd097ec243bfdb807172be254b74..a12ae55ffe672b7d2fa5c30939a8b9e837fe63d3 100644 (file)
@@ -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;
 }