diff options
author | Sébastien Determe <sebastien.determe@intl.att.com> | 2020-04-21 12:27:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-21 12:27:17 +0000 |
commit | 8b9918e7e3b1398ece5470f36be1d9dd13e29bee (patch) | |
tree | 8d2607bf1a90a8b32bc2e3e65832453d9d030348 /ui-react/src/components/dialogs/Loop/ModifyLoopModal.js | |
parent | dcfbed79c6da8b9c737c979b9a0410d37142499d (diff) | |
parent | c65613938d30565d4dc913fbf2d48002390119d3 (diff) |
Merge "Prevent adding same type of Op policy"
Diffstat (limited to 'ui-react/src/components/dialogs/Loop/ModifyLoopModal.js')
-rw-r--r-- | ui-react/src/components/dialogs/Loop/ModifyLoopModal.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js index 8c6740564..5154a880b 100644 --- a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js @@ -37,7 +37,7 @@ import Search from '@material-ui/icons/Search'; import LoopService from '../../../api/LoopService'; import Tabs from 'react-bootstrap/Tabs'; import Tab from 'react-bootstrap/Tab'; - +import Alert from 'react-bootstrap/Alert'; const ModalStyled = styled(Modal)` background-color: transparent; @@ -65,6 +65,7 @@ export default class ModifyLoopModal extends React.Component { toscaPolicyModelsData: [], selectedPolicyModelsData: [], key: 'add', + showFailAlert: false, toscaColumns: [ { title: "#", field: "index", render: rowData => rowData.tableData.id + 1, cellStyle: cellStyle, @@ -166,10 +167,25 @@ export default class ModifyLoopModal extends React.Component { this.props.history.push('/'); } + renderAlert() { + return ( + <div> + <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> + {this.state.showMessage} + </Alert> + </div> + ); + } + handleAdd() { - LoopService.addOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version); - this.props.loadLoopFunction(this.state.loopCache.getLoopName()); - this.handleClose(); + LoopService.addOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version) + .then(pars => { + this.props.loadLoopFunction(this.state.loopCache.getLoopName()); + this.handleClose(); + }) + .catch(error => { + this.setState({ showFailAlert: true, showMessage: "Adding failed with error: " + error.message}); + }); } handleRemove() { @@ -198,13 +214,14 @@ export default class ModifyLoopModal extends React.Component { rowStyle: rowData => ({ backgroundColor: (this.state.selectedRowData !== {} && this.state.selectedRowData.tableData !== undefined && this.state.selectedRowData.tableData.id === rowData.tableData.id) ? '#EEE' : '#FFF' - }) + }) }} /> <div> <TextModal value={this.state.content} onChange={this.handleYamlContent}/> </div> </Modal.Body> + {this.renderAlert()} </Tab> <Tab eventKey="remove" title="Remove Operational Policies"> <Modal.Body> |