From 0fb4ba41b504be33bdf7e1ac93d24206ba77e319 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 25 Apr 2021 21:54:56 -0700 Subject: [PATCH] ui: show a spinner when saving/deleting policy (#1018) Fixes #999 --- htmlui/src/PolicyEditor.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htmlui/src/PolicyEditor.js b/htmlui/src/PolicyEditor.js index 3ee1c7347..efc9dd879 100644 --- a/htmlui/src/PolicyEditor.js +++ b/htmlui/src/PolicyEditor.js @@ -3,9 +3,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import axios from 'axios'; import React, { Component } from 'react'; import Button from 'react-bootstrap/Button'; -import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Form from 'react-bootstrap/Form'; +import Row from 'react-bootstrap/Row'; +import Spinner from 'react-bootstrap/Spinner'; import Tab from 'react-bootstrap/Tab'; import Tabs from 'react-bootstrap/Tabs'; import { handleChange, OptionalBoolean, OptionalNumberField, RequiredBoolean, stateProperty, StringList } from './forms'; @@ -121,18 +122,23 @@ export class PolicyEditor extends Component { } } + this.setState({saving: true}); axios.put(this.snapshotURL(this.props), policy).then(result => { this.props.close(); }).catch(error => { + this.setState({saving: false}); errorAlert(error, 'Error saving policy'); }); } deletePolicy() { if (window.confirm('Are you sure you want to delete this policy?')) { + this.setState({saving: true}); + axios.delete(this.snapshotURL(this.props)).then(result => { this.props.close(); }).catch(error => { + this.setState({saving: false}); errorAlert(error, 'Error deleting policy'); }); } @@ -264,11 +270,15 @@ export class PolicyEditor extends Component { {RequiredBoolean(this, "Disable Parent Policy Evaluation (prevents any parent policies from affecting this directory and subdirectories)", "policy.noParent")} - + {!this.state.isNew && <>  - + } - + {this.state.saving && <> +   + + } + {!this.props.embedded && <>
JSON representation