remove unused component/imports

This commit is contained in:
Alex Holliday
2025-06-16 11:34:41 +08:00
parent e173269acd
commit 30a610511c
8 changed files with 7 additions and 148 deletions

View File

@@ -4,14 +4,14 @@ import { useTheme } from "@emotion/react";
import SkeletonLayout from "./skeleton";
const MonitorCountHeader = ({
shouldRender = true,
isLoading = false,
monitorCount,
heading = "monitors",
sx,
children,
}) => {
const theme = useTheme();
if (!shouldRender) return <SkeletonLayout />;
if (isLoading) return <SkeletonLayout />;
if (monitorCount === 1) {
heading = "monitor";
@@ -42,7 +42,7 @@ const MonitorCountHeader = ({
};
MonitorCountHeader.propTypes = {
shouldRender: PropTypes.bool,
isLoading: PropTypes.bool,
monitorCount: PropTypes.number,
heading: PropTypes.string,
children: PropTypes.node,

View File

@@ -1,41 +0,0 @@
import { Button, Box } from "@mui/material";
import { useTheme } from "@emotion/react";
import { useNavigate } from "react-router-dom";
import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
import PropTypes from "prop-types";
const ConfigButton = ({ shouldRender = true, monitorId, path }) => {
const theme = useTheme();
const navigate = useNavigate();
if (!shouldRender) return null;
return (
<Box alignSelf="flex-end">
<Button
variant="contained"
color="secondary"
onClick={() => navigate(`/${path}/configure/${monitorId}`)}
sx={{
px: theme.spacing(5),
"& svg": {
mr: theme.spacing(3),
"& path": {
/* Should always be contrastText for the button color */
stroke: theme.palette.secondary.contrastText,
},
},
}}
>
<SettingsIcon /> Configure
</Button>
</Box>
);
};
ConfigButton.propTypes = {
shouldRender: PropTypes.bool,
monitorId: PropTypes.string,
path: PropTypes.string,
};
export default ConfigButton;

View File

@@ -1,76 +0,0 @@
import { Stack, Typography } from "@mui/material";
import PulseDot from "../Animated/PulseDot";
import Dot from "../Dot";
import { useTheme } from "@emotion/react";
import { useMonitorUtils } from "../../Hooks/useMonitorUtils";
import { formatDurationRounded } from "../../Utils/timeUtils";
import ConfigButton from "./ConfigButton";
import SkeletonLayout from "./skeleton";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
const MonitorStatusHeader = ({ path, isLoading = false, isAdmin, monitor }) => {
const theme = useTheme();
const { t } = useTranslation();
const { statusColor, determineState } = useMonitorUtils();
if (isLoading) {
return <SkeletonLayout />;
}
const intervalText = t("monitorStatus.checkingEvery", {
interval: formatDurationRounded(monitor?.interval),
});
const captureVersion = monitor?.stats?.aggregateData?.latestCheck?.capture?.version;
return (
<Stack
direction="row"
justifyContent="space-between"
>
<Stack>
<Typography variant="monitorName">{monitor?.name}</Typography>
<Stack
direction="row"
alignItems={"center"}
gap={theme.spacing(4)}
>
<PulseDot color={statusColor[determineState(monitor)]} />
<Typography
component="h2"
variant="monitorUrl"
>
{monitor?.url?.replace(/^https?:\/\//, "") || "..."}
</Typography>
<Dot />
<Typography>
{intervalText}
{captureVersion && (
<>
{" "}
{t("monitorStatus.withCaptureAgent", {
version: captureVersion,
})}
</>
)}
.
</Typography>
</Stack>
</Stack>
<ConfigButton
path={path}
shouldRender={isAdmin}
monitorId={monitor?._id}
/>
</Stack>
);
};
MonitorStatusHeader.propTypes = {
path: PropTypes.string.isRequired,
isLoading: PropTypes.bool,
isAdmin: PropTypes.bool,
monitor: PropTypes.object,
};
export default MonitorStatusHeader;

View File

@@ -1,23 +0,0 @@
import { Stack, Skeleton } from "@mui/material";
const SkeletonLayout = () => {
return (
<Stack
direction="row"
justifyContent="space-between"
>
<Skeleton
height={40}
variant="rounded"
width="15%"
/>
<Skeleton
height={40}
variant="rounded"
width="15%"
/>
</Stack>
);
};
export default SkeletonLayout;

View File

@@ -116,7 +116,7 @@ const InfrastructureMonitors = () => {
/>
<Stack direction={"row"}>
<MonitorCountHeader
shouldRender={!isLoading}
isLoading={isLoading}
monitorCount={summary?.totalMonitors ?? 0}
/>
<Filter

View File

@@ -2,7 +2,6 @@
import { Stack, Typography } from "@mui/material";
import Breadcrumbs from "../../../Components/Breadcrumbs";
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
import PageSpeedStatusBoxes from "./Components/PageSpeedStatusBoxes";
import MonitorDetailsControlHeader from "../../../Components/MonitorDetailsControlHeader";
import PageSpeedAreaChart from "./Components/PageSpeedAreaChart";

View File

@@ -70,7 +70,7 @@ const PageSpeed = () => {
path="/pagespeed/create"
/>
<MonitorCountHeader
shouldRender={!isLoading}
isLoading={isLoading}
monitorCount={monitorsSummary?.totalMonitors}
sx={{ mb: theme.spacing(8) }}
/>

View File

@@ -201,9 +201,9 @@ const UptimeMonitors = () => {
<Stack direction={"row"}>
<MonitorCountHeader
shouldRender={monitors?.length > 0 && !monitorsWithSummaryIsLoading}
isLoading={monitorsWithSummaryIsLoading}
monitorCount={monitorsSummary?.totalMonitors}
></MonitorCountHeader>
/>
<Filter
selectedTypes={selectedTypes}
setSelectedTypes={setSelectedTypes}