From ea2969fd3bbfe52cbe4f41546dd40d68321c233b Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 25 Feb 2021 13:58:36 +0100 Subject: Add "delete policy" feature in UI Add delete policy functionality (call to backend) + insert Policies array in a tabs for future policy create operation + Ask column names during export of the test db Issue-ID: POLICY-2929 Signed-off-by: sebdet Change-Id: I4108c9fa2b986cc5aff11b8710bc6ad722c52f46 Signed-off-by: sebdet --- .../components/dialogs/Policy/ViewAllPolicies.js | 102 ++++++++++++--------- 1 file changed, 60 insertions(+), 42 deletions(-) (limited to 'ui-react/src/components') diff --git a/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js b/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js index dfebc51d8..b159584dd 100644 --- a/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js +++ b/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js @@ -49,9 +49,11 @@ import Select from 'react-select'; import JSONEditor from '@json-editor/json-editor'; import OnapUtils from '../../../utils/OnapUtils'; import Alert from 'react-bootstrap/Alert'; +import Tabs from 'react-bootstrap/Tabs'; +import Tab from 'react-bootstrap/Tab'; const DivWhiteSpaceStyled = styled.div` - white-space: pre; + white-space: pre; ` const ModalStyled = styled(Modal)` @@ -259,7 +261,22 @@ export default class ViewAllPolicies extends React.Component { } handleDeletePolicy(event, rowData) { - return null; + PolicyService.deletePolicy(rowData["type"], rowData["type_version"], rowData["name"],rowData["version"]).then( + respPolicyDeletion => { + if (respPolicyDeletion === "") { + //it indicates a failure + this.setState({ + showFailAlert: true, + showMessage: 'Policy Deletion Failure' + }); + } else { + this.setState({ + showSuccessAlert: true, + showMessage: 'Policy successfully Deleted' + }); + } + } + ) } customValidation(editorData) { @@ -324,53 +341,54 @@ export default class ViewAllPolicies extends React.Component { - - - } - label="Group by prefix" - /> - {this.handleOnRowClick(rowData)}} - options={{ - grouping: true, - exportButton: true, - headerStyle:rowHeaderStyle, - rowStyle: rowData => ({ - backgroundColor: (this.state.selectedRowId !== -1 && this.state.selectedRowId === rowData.tableData.id) ? '#EEE' : '#FFF' - }) - }} - actions={[ - { - icon: forwardRef((props, ref) => ), - tooltip: 'Delete Policy', - onClick: (event, rowData) => this.handleDeletePolicy(event, rowData) - } - ]} - /> + this.setState({ key, selectedRowData: {} })}> + + + } + label="Group by prefix" + /> + {this.handleOnRowClick(rowData)}} + options={{ + grouping: true, + exportButton: true, + headerStyle:rowHeaderStyle, + rowStyle: rowData => ({ + backgroundColor: (this.state.selectedRowId !== -1 && this.state.selectedRowId === rowData.tableData.id) ? '#EEE' : '#FFF' + }) + }} + actions={[ + { + icon: forwardRef((props, ref) => ), + tooltip: 'Delete Policy', + onClick: (event, rowData) => this.handleDeletePolicy(event, rowData) + } + ]} + /> + + +
Policy Properties Editor
- - - {this.state.showMessage} - - - - - {this.state.showMessage} - - - + + {this.state.showMessage} + + + + + {this.state.showMessage} + + -- cgit 1.2.3-korg