Merge branch 'bluewave-labs:develop' into FIX_1848_smallUIFixes

This commit is contained in:
Owaise Imdad authored and GitHub committed 2025-03-02 12:57:51 +05:30
commit 9edfd7185b
19 files changed
+283 -48

No files matched your search

@@ -5,7 +5,7 @@ import { useTheme } from "@emotion/react";
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
import { createToast } from "../../../../Utils/toastUtils";
const useSubscribeToMonitors = () => {
const useSubscribeToMonitors = (page, rowsPerPage) => {
// Redux
const { user } = useSelector((state) => state.auth);
@@ -25,8 +25,8 @@ const useSubscribeToMonitors = () => {
teamId: user.teamId,
limit: 25,
types: ["distributed_http"],
page: 0,
rowsPerPage: 10,
page,
rowsPerPage,
filter: null,
field: null,
order: null,
@@ -56,7 +56,7 @@ const useSubscribeToMonitors = () => {
});
setNetworkError(true);
}
}, [user, getMonitorWithPercentage, theme, isLoading]);
}, [user, getMonitorWithPercentage, theme, isLoading, page, rowsPerPage]);
return [isLoading, networkError, monitors, monitorsSummary, filteredMonitors];
};
export { useSubscribeToMonitors };
+23 -1
View File
@@ -3,10 +3,12 @@ import { Stack, Typography } from "@mui/material";
import Breadcrumbs from "../../../Components/Breadcrumbs";
import CreateMonitorHeader from "../../../Components/MonitorCreateHeader";
import MonitorTable from "./Components/MonitorTable";
import Pagination from "../../../Components/Table/TablePagination";
import Fallback from "../../../Components/Fallback";
import GenericFallback from "../../../Components/GenericFallback";
// Utils
import { useState } from "react";
import { useTheme } from "@mui/material/styles";
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
@@ -16,11 +18,23 @@ const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }
const DistributedUptimeMonitors = () => {
// Local state
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10);
// Utils
const theme = useTheme();
const isAdmin = useIsAdmin();
const [isLoading, networkError, monitors, monitorsSummary, filteredMonitors] =
useSubscribeToMonitors();
useSubscribeToMonitors(page, rowsPerPage);
// Handlers
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = (event) => {
setRowsPerPage(event.target.value);
setPage(0);
};
if (isLoading) {
return <SkeletonLayout />;
@@ -69,6 +83,14 @@ const DistributedUptimeMonitors = () => {
isLoading={isLoading}
monitors={filteredMonitors}
/>
<Pagination
itemCount={monitorsSummary?.totalMonitors ?? 0}
paginationLabel="monitors"
page={page}
rowsPerPage={rowsPerPage}
handleChangePage={handleChangePage}
handleChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Stack>
);
};
@@ -18,10 +18,11 @@ import InfoBox from "../../../Components/InfoBox";
import StatusHeader from "../../DistributedUptime/Details/Components/StatusHeader";
import MonitorsList from "./Components/MonitorsList";
import { RowContainer } from "../../../Components/StandardContainer";
import ThemeSwitch from "../../../Components/ThemeSwitch";
//Utils
import { useTheme } from "@mui/material/styles";
import { useState, useRef } from "react";
import { useState, useEffect, useRef } from "react";
import { useParams } from "react-router-dom";
import { useSubscribeToDetails } from "../../DistributedUptime/Details/Hooks/useSubscribeToDetails";
import { useDUStatusPageFetchByUrl } from "./Hooks/useDUStatusPageFetchByUrl";
@@ -31,6 +32,8 @@ import SubHeader from "../../../Components/Subheader";
import { safelyParseFloat } from "../../../Utils/utils";
import { useNavigate, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { useSelector, useDispatch } from "react-redux";
import { setMode } from "../../../Features/UI/uiSlice";
// Responsive
import { useMediaQuery } from "@mui/material";
@@ -40,8 +43,12 @@ const DistributedUptimeStatus = () => {
const location = useLocation();
const { t } = useTranslation();
const isPublic = location.pathname.startsWith("/status/distributed/public");
const elementToCapture = useRef(null);
// Redux state
const mode = useSelector((state) => state.ui.mode);
const originalModeRef = useRef(null);
// Local State
const [dateRange, setDateRange] = useState("day");
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
@@ -50,6 +57,7 @@ const DistributedUptimeStatus = () => {
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm"));
const navigate = useNavigate();
const dispatch = useDispatch();
const [
statusPageIsLoading,
@@ -85,6 +93,28 @@ const DistributedUptimeStatus = () => {
};
}
// Default to dark mode
useEffect(() => {
const cleanup = () => {
if (originalModeRef.current === null) {
originalModeRef.current = mode;
}
if (isPublic) {
dispatch(setMode(originalModeRef.current));
}
};
if (isPublic) {
dispatch(setMode("dark"));
}
window.addEventListener("beforeunload", cleanup);
return () => {
window.removeEventListener("beforeunload", cleanup);
};
}, [dispatch, isPublic]);
// Done loading, a status page doesn't exist
if (!statusPageIsLoading && typeof statusPage === "undefined") {
return (
@@ -158,9 +188,10 @@ const DistributedUptimeStatus = () => {
}}
>
{!isPublic && <Breadcrumbs list={BREADCRUMBS} />}
<ControlsHeader
shouldShow={!isPublic}
statusPage={statusPage}
isPublic={isPublic}
isDeleting={isDeleting}
isDeleteOpen={isDeleteOpen}
setIsDeleteOpen={setIsDeleteOpen}
@@ -183,11 +214,9 @@ const DistributedUptimeStatus = () => {
<RowContainer>
<Stack>
<Typography variant={`body2`}>
{t("distributedRightCatagoryTitle")}
</Typography>
<Typography variant={`h2`}>
{t("distributedRightCatagoryDescription")}
{t("distributedRightCategoryTitle")}
</Typography>
<Typography variant={`h2`}>{statusPage.companyName}</Typography>
</Stack>
</RowContainer>
</SubHeader>
@@ -2,7 +2,7 @@
import { Box, Stack, Typography, Button } from "@mui/material";
import Image from "../../../../../Components/Image";
import SettingsIcon from "../../../../../assets/icons/settings-bold.svg?react";
import ThemeSwitch from "../../../../../Components/ThemeSwitch";
//Utils
import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom";
@@ -76,6 +76,7 @@ Controls.propTypes = {
const ControlsHeader = ({
statusPage,
isPublic,
isDeleting,
isDeleteOpen,
setIsDeleteOpen,
@@ -105,7 +106,16 @@ const ControlsHeader = ({
maxHeight={"50px"}
base64={statusPage?.logo?.data}
/>
<Typography variant="h1">{statusPage?.companyName}</Typography>
<Typography
variant="h1"
overflow="hidden"
textOverflow="ellipsis"
sx={{
maxWidth: { xs: "200px", sm: "100%" },
}}
>
{statusPage?.companyName}
</Typography>
</Stack>
<Controls
isDeleting={isDeleting}
@@ -114,6 +124,7 @@ const ControlsHeader = ({
url={url}
type={type}
/>
{isPublic && <ThemeSwitch />}
</Stack>
);
};
@@ -121,6 +132,7 @@ const ControlsHeader = ({
ControlsHeader.propTypes = {
url: PropTypes.string,
statusPage: PropTypes.object,
isPublic: PropTypes.bool,
isDeleting: PropTypes.bool,
isDeleteOpen: PropTypes.bool.isRequired,
setIsDeleteOpen: PropTypes.func.isRequired,
@@ -17,16 +17,40 @@ const StatusPagesTable = ({ data }) => {
},
{
id: "url",
content: "URL",
content: "Public URL",
onClick: (e, row) => {
if (row.isPublished) {
e.stopPropagation();
const url =
row.type === "distributed"
? `/status/distributed/public/${row.url}`
: `/status/uptime/public/${row.url}`;
navigate(url);
}
},
render: (row) => {
const content = row.isPublished ? `/${row.url}` : "Unpublished";
return (
<Stack
direction="row"
alignItems="center"
justifyContent="center"
gap={theme.spacing(2)}
paddingLeft={theme.spacing(2)}
paddingRight={theme.spacing(2)}
borderRadius={theme.spacing(4)}
sx={{
...(row.isPublished && {
":hover": {
backgroundColor: `${theme.palette.primary.light}`,
cursor: "pointer",
borderRadius: 1,
},
}),
}}
>
<Typography>{`/${row.url}`}</Typography>
<ArrowOutwardIcon />
<Typography>{content}</Typography>
{row.isPublished && <ArrowOutwardIcon />}
</Stack>
);
},
@@ -51,6 +51,7 @@ const StatusPages = () => {
/>
);
}
return (
<Stack gap={theme.spacing(10)}>
<Breadcrumbs list={BREADCRUMBS} />
@@ -35,6 +35,7 @@ const ChartBoxes = ({
const denominator =
totalUpChecks + totalDownChecks > 0 ? totalUpChecks + totalDownChecks : 1;
const groupedUptimePercentage = (totalUpChecks / denominator) * 100;
const noIncidentsMessage = "Great. No Incidents, yet!";
return (
<Stack
@@ -45,6 +46,7 @@ const ChartBoxes = ({
<ChartBox
icon={<UptimeIcon />}
header="Uptime"
isEmpty={monitor?.uptimePercentage === 0 && !monitor?.upChecks?.length}
>
<Stack
width={"100%"}
@@ -95,6 +97,8 @@ const ChartBoxes = ({
<ChartBox
icon={<IncidentsIcon />}
header="Incidents"
noDataMessage={noIncidentsMessage}
isEmpty={monitor?.groupedDownChecks?.length === 0}
>
<Stack width={"100%"}>
<Box position="relative">