X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ui-react%2Fsrc%2Fcomponents%2Fdialogs%2FPerformActions.js;h=f6001e21f411e4bb409d2f3df0fcfe9b3d313c73;hb=4fb32395392c3c65ad8dcadc42d7804d2e656c63;hp=66b192863591ddea3c5f6c9a0316d72377cae838;hpb=0efeb6b141cb4abe84af8eb38e26d5ed1ab73bb0;p=clamp.git diff --git a/ui-react/src/components/dialogs/PerformActions.js b/ui-react/src/components/dialogs/PerformActions.js index 66b19286..f6001e21 100644 --- a/ui-react/src/components/dialogs/PerformActions.js +++ b/ui-react/src/components/dialogs/PerformActions.js @@ -22,24 +22,19 @@ */ import React from 'react'; import LoopActionService from '../../api/LoopActionService'; -import Spinner from 'react-bootstrap/Spinner' -import styled from 'styled-components'; -const StyledSpinnerDiv = styled.div` - justify-content: center !important; - display: flex !important; -`; export default class PerformActions extends React.Component { state = { loopName: this.props.loopCache.getLoopName(), loopAction: this.props.loopAction }; + constructor(props, context) { super(props, context); - this.refreshStatus = this.refreshStatus.bind(this); } + componentWillReceiveProps(newProps) { this.setState({ loopName: newProps.loopCache.getLoopName(), @@ -51,35 +46,50 @@ export default class PerformActions extends React.Component { const action = this.state.loopAction; const loopName = this.state.loopName; - LoopActionService.performAction(loopName, action).then(pars => { - this.props.showAlert("Action " + action + " successfully performed"); - // refresh status and update loop logs - this.refreshStatus(loopName); + if (action === 'delete') { + if (window.confirm('You are about to remove Control Loop Model "' + loopName + + '". Select OK to continue with deletion or Cancel to keep the model.') === false) { + return; + } + } + + this.props.setBusyLoading(); // Alert top level to start block user clicks + + LoopActionService.performAction(loopName, action) + .then(pars => { + this.props.showSucAlert("Action " + action + " successfully performed"); + if (action === 'delete') { + this.props.updateLoopFunction(null); + this.props.history.push('/'); + } else { + // refresh status and update loop logs + this.refreshStatus(loopName); + } }) .catch(error => { - this.props.showAlert("Action " + action + " failed"); + this.props.showFailAlert("Action " + action + " failed"); // refresh status and update loop logs this.refreshStatus(loopName); - }); - + }) + .finally(() => this.props.clearBusyLoading()); } refreshStatus(loopName) { - LoopActionService.refreshStatus(loopName).then(data => { + + this.props.setBusyLoading(); + + LoopActionService.refreshStatus(loopName) + .then(data => { this.props.updateLoopFunction(data); this.props.history.push('/'); }) - .catch(error => { + .catch(error => { this.props.history.push('/'); - }); + }) + .finally(() => this.props.clearBusyLoading()); } render() { - return ( - - - - - ); + return null; } }