diff --git a/Client/src/Pages/Monitors/ActionMenu/index.jsx b/Client/src/Pages/Monitors/ActionMenu/index.jsx
deleted file mode 100644
index a8fb437bc..000000000
--- a/Client/src/Pages/Monitors/ActionMenu/index.jsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { useState } from "react";
-import { Box, IconButton, Menu, MenuItem } from "@mui/material";
-import Settings from "../../../assets/icons/settings-bold.svg?react";
-import { useNavigate } from "react-router-dom";
-
-const ActionsMenu = ({ monitor }) => {
- const [anchorEl, setAnchorEl] = useState(null);
- const [actions, setActions] = useState({});
- const openMenu = (event, id, url) => {
- event.preventDefault();
- setAnchorEl(event.currentTarget);
- setActions({ id: id, url: url });
- };
-
- const openRemove = () => {
- closeMenu();
- setIsOpen(true);
- };
-
- const closeMenu = () => {
- setAnchorEl(null);
- };
-
- const navigate = useNavigate();
- return (
- <>
- {
- event.stopPropagation();
- openMenu(
- event,
- monitor._id,
- monitor.type === "ping" ? null : monitor.url
- );
- }}
- sx={{
- "&:focus": {
- outline: "none",
- },
- }}
- >
-
-
-
-
- >
- );
-};
-
-export default ActionsMenu;
diff --git a/Client/src/Pages/Monitors/index.jsx b/Client/src/Pages/Monitors/index.jsx
index 24ab4d172..19a4b4c4f 100644
--- a/Client/src/Pages/Monitors/index.jsx
+++ b/Client/src/Pages/Monitors/index.jsx
@@ -25,7 +25,172 @@ import {
Stack,
Typography,
} from "@mui/material";
-import ActionsMenu from "./ActionMenu";
+
+import Settings from "../../assets/icons/settings-bold.svg?react";
+
+const ActionsMenu = ({ monitor }) => {
+ const [anchorEl, setAnchorEl] = useState(null);
+ const [actions, setActions] = useState({});
+ const [isOpen, setIsOpen] = useState(false);
+ const dispatch = useDispatch();
+ const theme = useTheme();
+ const authState = useSelector((state) => state.auth);
+
+ const handleRemove = async (event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ let monitor = { _id: actions.id };
+ const action = await dispatch(
+ deleteUptimeMonitor({ authToken: authState.authToken, monitor })
+ );
+ if (action.meta.requestStatus === "fulfilled") {
+ setIsOpen(false); // close modal
+ dispatch(getUptimeMonitorsByUserId(authState.authToken));
+ createToast({ body: "Monitor deleted successfully." });
+ } else {
+ createToast({ body: "Failed to delete monitor." });
+ }
+ };
+
+ const openMenu = (event, id, url) => {
+ event.preventDefault();
+ event.stopPropagation();
+ setAnchorEl(event.currentTarget);
+ setActions({ id: id, url: url });
+ };
+
+ const openRemove = (e) => {
+ closeMenu(e);
+ setIsOpen(true);
+ };
+
+ const closeMenu = (e) => {
+ e.stopPropagation();
+ setAnchorEl(null);
+ };
+
+ const navigate = useNavigate();
+ return (
+ <>
+ {
+ event.stopPropagation();
+ openMenu(
+ event,
+ monitor._id,
+ monitor.type === "ping" ? null : monitor.url
+ );
+ }}
+ sx={{
+ "&:focus": {
+ outline: "none",
+ },
+ }}
+ >
+
+
+
+
+ setIsOpen(false)}
+ disablePortal
+ >
+
+
+ Do you really want to delete this monitor?
+
+
+ Once deleted, this monitor cannot be retrieved.
+
+
+
+
+
+ >
+ );
+};
/**
* Host component.
@@ -111,23 +276,6 @@ const Monitors = () => {
const authState = useSelector((state) => state.auth);
const dispatch = useDispatch({});
- const [isOpen, setIsOpen] = useState(false);
-
- const handleRemove = async (event) => {
- event.preventDefault();
- let monitor = { _id: actions.id };
- const action = await dispatch(
- deleteUptimeMonitor({ authToken: authState.authToken, monitor })
- );
- if (action.meta.requestStatus === "fulfilled") {
- setIsOpen(false); // close modal
- dispatch(getUptimeMonitorsByUserId(authState.authToken));
- createToast({ body: "Monitor deleted successfully." });
- } else {
- createToast({ body: "Failed to delete monitor." });
- }
- };
-
useEffect(() => {
dispatch(getUptimeMonitorsByUserId(authState.authToken));
}, [authState.authToken, dispatch]);
@@ -294,53 +442,6 @@ const Monitors = () => {
)}
>
)}
-
- setIsOpen(false)}
- disablePortal
- >
-
-
- Do you really want to delete this monitor?
-
-
- Once deleted, this monitor cannot be retrieved.
-
-
- setIsOpen(false)}
- />
-
-
-
-
);
};