Added functionality to delete icon on Policy Details screen (#1137)
* Added functionality to delete icon on Policy Details screen, typo fix in delete policy modal * Removed unneeded text * Updated field names
This commit is contained in:
@@ -74,7 +74,7 @@ const DeletePolicy = ({
|
|||||||
<DialogContent>
|
<DialogContent>
|
||||||
{deleteLoading && <LinearProgress />}
|
{deleteLoading && <LinearProgress />}
|
||||||
<DialogContentText id="alert-dialog-description">
|
<DialogContentText id="alert-dialog-description">
|
||||||
Are you sure you want to delete policy <b>{selectedPolicy}</b>?.
|
Are you sure you want to delete policy <b>{selectedPolicy}</b>?
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import { Button, IconButton, LinearProgress, Tooltip } from "@material-ui/core";
|
|||||||
import TableWrapper from "../Common/TableWrapper/TableWrapper";
|
import TableWrapper from "../Common/TableWrapper/TableWrapper";
|
||||||
import api from "../../../common/api";
|
import api from "../../../common/api";
|
||||||
import PageHeader from "../Common/PageHeader/PageHeader";
|
import PageHeader from "../Common/PageHeader/PageHeader";
|
||||||
|
import DeletePolicy from "./DeletePolicy";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { setErrorSnackMessage, setSnackBarMessage } from "../../../actions";
|
import { setErrorSnackMessage, setSnackBarMessage } from "../../../actions";
|
||||||
import { ErrorResponseHandler } from "../../../common/types";
|
import { ErrorResponseHandler } from "../../../common/types";
|
||||||
@@ -199,6 +200,7 @@ const PolicyDetails = ({
|
|||||||
const [loadingUsers, setLoadingUsers] = useState<boolean>(true);
|
const [loadingUsers, setLoadingUsers] = useState<boolean>(true);
|
||||||
const [filterGroups, setFilterGroups] = useState<string>("");
|
const [filterGroups, setFilterGroups] = useState<string>("");
|
||||||
const [loadingGroups, setLoadingGroups] = useState<boolean>(true);
|
const [loadingGroups, setLoadingGroups] = useState<boolean>(true);
|
||||||
|
const [deleteOpen, setDeleteOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
const saveRecord = (event: React.FormEvent) => {
|
const saveRecord = (event: React.FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -307,6 +309,15 @@ const PolicyDetails = ({
|
|||||||
|
|
||||||
const validSave = policyName.trim() !== "";
|
const validSave = policyName.trim() !== "";
|
||||||
|
|
||||||
|
const deletePolicy = () => {
|
||||||
|
setDeleteOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeDeleteModalAndRefresh = (refresh: boolean) => {
|
||||||
|
setDeleteOpen(false);
|
||||||
|
history.push(`/policies`);
|
||||||
|
};
|
||||||
|
|
||||||
const userViewAction = (user: any) => {
|
const userViewAction = (user: any) => {
|
||||||
history.push(`/users/${user}`);
|
history.push(`/users/${user}`);
|
||||||
};
|
};
|
||||||
@@ -322,6 +333,13 @@ const PolicyDetails = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
{deleteOpen && (
|
||||||
|
<DeletePolicy
|
||||||
|
deleteOpen={deleteOpen}
|
||||||
|
selectedPolicy={policyName}
|
||||||
|
closeDeleteModalAndRefresh={closeDeleteModalAndRefresh}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<PageHeader
|
<PageHeader
|
||||||
label={
|
label={
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@@ -343,18 +361,17 @@ const PolicyDetails = ({
|
|||||||
subTitle={<Fragment>IAM Policy</Fragment>}
|
subTitle={<Fragment>IAM Policy</Fragment>}
|
||||||
actions={
|
actions={
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Tooltip title={"Delete"}>
|
<Tooltip title="Delete Policy">
|
||||||
<IconButton
|
<IconButton
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="Delete"
|
aria-label="Delete Policy"
|
||||||
component="span"
|
component="span"
|
||||||
onClick={() => {
|
onClick={deletePolicy}
|
||||||
// setDeleteOpen(true);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<Tooltip title={"Refresh"}>
|
<Tooltip title={"Refresh"}>
|
||||||
<IconButton
|
<IconButton
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
Reference in New Issue
Block a user