From 7366b4156cfc2166706b876f91e01bb77c529d04 Mon Sep 17 00:00:00 2001 From: Hassan Ali Date: Tue, 23 Oct 2018 13:43:36 -0400 Subject: [PATCH] Provide visual feedback when terminating ec2 instances --- src/components/Snackbar/index.jsx | 5 +-- .../AwsProvisioner/ViewWorkerType/index.jsx | 40 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/Snackbar/index.jsx b/src/components/Snackbar/index.jsx index cd2b3092..d72c12e4 100644 --- a/src/components/Snackbar/index.jsx +++ b/src/components/Snackbar/index.jsx @@ -59,12 +59,11 @@ export default class Snackbar extends Component { /** Properties applied to the SnackbarContent element. */ snackbarContentProps: object, /** Callback fired when the component requests to be closed. */ - onClose: func, + onClose: func.isRequired, }; static defaultProps = { variant: 'success', - onClose: null, snackbarContentProps: null, }; @@ -81,7 +80,7 @@ export default class Snackbar extends Component { const isWarning = variant === 'warning'; return ( - + { @@ -65,7 +68,10 @@ export default class ViewWorkerType extends Component { variables: { workerType }, }); - this.setState({ actionLoading: false }); + this.setState({ + actionLoading: false, + showTerminateAllInstancesSnackbar: true, + }); } catch (error) { this.setState({ actionLoading: false, error: formatError(error) }); } @@ -80,12 +86,22 @@ export default class ViewWorkerType extends Component { variables: { region, instanceId: id }, }); - this.setState({ actionLoading: false }); + this.setState({ + actionLoading: false, + showTerminateInstanceSnackbar: true, + }); } catch (error) { this.setState({ actionLoading: false, error: formatError(error) }); } }; + handleSnackbarClose = () => { + this.setState({ + showTerminateAllInstancesSnackbar: false, + showTerminateInstanceSnackbar: false, + }); + }; + render() { const { classes, @@ -101,7 +117,13 @@ export default class ViewWorkerType extends Component { params: { workerType }, }, } = this.props; - const { currentTab, actionLoading } = this.state; + const { + currentTab, + actionLoading, + showTerminateAllInstancesSnackbar, + showTerminateInstanceSnackbar, + } = this.state; + const FIVE_SECONDS = 5000; return ( @@ -166,6 +188,18 @@ export default class ViewWorkerType extends Component { )} + + ); }