Fix #2471: Add Details, Configure, and Pause options to infrastructure action menu
This commit is contained in:
1 parent
906a76c545
commit
74cef5adb1
1 file changed
+24
-1
@@ -9,6 +9,7 @@ import Settings from "../../../../../assets/icons/settings-bold.svg?react";
|
||||
import PropTypes from "prop-types";
|
||||
import Dialog from "../../../../../Components/Dialog";
|
||||
import { networkService } from "../../../../../Utils/NetworkService.js";
|
||||
import { usePauseMonitor } from "../../../../../Hooks/monitorHooks";
|
||||
|
||||
/**
|
||||
* InfrastructureMenu Component
|
||||
@@ -29,6 +30,7 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
const theme = useTheme();
|
||||
const [pauseMonitor] = usePauseMonitor();
|
||||
|
||||
const openMenu = (e) => {
|
||||
e.stopPropagation();
|
||||
@@ -54,6 +56,20 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||
navigate(`/infrastructure/${id}`);
|
||||
}
|
||||
|
||||
const openConfigure = (id) => {
|
||||
navigate(`/infrastructure/configure/${id}`);
|
||||
}
|
||||
|
||||
const handlePause = async () => {
|
||||
try {
|
||||
await pauseMonitor({ monitorId: monitor.id });
|
||||
createToast({ body: `Monitor ${monitor.isActive ? "paused" : "resumed"} successfully.` });
|
||||
updateCallback();
|
||||
} catch (error) {
|
||||
createToast({ body: `Failed to ${monitor.isActive ? "pause" : "resume"} monitor.` });
|
||||
}
|
||||
}
|
||||
|
||||
const handleRemove = async () => {
|
||||
try {
|
||||
await networkService.deleteMonitorById({
|
||||
@@ -105,7 +121,14 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
{isAdmin && <MenuItem onClick={openRemove}>Remove</MenuItem>}
|
||||
<MenuItem onClick={() => openDetails(monitor.id)}>Details</MenuItem>
|
||||
{isAdmin && <MenuItem onClick={() => openConfigure(monitor.id)}>Configure</MenuItem>}
|
||||
{isAdmin && (
|
||||
<MenuItem onClick={handlePause}>
|
||||
{monitor.isActive ? "Pause" : "Resume"}
|
||||
</MenuItem>
|
||||
)}
|
||||
{isAdmin && <MenuItem onClick={openRemove} sx={{ color: theme.palette.error.main }}>Remove</MenuItem>}
|
||||
</Menu>
|
||||
<Dialog
|
||||
open={isDialogOpen}
|
||||
|
||||
Reference in new issue
Block a user