@@ -40,6 +40,7 @@ import { routes } from "../constants";
4040import { useTestRunDispatch , updateTestRun , selectTestRun } from "../contexts" ;
4141import { DrawArea } from "./DrawArea" ;
4242import { CommentsPopper } from "./CommentsPopper" ;
43+ import { useSnackbar } from "notistack" ;
4344
4445const useStyles = makeStyles ( ( theme ) => ( {
4546 imageContainer : {
@@ -57,6 +58,7 @@ const TestDetailsModal: React.FunctionComponent<{
5758} > = ( { testRun } ) => {
5859 const classes = useStyles ( ) ;
5960 const history = useHistory ( ) ;
61+ const { enqueueSnackbar } = useSnackbar ( ) ;
6062 const testRunDispatch = useTestRunDispatch ( ) ;
6163
6264 const stageWidth = ( window . innerWidth / 2 ) * 0.9 ;
@@ -177,6 +179,16 @@ const TestDetailsModal: React.FunctionComponent<{
177179 . then ( ( testRun ) => {
178180 updateTestRun ( testRunDispatch , testRun ) ;
179181 } )
182+ . then ( ( ) =>
183+ enqueueSnackbar ( "Approved" , {
184+ variant : "success" ,
185+ } )
186+ )
187+ . catch ( ( err ) =>
188+ enqueueSnackbar ( err , {
189+ variant : "error" ,
190+ } )
191+ )
180192 }
181193 >
182194 Approve
@@ -186,9 +198,21 @@ const TestDetailsModal: React.FunctionComponent<{
186198 < Button
187199 color = "secondary"
188200 onClick = { ( ) =>
189- testRunService . reject ( testRun . id ) . then ( ( testRun ) => {
190- updateTestRun ( testRunDispatch , testRun ) ;
191- } )
201+ testRunService
202+ . reject ( testRun . id )
203+ . then ( ( testRun ) => {
204+ updateTestRun ( testRunDispatch , testRun ) ;
205+ } )
206+ . then ( ( ) =>
207+ enqueueSnackbar ( "Rejected" , {
208+ variant : "success" ,
209+ } )
210+ )
211+ . catch ( ( err ) =>
212+ enqueueSnackbar ( err , {
213+ variant : "error" ,
214+ } )
215+ )
192216 }
193217 >
194218 Reject
@@ -239,6 +263,16 @@ const TestDetailsModal: React.FunctionComponent<{
239263 comment
240264 ) ,
241265 ] )
266+ . then ( ( ) =>
267+ enqueueSnackbar ( "Comment updated" , {
268+ variant : "success" ,
269+ } )
270+ )
271+ . catch ( ( err ) =>
272+ enqueueSnackbar ( err , {
273+ variant : "error" ,
274+ } )
275+ )
242276 }
243277 />
244278 </ Grid >
@@ -274,25 +308,39 @@ const TestDetailsModal: React.FunctionComponent<{
274308 < Grid item >
275309 < IconButton
276310 disabled = { isIgnoreAreasSaved ( ) }
277- onClick = { ( ) => {
278- // update in test run
279- testRunService
280- . setIgnoreAreas ( testRun . id , ignoreAreas )
281- . then ( ( ) =>
311+ onClick = { ( ) =>
312+ Promise . all ( [
313+ // update in test run
314+ testRunService . setIgnoreAreas ( testRun . id , ignoreAreas ) ,
315+ // update in variation
316+ testVariationService . setIgnoreAreas (
317+ testRun . testVariationId ,
318+ ignoreAreas
319+ ) ,
320+ ] )
321+ . then ( ( ) => {
322+ enqueueSnackbar ( "Ignore areas are updated" , {
323+ variant : "success" ,
324+ } ) ;
325+
282326 // recalculate diff
283327 testRunService
284328 . recalculateDiff ( testRun . id )
285329 . then ( ( testRun ) =>
286330 updateTestRun ( testRunDispatch , testRun )
287331 )
288- ) ;
289-
290- // update in variation
291- testVariationService . setIgnoreAreas (
292- testRun . testVariationId ,
293- ignoreAreas
294- ) ;
295- } }
332+ . then ( ( ) =>
333+ enqueueSnackbar ( "Diff recalculated" , {
334+ variant : "success" ,
335+ } )
336+ ) ;
337+ } )
338+ . catch ( ( err ) =>
339+ enqueueSnackbar ( err , {
340+ variant : "error" ,
341+ } )
342+ )
343+ }
296344 >
297345 < Save />
298346 </ IconButton >
0 commit comments