refactor actions menu
This commit is contained in:
1 parent
7752e52fcd
commit
220fc080e6
1 file changed
+40
-66
@@ -2,23 +2,16 @@ import { useState } from "react";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import {
|
import { Button, IconButton, Menu, MenuItem, Stack, Typography } from "@mui/material";
|
||||||
Button,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Modal,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { logger } from "../../../../Utils/Logger";
|
import { logger } from "../../../../Utils/Logger";
|
||||||
import Settings from "../../../../assets/icons/settings-bold.svg?react";
|
import Settings from "../../../../assets/icons/settings-bold.svg?react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
import { GenericDialog } from "../../../../Components/Dialog/genericDialog";
|
||||||
|
|
||||||
const ActionsMenu = ({ isAdmin, maintenanceWindow, updateCallback }) => {
|
const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
||||||
maintenanceWindow;
|
maintenanceWindow;
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
@@ -155,71 +148,52 @@ const ActionsMenu = ({ isAdmin, maintenanceWindow, updateCallback }) => {
|
|||||||
Remove
|
Remove
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Modal
|
<GenericDialog
|
||||||
aria-labelledby="modal-delete-monitor"
|
title={"modal-delete-monitor"}
|
||||||
aria-describedby="delete-monitor-confirmation"
|
description={"delete-monitor-confirmation"}
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={(e) => {
|
close={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
|
theme={theme}
|
||||||
>
|
>
|
||||||
<Stack
|
<Typography
|
||||||
gap={theme.spacing(2)}
|
id="modal-delete-maintenance"
|
||||||
sx={{
|
component="h2"
|
||||||
position: "absolute",
|
variant="h2"
|
||||||
top: "50%",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translate(-50%, -50%)",
|
|
||||||
width: 400,
|
|
||||||
bgcolor: theme.palette.background.main,
|
|
||||||
border: 1,
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
boxShadow: 24,
|
|
||||||
p: theme.spacing(15),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Typography
|
Do you really want to remove this maintenance window?
|
||||||
id="modal-delete-maintenance"
|
</Typography>
|
||||||
component="h2"
|
<Stack
|
||||||
variant="h2"
|
direction="row"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mt={theme.spacing(12)}
|
||||||
|
justifyContent="flex-end"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="text"
|
||||||
|
color="info"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setIsOpen(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Do you really want to remove this maintenance window?
|
Cancel
|
||||||
</Typography>
|
</Button>
|
||||||
<Stack
|
<LoadingButton
|
||||||
direction="row"
|
loading={isLoading}
|
||||||
gap={theme.spacing(4)}
|
variant="contained"
|
||||||
mt={theme.spacing(12)}
|
color="error"
|
||||||
justifyContent="flex-end"
|
onClick={(e) => {
|
||||||
|
e.stopPropagation(e);
|
||||||
|
handleRemove(e);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
Delete
|
||||||
variant="text"
|
</LoadingButton>
|
||||||
color="info"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
setIsOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<LoadingButton
|
|
||||||
loading={isLoading}
|
|
||||||
variant="contained"
|
|
||||||
color="error"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation(e);
|
|
||||||
handleRemove(e);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</LoadingButton>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Modal>
|
</GenericDialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user