diff --git a/client/src/Pages/Infrastructure/Monitors/Components/MonitorsTableMenu/index.jsx b/client/src/Pages/Infrastructure/Monitors/Components/MonitorsTableMenu/index.jsx index 15193da3e..9875e0697 100644 --- a/client/src/Pages/Infrastructure/Monitors/Components/MonitorsTableMenu/index.jsx +++ b/client/src/Pages/Infrastructure/Monitors/Components/MonitorsTableMenu/index.jsx @@ -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 && Remove} + openDetails(monitor.id)}>Details + {isAdmin && openConfigure(monitor.id)}>Configure} + {isAdmin && ( + + {monitor.isActive ? "Pause" : "Resume"} + + )} + {isAdmin && Remove}