Merge pull request #1675 from bluewave-labs/fix/fe/pagespeed-details-empty-view
fix: fe/pagespeed details empty view, resolves #1674
This commit is contained in:
7 files changed
+67
-28
No files matched your search
@@ -3,7 +3,7 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
|
import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
const ConfigButton = ({ shouldRender, monitorId }) => {
|
const ConfigButton = ({ shouldRender = true, monitorId, path }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ const ConfigButton = ({ shouldRender, monitorId }) => {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
onClick={() => navigate(`/uptime/configure/${monitorId}`)}
|
onClick={() => navigate(`/${path}/configure/${monitorId}`)}
|
||||||
sx={{
|
sx={{
|
||||||
px: theme.spacing(5),
|
px: theme.spacing(5),
|
||||||
"& svg": {
|
"& svg": {
|
||||||
@@ -34,7 +34,8 @@ const ConfigButton = ({ shouldRender, monitorId }) => {
|
|||||||
|
|
||||||
ConfigButton.propTypes = {
|
ConfigButton.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
shouldRender: PropTypes.bool,
|
||||||
monitorId: PropTypes.string,
|
monitorId: PropTypes.string.isRequired,
|
||||||
|
path: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ConfigButton;
|
export default ConfigButton;
|
||||||
@@ -8,7 +8,7 @@ import ConfigButton from "./ConfigButton";
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const MonitorStatusHeader = ({ shouldRender = true, isAdmin, monitor }) => {
|
const MonitorStatusHeader = ({ path, shouldRender = true, isAdmin, monitor }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { statusColor, statusMsg, determineState } = useUtils();
|
const { statusColor, statusMsg, determineState } = useUtils();
|
||||||
if (!shouldRender) {
|
if (!shouldRender) {
|
||||||
@@ -38,6 +38,7 @@ const MonitorStatusHeader = ({ shouldRender = true, isAdmin, monitor }) => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<ConfigButton
|
<ConfigButton
|
||||||
|
path={path}
|
||||||
shouldRender={isAdmin}
|
shouldRender={isAdmin}
|
||||||
monitorId={monitor?._id}
|
monitorId={monitor?._id}
|
||||||
/>
|
/>
|
||||||
@@ -46,6 +47,7 @@ const MonitorStatusHeader = ({ shouldRender = true, isAdmin, monitor }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MonitorStatusHeader.propTypes = {
|
MonitorStatusHeader.propTypes = {
|
||||||
|
path: PropTypes.string.isRequired,
|
||||||
shouldRender: PropTypes.bool,
|
shouldRender: PropTypes.bool,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
monitor: PropTypes.object,
|
monitor: PropTypes.object,
|
||||||
|
|||||||
+29
-15
@@ -3,25 +3,22 @@ import { useTheme } from "@emotion/react";
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const TimeFramePicker = ({ shouldRender = true, dateRange, setDateRange }) => {
|
const MonitorTimeFrameHeader = ({
|
||||||
|
shouldRender = true,
|
||||||
|
hasDateRange = true,
|
||||||
|
dateRange,
|
||||||
|
setDateRange,
|
||||||
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!shouldRender) {
|
if (!shouldRender) {
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
let timeFramePicker = null;
|
||||||
<Stack
|
|
||||||
direction="row"
|
if (hasDateRange) {
|
||||||
justifyContent="space-between"
|
timeFramePicker = (
|
||||||
alignItems="flex-end"
|
|
||||||
gap={theme.spacing(4)}
|
|
||||||
mb={theme.spacing(8)}
|
|
||||||
>
|
|
||||||
<Typography variant="body2">
|
|
||||||
Showing statistics for past{" "}
|
|
||||||
{dateRange === "day" ? "24 hours" : dateRange === "week" ? "7 days" : "30 days"}.
|
|
||||||
</Typography>
|
|
||||||
<ButtonGroup sx={{ height: 32 }}>
|
<ButtonGroup sx={{ height: 32 }}>
|
||||||
<Button
|
<Button
|
||||||
variant="group"
|
variant="group"
|
||||||
@@ -45,14 +42,31 @@ const TimeFramePicker = ({ shouldRender = true, dateRange, setDateRange }) => {
|
|||||||
Month
|
Month
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="flex-end"
|
||||||
|
gap={theme.spacing(4)}
|
||||||
|
mb={theme.spacing(8)}
|
||||||
|
>
|
||||||
|
<Typography variant="body2">
|
||||||
|
Showing statistics for past{" "}
|
||||||
|
{dateRange === "day" ? "24 hours" : dateRange === "week" ? "7 days" : "30 days"}.
|
||||||
|
</Typography>
|
||||||
|
{timeFramePicker}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeFramePicker.propTypes = {
|
MonitorTimeFrameHeader.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
shouldRender: PropTypes.bool,
|
||||||
|
hasDateRange: PropTypes.bool,
|
||||||
dateRange: PropTypes.string,
|
dateRange: PropTypes.string,
|
||||||
setDateRange: PropTypes.func,
|
setDateRange: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TimeFramePicker;
|
export default MonitorTimeFrameHeader;
|
||||||
File renamed without changes.
Whitespace-only changes.
@@ -1,10 +1,12 @@
|
|||||||
// Components
|
// Components
|
||||||
import { Stack, Typography, Skeleton } from "@mui/material";
|
import { Stack, Typography } from "@mui/material";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
|
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
||||||
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
||||||
import PageSpeedStatusBoxes from "./Components/PageSpeedStatusBoxes";
|
import PageSpeedStatusBoxes from "./Components/PageSpeedStatusBoxes";
|
||||||
import PageSpeedAreaChart from "./Components/PageSpeedAreaChart";
|
import PageSpeedAreaChart from "./Components/PageSpeedAreaChart";
|
||||||
import PerformanceReport from "./Components/PerformanceReport";
|
import PerformanceReport from "./Components/PerformanceReport";
|
||||||
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
// Utils
|
// Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
@@ -41,10 +43,28 @@ const PageSpeedDetails = () => {
|
|||||||
setMetrics((prev) => ({ ...prev, [id]: !prev[id] }));
|
setMetrics((prev) => ({ ...prev, [id]: !prev[id] }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Empty view, displayed when loading is complete and there are no checks
|
||||||
|
if (!isLoading && monitor?.checks?.length === 0) {
|
||||||
|
return (
|
||||||
|
<Stack gap={theme.spacing(10)}>
|
||||||
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
|
<MonitorStatusHeader
|
||||||
|
path={"pagespeed"}
|
||||||
|
isAdmin={isAdmin}
|
||||||
|
monitor={monitor}
|
||||||
|
/>
|
||||||
|
<GenericFallback>
|
||||||
|
<Typography>There is no history for this monitor yet.</Typography>
|
||||||
|
</GenericFallback>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
<MonitorStatusHeader
|
<MonitorStatusHeader
|
||||||
|
path={"pagespeed"}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
shouldRender={!isLoading}
|
shouldRender={!isLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
@@ -53,12 +73,12 @@ const PageSpeedDetails = () => {
|
|||||||
shouldRender={!isLoading}
|
shouldRender={!isLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
/>
|
/>
|
||||||
<Typography
|
<MonitorTimeFrameHeader
|
||||||
variant="body2"
|
shouldRender={!isLoading}
|
||||||
my={theme.spacing(8)}
|
dateRange={"day"}
|
||||||
>
|
hasDateRange={false}
|
||||||
Showing statistics for past 24 hours.
|
/>
|
||||||
</Typography>
|
|
||||||
<PageSpeedAreaChart
|
<PageSpeedAreaChart
|
||||||
shouldRender={!isLoading}
|
shouldRender={!isLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Components
|
// Components
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
import MonitorStatusHeader from "../../../Components/MonitorStatusHeader";
|
||||||
import TimeFramePicker from "./Components/TimeFramePicker";
|
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
||||||
import ChartBoxes from "./Components/ChartBoxes";
|
import ChartBoxes from "./Components/ChartBoxes";
|
||||||
import ResponseTimeChart from "./Components/Charts/ResponseTimeChart";
|
import ResponseTimeChart from "./Components/Charts/ResponseTimeChart";
|
||||||
import ResponseTable from "./Components/ResponseTable";
|
import ResponseTable from "./Components/ResponseTable";
|
||||||
@@ -81,6 +81,7 @@ const UptimeDetails = () => {
|
|||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
<MonitorStatusHeader
|
<MonitorStatusHeader
|
||||||
|
path={"uptime"}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
shouldRender={!monitorIsLoading}
|
shouldRender={!monitorIsLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
@@ -90,8 +91,9 @@ const UptimeDetails = () => {
|
|||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
certificateExpiry={certificateExpiry}
|
certificateExpiry={certificateExpiry}
|
||||||
/>
|
/>
|
||||||
<TimeFramePicker
|
<MonitorTimeFrameHeader
|
||||||
shouldRender={!monitorIsLoading}
|
shouldRender={!monitorIsLoading}
|
||||||
|
hasDateRange={true}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
setDateRange={setDateRange}
|
setDateRange={setDateRange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user