sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * ONAP POLICY-CLAMP |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2021 AT&T Intellectual Property. All rights |
| 6 | * reserved. |
| 7 | * ================================================================================ |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | * ============LICENSE_END============================================ |
| 20 | * =================================================================== |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | import React, { forwardRef } from 'react' |
| 25 | import Button from 'react-bootstrap/Button'; |
| 26 | import Modal from 'react-bootstrap/Modal'; |
| 27 | import styled from 'styled-components'; |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 28 | import AddBox from '@material-ui/icons/AddBox'; |
| 29 | import ArrowDownward from '@material-ui/icons/ArrowDownward'; |
| 30 | import Check from '@material-ui/icons/Check'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 31 | import ChevronLeft from '@material-ui/icons/ChevronLeft'; |
| 32 | import ChevronRight from '@material-ui/icons/ChevronRight'; |
| 33 | import Clear from '@material-ui/icons/Clear'; |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 34 | import DeleteOutline from '@material-ui/icons/DeleteOutline'; |
| 35 | import Edit from '@material-ui/icons/Edit'; |
| 36 | import FilterList from '@material-ui/icons/FilterList'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 37 | import FirstPage from '@material-ui/icons/FirstPage'; |
| 38 | import LastPage from '@material-ui/icons/LastPage'; |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 39 | import Remove from '@material-ui/icons/Remove'; |
| 40 | import SaveAlt from '@material-ui/icons/SaveAlt'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 41 | import Search from '@material-ui/icons/Search'; |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 42 | import ViewColumn from '@material-ui/icons/ViewColumn'; |
| 43 | import FormControlLabel from '@material-ui/core/FormControlLabel'; |
| 44 | import Switch from '@material-ui/core/Switch'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 45 | import MaterialTable from "material-table"; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 46 | import PolicyService from '../../../api/PolicyService'; |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 47 | import PolicyToscaService from '../../../api/PolicyToscaService'; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 48 | import Select from 'react-select'; |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 49 | import JSONEditor from '@json-editor/json-editor'; |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 50 | import OnapUtils from '../../../utils/OnapUtils'; |
| 51 | import Alert from 'react-bootstrap/Alert'; |
| 52 | |
| 53 | const DivWhiteSpaceStyled = styled.div` |
| 54 | white-space: pre; |
| 55 | ` |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 56 | |
| 57 | const ModalStyled = styled(Modal)` |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 58 | @media (min-width: 1200px) { |
| 59 | .modal-xl { |
| 60 | max-width: 96%; |
| 61 | } |
| 62 | } |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 63 | background-color: transparent; |
| 64 | ` |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 65 | const JsonEditorDiv = styled.div` |
| 66 | margin-top: 20px; |
| 67 | background-color: ${props => props.theme.toscaTextareaBackgroundColor}; |
| 68 | text-align: justify; |
| 69 | font-size: ${props => props.theme.toscaTextareaFontSize}; |
| 70 | width: 100%; |
| 71 | height: 30%; |
| 72 | border: 1px solid black; |
| 73 | ` |
| 74 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 75 | |
| 76 | const standardCellStyle = { border: '1px solid black' }; |
| 77 | const cellPdpGroupStyle = { backgroundColor: '#039be5', color: '#FFF', border: '1px solid black'}; |
| 78 | const headerStyle = { backgroundColor: '#ddd', border: '2px solid black' }; |
| 79 | const rowHeaderStyle = {backgroundColor:'#ddd', fontSize: '15pt', text: 'bold', border: '1px solid black'}; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 80 | |
| 81 | export default class ViewAllPolicies extends React.Component { |
| 82 | state = { |
| 83 | show: true, |
| 84 | content: 'Please select a policy to display it', |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 85 | selectedRowId: -1, |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 86 | policiesListData: [], |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 87 | prefixGrouping: false, |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 88 | showSuccessAlert: false, |
| 89 | showFailAlert: false, |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 90 | policyColumnsDefinition: [ |
| 91 | { |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 92 | title: "Policy Name", field: "name", |
| 93 | cellStyle: standardCellStyle, |
| 94 | headerStyle: headerStyle |
| 95 | }, |
| 96 | { |
| 97 | title: "Policy Version", field: "version", |
| 98 | cellStyle: standardCellStyle, |
| 99 | headerStyle: headerStyle |
| 100 | }, |
| 101 | { |
| 102 | title: "Policy Type", field: "type", |
| 103 | cellStyle: standardCellStyle, |
| 104 | headerStyle: headerStyle |
| 105 | }, |
| 106 | { |
| 107 | title: "Policy Type Version", field: "type_version", |
| 108 | cellStyle: standardCellStyle, |
| 109 | headerStyle: headerStyle |
| 110 | }, |
| 111 | { |
| 112 | title: "Deployed in PDP", field: "pdpGroupInfo.pdpGroup", |
| 113 | cellStyle: cellPdpGroupStyle, |
| 114 | headerStyle: headerStyle, |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 115 | render: rowData => this.renderPdpGroupDropBox(rowData), |
| 116 | grouping: false |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 117 | }, |
| 118 | { |
| 119 | title: "PDP Group", field: "pdpGroupInfo.pdpGroup", |
| 120 | cellStyle: cellPdpGroupStyle, |
| 121 | headerStyle: headerStyle |
| 122 | }, |
| 123 | { |
| 124 | title: "PDP SubGroup", field: "pdpGroupInfo.pdpSubGroup", |
| 125 | cellStyle: cellPdpGroupStyle, |
| 126 | headerStyle: headerStyle |
| 127 | } |
| 128 | ], |
| 129 | tableIcons: { |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 130 | Add: forwardRef((props, ref) => <AddBox {...props} ref={ref} />), |
| 131 | Check: forwardRef((props, ref) => <Check {...props} ref={ref} />), |
| 132 | Clear: forwardRef((props, ref) => <Clear {...props} ref={ref} />), |
| 133 | Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />), |
| 134 | DetailPanel: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />), |
| 135 | Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} />), |
| 136 | Export: forwardRef((props, ref) => <SaveAlt {...props} ref={ref} />), |
| 137 | Filter: forwardRef((props, ref) => <FilterList {...props} ref={ref} />), |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 138 | FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />), |
| 139 | LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />), |
| 140 | NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />), |
| 141 | PreviousPage: forwardRef((props, ref) => <ChevronLeft {...props} ref={ref} />), |
| 142 | ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />), |
| 143 | Search: forwardRef((props, ref) => <Search {...props} ref={ref} />), |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 144 | SortArrow: forwardRef((props, ref) => <ArrowDownward {...props} ref={ref} />), |
| 145 | ThirdStateCheck: forwardRef((props, ref) => <Remove {...props} ref={ref} />), |
| 146 | ViewColumn: forwardRef((props, ref) => <ViewColumn {...props} ref={ref} />) |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 147 | } |
| 148 | }; |
| 149 | |
| 150 | constructor(props, context) { |
| 151 | super(props, context); |
| 152 | this.handleClose = this.handleClose.bind(this); |
| 153 | this.renderPdpGroupDropBox = this.renderPdpGroupDropBox.bind(this); |
| 154 | this.handlePdpGroupChange = this.handlePdpGroupChange.bind(this); |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 155 | this.createJsonEditor = this.createJsonEditor.bind(this); |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 156 | this.handlePrefixGrouping = this.handlePrefixGrouping.bind(this); |
sebdet | a0a3a03 | 2021-02-16 14:53:43 +0100 | [diff] [blame] | 157 | this.handleDeletePolicy = this.handleDeletePolicy.bind(this); |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 158 | this.handleUpdatePolicy = this.handleUpdatePolicy.bind(this); |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 159 | this.handleCreateNewVersion = this.handleCreateNewVersion.bind(this); |
| 160 | this.disableAlert = this.disableAlert.bind(this); |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 161 | this.getAllPolicies(); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | handlePdpGroupChange(e) { |
| 166 | let pdpSplit = e.value.split("/"); |
| 167 | let selectedPdpGroup = pdpSplit[0]; |
| 168 | let selectedSubPdpGroup = pdpSplit[1]; |
| 169 | if (typeof selectedSubPdpGroup !== "undefined") { |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 170 | let temp = this.state.policiesListData; |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 171 | temp[this.state.selectedRowId]["pdpGroupInfo"] = {"pdpGroup":selectedPdpGroup,"pdpSubGroup":selectedSubPdpGroup}; |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 172 | this.setState({policiesListData: temp}); |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 173 | } else { |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 174 | delete this.state.policiesListData[this.state.selectedRowId]["pdpGroupInfo"]; |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 178 | createJsonEditor(toscaModel, editorData) { |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 179 | document.getElementById("policy-editor").innerHTML = ""; |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 180 | JSONEditor.defaults.themes.myBootstrap4 = JSONEditor.defaults.themes.bootstrap4.extend({ |
| 181 | getTab: function(text,tabId) { |
| 182 | var liel = document.createElement('li'); |
| 183 | liel.classList.add('nav-item'); |
| 184 | var ael = document.createElement("a"); |
| 185 | ael.classList.add("nav-link"); |
| 186 | ael.setAttribute("style",'padding:10px;max-width:160px;'); |
| 187 | ael.setAttribute("href", "#" + tabId); |
| 188 | ael.setAttribute('data-toggle', 'tab'); |
| 189 | text.setAttribute("style",'word-wrap:break-word;'); |
| 190 | ael.appendChild(text); |
| 191 | liel.appendChild(ael); |
| 192 | return liel; |
| 193 | } |
| 194 | }); |
| 195 | return new JSONEditor(document.getElementById("policy-editor"), |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 196 | { |
| 197 | schema: toscaModel, |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 198 | startval: editorData, |
| 199 | theme: 'myBootstrap4', |
| 200 | object_layout: 'grid', |
| 201 | disable_properties: false, |
| 202 | disable_edit_json: false, |
| 203 | disable_array_reorder: true, |
| 204 | disable_array_delete_last_row: true, |
| 205 | disable_array_delete_all_rows: false, |
| 206 | array_controls_top: true, |
| 207 | keep_oneof_values: false, |
| 208 | collapsed:true, |
| 209 | show_errors: 'always', |
| 210 | display_required_only: false, |
| 211 | show_opt_in: false, |
| 212 | prompt_before_delete: true, |
| 213 | required_by_default: false |
| 214 | }) |
| 215 | } |
| 216 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 217 | renderPdpGroupDropBox(dataRow) { |
| 218 | let optionItems = [{label: "NOT DEPLOYED", value: "NOT DEPLOYED"}]; |
| 219 | let selectedItem = {label: "NOT DEPLOYED", value: "NOT DEPLOYED"}; |
| 220 | if (typeof dataRow.supportedPdpGroups !== "undefined") { |
| 221 | for (const pdpGroup of dataRow["supportedPdpGroups"]) { |
| 222 | for (const pdpSubGroup of Object.values(pdpGroup)[0]) { |
| 223 | optionItems.push({ label: Object.keys(pdpGroup)[0]+"/"+pdpSubGroup, |
| 224 | value: Object.keys(pdpGroup)[0]+"/"+pdpSubGroup }); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | if (typeof dataRow.pdpGroupInfo !== "undefined") { |
| 229 | selectedItem = {label: dataRow["pdpGroupInfo"]["pdpGroup"]+"/"+dataRow["pdpGroupInfo"]["pdpSubGroup"], |
| 230 | value: dataRow["pdpGroupInfo"]["pdpGroup"]+"/"+dataRow["pdpGroupInfo"]["pdpSubGroup"]}; |
| 231 | } |
| 232 | return (<div style={{width: '250px'}}><Select value={selectedItem} options={optionItems} onChange={this.handlePdpGroupChange}/></div>); |
| 233 | } |
| 234 | |
| 235 | getAllPolicies() { |
| 236 | PolicyService.getPoliciesList().then(allPolicies => { |
| 237 | this.setState({ policiesListData: allPolicies["policies"] }) |
| 238 | }); |
| 239 | } |
| 240 | |
| 241 | handleClose() { |
| 242 | this.setState({ show: false }); |
| 243 | this.props.history.push('/') |
| 244 | } |
| 245 | |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 246 | handleOnRowClick(rowData) { |
| 247 | PolicyToscaService.getToscaPolicyModel(rowData["type"], rowData["type_version"]).then(respJsonPolicyTosca => { |
| 248 | this.setState({ |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 249 | selectedRowId: rowData.tableData.id, |
| 250 | selectedRowIdJsonSchema: respJsonPolicyTosca, |
| 251 | selectedRowIdPolicyProperties: rowData["properties"], |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 252 | jsonEditorForPolicy: this.createJsonEditor(respJsonPolicyTosca, rowData["properties"]) |
| 253 | }); |
| 254 | }); |
| 255 | } |
| 256 | |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 257 | handlePrefixGrouping(event) { |
| 258 | this.setState({prefixGrouping: event.target.checked}); |
sebdet | a0a3a03 | 2021-02-16 14:53:43 +0100 | [diff] [blame] | 259 | } |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 260 | |
sebdet | a0a3a03 | 2021-02-16 14:53:43 +0100 | [diff] [blame] | 261 | handleDeletePolicy(event, rowData) { |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 262 | return null; |
| 263 | } |
| 264 | |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 265 | customValidation(editorData) { |
| 266 | // method for sub-classes to override with customized validation |
| 267 | return []; |
| 268 | } |
| 269 | |
| 270 | handleCreateNewVersion() { |
| 271 | var editorData = this.state.jsonEditorForPolicy.getValue(); |
| 272 | var errors = this.state.jsonEditorForPolicy.validate(); |
| 273 | errors = errors.concat(this.customValidation(editorData)); |
| 274 | |
| 275 | if (errors.length !== 0) { |
| 276 | console.error("Errors detected during policy data validation ", errors); |
| 277 | this.setState({ |
| 278 | showFailAlert: true, |
| 279 | showMessage: 'Errors detected during policy data validation:\n' + OnapUtils.jsonEditorErrorFormatter(errors) |
| 280 | }); |
| 281 | return; |
| 282 | } else { |
| 283 | console.info("NO validation errors found in policy data"); |
| 284 | let newPolicy = JSON.parse(JSON.stringify(this.state.policiesListData[this.state.selectedRowId])); |
| 285 | newPolicy["properties"] = editorData; |
| 286 | let newVersion = this.bumpVersion(newPolicy["version"]); |
| 287 | newPolicy["version"] = newVersion; |
| 288 | newPolicy["metadata"]["policy-version"] = newVersion; |
| 289 | // Remove stuff added by UI |
| 290 | delete newPolicy["tableData"]; |
| 291 | PolicyService.createNewPolicy(newPolicy["type"], newPolicy["type_version"], newPolicy).then(respPolicyCreation => { |
| 292 | if (respPolicyCreation === "") { |
| 293 | //it indicates a failure |
| 294 | this.setState({ |
| 295 | showFailAlert: true, |
| 296 | showMessage: 'Policy Creation Failure' |
| 297 | }); |
| 298 | } else { |
| 299 | this.setState({ |
| 300 | showSuccessAlert: true, |
| 301 | showMessage: 'Policy in version ' + newVersion + ' created successfully' |
| 302 | }); |
| 303 | } |
| 304 | }) |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | bumpVersion(versionToBump) { |
| 309 | let semVer = versionToBump.split("."); |
| 310 | return parseInt(semVer[0])+1 + "." + semVer[1] + "." + semVer[2]; |
sebdet | a0a3a03 | 2021-02-16 14:53:43 +0100 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | handleUpdatePolicy() { |
| 314 | this.setState({ show: false }); |
| 315 | this.props.history.push('/') |
| 316 | } |
| 317 | |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 318 | disableAlert() { |
| 319 | this.setState ({ showSuccessAlert: false, showFailAlert: false }); |
| 320 | } |
| 321 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 322 | render() { |
| 323 | return ( |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 324 | <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false}> |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 325 | <Modal.Header closeButton> |
| 326 | </Modal.Header> |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 327 | |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 328 | <Modal.Body> |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 329 | <FormControlLabel |
| 330 | control={<Switch checked={this.state.prefixGrouping} onChange={this.handlePrefixGrouping} />} |
| 331 | label="Group by prefix" |
| 332 | /> |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 333 | <MaterialTable |
| 334 | title={"View All Policies in Policy Engine"} |
| 335 | data={this.state.policiesListData} |
| 336 | columns={this.state.policyColumnsDefinition} |
| 337 | icons={this.state.tableIcons} |
sebdet | 3718a16 | 2021-02-12 17:18:47 +0100 | [diff] [blame] | 338 | onRowClick={(event, rowData) => {this.handleOnRowClick(rowData)}} |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 339 | options={{ |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 340 | grouping: true, |
| 341 | exportButton: true, |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 342 | headerStyle:rowHeaderStyle, |
| 343 | rowStyle: rowData => ({ |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 344 | backgroundColor: (this.state.selectedRowId !== -1 && this.state.selectedRowId === rowData.tableData.id) ? '#EEE' : '#FFF' |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 345 | }) |
| 346 | }} |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 347 | actions={[ |
| 348 | { |
| 349 | icon: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />), |
| 350 | tooltip: 'Delete Policy', |
sebdet | a0a3a03 | 2021-02-16 14:53:43 +0100 | [diff] [blame] | 351 | onClick: (event, rowData) => this.handleDeletePolicy(event, rowData) |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 352 | } |
| 353 | ]} |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 354 | /> |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 355 | <JsonEditorDiv> |
| 356 | <h5>Policy Properties Editor</h5> |
| 357 | <div id="policy-editor" title="Policy Properties"/> |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 358 | <Button variant="secondary" title="Create a new policy version from the defined parameters" |
| 359 | onClick={this.handleCreateNewVersion}>Create New Version</Button> |
| 360 | <Button variant="secondary" title="Update the current policy version, BE CAREFUL this will undeploy the policy from PDP, delete it and then recreate the policy" |
| 361 | onClick={this.handleUpdatePolicy}>Update Current Version</Button> |
sebdet | 3728547 | 2021-02-15 18:09:38 +0100 | [diff] [blame] | 362 | </JsonEditorDiv> |
sebdet | c427e64 | 2021-02-17 17:53:17 +0100 | [diff] [blame^] | 363 | <Alert variant="success" show={this.state.showSuccessAlert} onClose={this.disableAlert} dismissible> |
| 364 | <DivWhiteSpaceStyled> |
| 365 | {this.state.showMessage} |
| 366 | </DivWhiteSpaceStyled> |
| 367 | </Alert> |
| 368 | <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> |
| 369 | <DivWhiteSpaceStyled> |
| 370 | {this.state.showMessage} |
| 371 | </DivWhiteSpaceStyled> |
| 372 | </Alert> |
sebdet | eb8e3f1 | 2021-01-24 18:12:36 +0100 | [diff] [blame] | 373 | </Modal.Body> |
| 374 | <Modal.Footer> |
| 375 | <Button variant="secondary" onClick={this.handleClose}>Close</Button> |
| 376 | </Modal.Footer> |
| 377 | </ModalStyled> |
| 378 | ); |
| 379 | } |
| 380 | } |