Skip to content
This repository was archived by the owner on Mar 23, 2019. It is now read-only.

Add a visual indicator when an EC2 instance is terminated #195

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/Snackbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -81,7 +80,7 @@ export default class Snackbar extends Component {
const isWarning = variant === 'warning';

return (
<MuiSnackbar {...props}>
<MuiSnackbar onClose={onClose} {...props}>
<SnackbarContent
className={classes[variant]}
action={
Expand Down
40 changes: 37 additions & 3 deletions src/views/AwsProvisioner/ViewWorkerType/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Button from '../../../components/Button';
import AwsProvisionerErrorsTable from '../../../components/AwsProvisionerErrorsTable';
import AwsProvisionerHealthTable from '../../../components/AwsProvisionerHealthTable';
import AwsProvisionerWorkerTypeStatus from '../../../components/AwsProvisionerWorkerTypeStatus';
import Snackbar from '../../../components/Snackbar';
import Ec2ResourcesTable from '../../../components/Ec2ResourcesTable';
import formatError from '../../../utils/formatError';
import workerTypeQuery from './workerType.graphql';
Expand Down Expand Up @@ -43,6 +44,8 @@ export default class ViewWorkerType extends Component {
state = {
currentTab: 0,
actionLoading: false,
showTerminateAllInstancesSnackbar: false,
showTerminateInstanceSnackbar: false,
};

handleTabChange = (e, currentTab) => {
Expand All @@ -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) });
}
Expand All @@ -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,
Expand All @@ -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 (
<Dashboard title={`AWS Provisioner ${workerType}`}>
Expand Down Expand Up @@ -166,6 +188,18 @@ export default class ViewWorkerType extends Component {
</div>
</Tooltip>
)}
<Snackbar
open={showTerminateAllInstancesSnackbar}
onClose={this.handleSnackbarClose}
autoHideDuration={FIVE_SECONDS}
message="A request has been sent to terminate all instances."
/>
<Snackbar
open={showTerminateInstanceSnackbar}
onClose={this.handleSnackbarClose}
autoHideDuration={FIVE_SECONDS}
message="A request has been sent to terminate the instance."
/>
</Dashboard>
);
}
Expand Down