refactor common components out
This commit is contained in:
1 parent
1e7e7c7365
commit
e570b76d88
7 files changed
+30
-22
No files matched your search
+5
-5
@@ -2,16 +2,16 @@ import { useState } from "react";
|
|||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { createToast } from "../../../../../Utils/toastUtils";
|
import { createToast } from "../../Utils/toastUtils";
|
||||||
import { logger } from "../../../../../Utils/Logger";
|
import { logger } from "../../Utils/Logger";
|
||||||
import { IconButton, Menu, MenuItem } from "@mui/material";
|
import { IconButton, Menu, MenuItem } from "@mui/material";
|
||||||
import {
|
import {
|
||||||
deleteUptimeMonitor,
|
deleteUptimeMonitor,
|
||||||
pauseUptimeMonitor,
|
pauseUptimeMonitor,
|
||||||
} from "../../../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
} from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
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 Dialog from "../../../../../Components/Dialog";
|
import Dialog from "../../Components/Dialog";
|
||||||
|
|
||||||
const ActionsMenu = ({
|
const ActionsMenu = ({
|
||||||
monitor,
|
monitor,
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { Stack, Typography } from "@mui/material";
|
import { Stack, Typography } from "@mui/material";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import Dot from "../../../../../Components/Dot";
|
import Dot from "../Dot";
|
||||||
/**
|
/**
|
||||||
* Host component.
|
* Host component.
|
||||||
* This subcomponent receives a params object and displays the host details.
|
* This subcomponent receives a params object and displays the host details.
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
|
// Components
|
||||||
import DataTable from "../../../../../Components/Table";
|
import DataTable from "../../../../../Components/Table";
|
||||||
import BarChart from "../../../../../Components/Charts/BarChart";
|
import BarChart from "../../../../../Components/Charts/BarChart";
|
||||||
import { Box } from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
import { StatusLabel } from "../../../../../Components/Label";
|
import { StatusLabel } from "../../../../../Components/Label";
|
||||||
|
import Host from "../../../../../Components/Host";
|
||||||
|
|
||||||
//REFACTOR
|
// Utils
|
||||||
import Host from "../../../../Uptime/Monitors/Components/Host";
|
|
||||||
import ActionsMenu from "../../../../Uptime/Monitors/Components/ActionsMenu";
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useMonitorUtils } from "../../../../../Hooks/useMonitorUtils";
|
import { useMonitorUtils } from "../../../../../Hooks/useMonitorUtils";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
// Constants
|
||||||
const TYPE_MAP = {
|
const TYPE_MAP = {
|
||||||
distributed_http: "Distributed HTTP",
|
distributed_http: "Distributed HTTP",
|
||||||
};
|
};
|
||||||
@@ -59,12 +62,7 @@ const MonitorTable = ({ isLoading, monitors }) => {
|
|||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
content: "Actions",
|
content: "Actions",
|
||||||
render: (row) => (
|
render: (row) => <span>{"TODO"}</span>,
|
||||||
<ActionsMenu
|
|
||||||
monitor={row.monitor}
|
|
||||||
isAdmin={true}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -88,4 +86,9 @@ const MonitorTable = ({ isLoading, monitors }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MonitorTable.propTypes = {
|
||||||
|
isLoading: PropTypes.bool,
|
||||||
|
monitors: PropTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
export default MonitorTable;
|
export default MonitorTable;
|
||||||
@@ -8,15 +8,12 @@ import GenericFallback from "../../../Components/GenericFallback";
|
|||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
|
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
|
||||||
// Constants
|
// Constants
|
||||||
const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }];
|
const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }];
|
||||||
|
|
||||||
const DistributedUptimeMonitors = () => {
|
const DistributedUptimeMonitors = () => {
|
||||||
// Redux state
|
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
|
||||||
// Local state
|
// Local state
|
||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Components
|
// Components
|
||||||
import DataTable from "../../../../../Components/Table";
|
import DataTable from "../../../../../Components/Table";
|
||||||
import Host from "../../../../Uptime/Monitors/Components/Host";
|
import Host from "../../../../../Components/Host";
|
||||||
import { StatusLabel } from "../../../../../Components/Label";
|
import { StatusLabel } from "../../../../../Components/Label";
|
||||||
import { Stack } from "@mui/material";
|
import { Stack } from "@mui/material";
|
||||||
import { InfrastructureMenu } from "../MonitorsTableMenu";
|
import { InfrastructureMenu } from "../MonitorsTableMenu";
|
||||||
@@ -12,6 +12,7 @@ import CustomGauge from "../../../../../Components/Charts/CustomGauge";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import useUtils from "../../../../Uptime/Monitors/Hooks/useUtils";
|
import useUtils from "../../../../Uptime/Monitors/Hooks/useUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const MonitorsTable = ({ shouldRender, monitors, isAdmin, handleActionMenuDelete }) => {
|
const MonitorsTable = ({ shouldRender, monitors, isAdmin, handleActionMenuDelete }) => {
|
||||||
// Utils
|
// Utils
|
||||||
@@ -131,4 +132,11 @@ const MonitorsTable = ({ shouldRender, monitors, isAdmin, handleActionMenuDelete
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MonitorsTable.propTypes = {
|
||||||
|
shouldRender: PropTypes.bool,
|
||||||
|
monitors: PropTypes.array,
|
||||||
|
isAdmin: PropTypes.bool,
|
||||||
|
handleActionMenuDelete: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
export default MonitorsTable;
|
export default MonitorsTable;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Components
|
// Components
|
||||||
import { Stack, Box } from "@mui/material";
|
import { Stack, Box } from "@mui/material";
|
||||||
import Host from "../../../../Uptime/Monitors/Components/Host";
|
import Host from "../../../../../Components/Host";
|
||||||
import StatusPageBarChart from "../../../../../Components/Charts/StatusPageBarChart";
|
import StatusPageBarChart from "../../../../../Components/Charts/StatusPageBarChart";
|
||||||
import { StatusLabel } from "../../../../../Components/Label";
|
import { StatusLabel } from "../../../../../Components/Label";
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { Box, Stack } from "@mui/material";
|
|||||||
import DataTable from "../../../../../Components/Table";
|
import DataTable from "../../../../../Components/Table";
|
||||||
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
|
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
|
||||||
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
|
import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
|
||||||
import Host from "../Host";
|
import Host from "../../../../../Components/Host";
|
||||||
import { StatusLabel } from "../../../../../Components/Label";
|
import { StatusLabel } from "../../../../../Components/Label";
|
||||||
import BarChart from "../../../../../Components/Charts/BarChart";
|
import BarChart from "../../../../../Components/Charts/BarChart";
|
||||||
import ActionsMenu from "../ActionsMenu";
|
import ActionsMenu from "../../../../../Components/ActionsMenu";
|
||||||
|
|
||||||
import LoadingSpinner from "../LoadingSpinner";
|
import LoadingSpinner from "../LoadingSpinner";
|
||||||
import TableSkeleton from "../../../../../Components/Table/skeleton";
|
import TableSkeleton from "../../../../../Components/Table/skeleton";
|
||||||
|
|||||||
Reference in new issue
Block a user