Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: HTTPS monitors show HTTP on the table #1642

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Client/src/Components/CircularCount/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Box } from "@mui/material";
import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
const CircularCount = ({ count }) => {
const theme = useTheme();
return (
<Box
component="span"
color={theme.palette.tertiary.contrastText}
border={2}
borderColor={theme.palette.accent.main}
backgroundColor={theme.palette.tertiary.main}
sx={{
padding: ".25em .75em",
borderRadius: "50%",
fontSize: "12px",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Yo dawg, I heard you like theme variables! 🎨

The hardcoded font size "12px" should be replaced with a theme typography value to maintain consistency and follow the PR's guideline about avoiding hardcoded values.

-				fontSize: "12px",
+				fontSize: theme.typography.caption.fontSize,

Committable suggestion skipped: line range outside the PR's diff.

fontWeight: 500,
}}
>
{count}
</Box>
);
};

CircularCount.propTypes = {
count: PropTypes.number,
};

export default CircularCount;
2 changes: 1 addition & 1 deletion Client/src/Components/StatBox/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Typography } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import PropTypes from "prop-types";
import useUtils from "../../Pages/Uptime/utils";
import useUtils from "../../Pages/Uptime/Home/Hooks/useUtils";

/**
* StatBox Component
Expand Down
2 changes: 1 addition & 1 deletion Client/src/Pages/Infrastructure/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AreaChart from "../../../Components/Charts/AreaChart";
import { useSelector } from "react-redux";
import { networkService } from "../../../main";
import PulseDot from "../../../Components/Animated/PulseDot";
import useUtils from "../../Uptime/utils";
import useUtils from "../../Uptime/Home/Hooks/useUtils";
import { useNavigate } from "react-router-dom";
import Empty from "./empty";
import { logger } from "../../../Utils/Logger";
Expand Down
4 changes: 2 additions & 2 deletions Client/src/Pages/Infrastructure/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState, useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { /* useDispatch, */ useSelector } from "react-redux";
import { useTheme } from "@emotion/react";
import useUtils from "../Uptime/utils.jsx";
import useUtils from "../Uptime/Home/Hooks/useUtils.jsx";
import { jwtDecode } from "jwt-decode";
import SkeletonLayout from "./skeleton";
import Fallback from "../../Components/Fallback";
Expand All @@ -17,7 +17,7 @@ import Pagination from "../../Components/Table/TablePagination/index.jsx";
// import { getInfrastructureMonitorsByTeamId } from "../../Features/InfrastructureMonitors/infrastructureMonitorsSlice";
import { networkService } from "../../Utils/NetworkService.js";
import CustomGauge from "../../Components/Charts/CustomGauge/index.jsx";
import Host from "../Uptime/Home/host.jsx";
import Host from "../Uptime/Home/Components/Host";
import { useIsAdmin } from "../../Hooks/useIsAdmin.js";
import { InfrastructureMenu } from "./components/Menu";

Expand Down
2 changes: 1 addition & 1 deletion Client/src/Pages/PageSpeed/Configure/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import PulseDot from "../../../Components/Animated/PulseDot";
import LoadingButton from "@mui/lab/LoadingButton";
import PlayCircleOutlineRoundedIcon from "@mui/icons-material/PlayCircleOutlineRounded";
import SkeletonLayout from "./skeleton";
import useUtils from "../../Uptime/utils";
import useUtils from "../../Uptime/Home/Hooks/useUtils";
import "./index.css";
import Dialog from "../../../Components/Dialog";

Expand Down
2 changes: 1 addition & 1 deletion Client/src/Pages/PageSpeed/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import PulseDot from "../../../Components/Animated/PulseDot";
import PagespeedDetailsAreaChart from "./Charts/AreaChart";
import Checkbox from "../../../Components/Inputs/Checkbox";
import PieChart from "./Charts/PieChart";
import useUtils from "../../Uptime/utils";
import useUtils from "../../Uptime/Home/Hooks/useUtils";
import "./index.css";
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import StatBox from "../../../Components/StatBox";
Expand Down
2 changes: 1 addition & 1 deletion Client/src/Pages/PageSpeed/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTheme } from "@emotion/react";
import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts";
import { useSelector } from "react-redux";
import { formatDateWithTz, formatDurationSplit } from "../../Utils/timeUtils";
import useUtils from "../Uptime/utils";
import useUtils from "../Uptime/Home/Hooks/useUtils";
import { useState } from "react";
import IconBox from "../../Components/IconBox";
/**
Expand Down
2 changes: 1 addition & 1 deletion Client/src/Pages/Uptime/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import PulseDot from "../../../Components/Animated/PulseDot";
import { ChartBox } from "./styled";
import SkeletonLayout from "./skeleton";
import "./index.css";
import useUtils from "../utils";
import useUtils from "../Home/Hooks/useUtils";
import { formatDateWithTz, formatDurationSplit } from "../../../Utils/timeUtils";
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import IconBox from "../../../Components/IconBox";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { useTheme } from "@emotion/react";
import { useNavigate } from "react-router-dom";
import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger";
import { createToast } from "../../../../../Utils/toastUtils";
import { logger } from "../../../../../Utils/Logger";
import { IconButton, Menu, MenuItem } from "@mui/material";
import {
deleteUptimeMonitor,
pauseUptimeMonitor,
} from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import Settings from "../../../assets/icons/settings-bold.svg?react";
} from "../../../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import Settings from "../../../../../assets/icons/settings-bold.svg?react";
import PropTypes from "prop-types";
import Dialog from "../../../Components/Dialog";
import Dialog from "../../../../../Components/Dialog";

const ActionsMenu = ({
monitor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Typography } from "@mui/material";
import { Stack, Box, Typography } from "@mui/material";
import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
/**
* Host component.
* This subcomponent receives a params object and displays the host details.
Expand All @@ -13,44 +14,43 @@ import PropTypes from "prop-types";
* @returns {React.ElementType} Returns a div element with the host details.
*/
const Host = ({ url, title, percentageColor, percentage }) => {
const noTitle = title === undefined || title === url;
const theme = useTheme();
console.log(url, title);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, we got a console.log in production code! 🚫

Remove the debug console.log statement before merging.

-	console.log(url, title);

return (
<Box className="host">
<Box
display="inline-block"
<Stack>
<Stack
direction="row"
position="relative"
sx={{
fontWeight: 500,
"&:before": {
position: "absolute",
content: `""`,
width: "4px",
height: "4px",
borderRadius: "50%",
backgroundColor: "gray",
opacity: 0.8,
right: "-10px",
top: "42%",
},
}}
alignItems="center"
gap={theme.spacing(4)}
>
{title}
</Box>
{percentageColor && percentage && (
<Typography
component="span"
sx={{
color: percentageColor,
fontWeight: 500,
/* TODO point font weight to theme */
ml: "15px",
}}
>
{percentage}%
</Typography>
)}
{!noTitle && <Box sx={{ opacity: 0.6 }}>{url}</Box>}
</Box>
{percentageColor && percentage && (
<>
<span
style={{
content: '""',
width: "4px",
height: "4px",
borderRadius: "50%",
backgroundColor: "gray",
opacity: 0.8,
}}
/>
<Typography
component="span"
sx={{
color: percentageColor,
fontWeight: 500,
}}
>
{percentage}%
</Typography>
</>
)}
</Stack>
<span style={{ opacity: 0.6 }}>{url}</span>
</Stack>
);
};

Expand Down
46 changes: 46 additions & 0 deletions Client/src/Pages/Uptime/Home/Components/LoadingSpinner/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { CircularProgress, Box } from "@mui/material";
import { useTheme } from "@emotion/react";
import PropTypes from "prop-types";
const LoadingSpinner = ({ shouldRender }) => {
const theme = useTheme();
if (shouldRender === false) {
return;
}

return (
<>
<Box
width="100%"
height="100%"
position="absolute"
sx={{
backgroundColor: theme.palette.primary.main,
opacity: 0.8,
zIndex: 100,
}}
/>
Comment on lines +12 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Knees weak, arms heavy, but this overlay needs to be accessibility ready! 🎯

The overlay Box needs some accessibility love and could use some constants:

+const OVERLAY_OPACITY = 0.8;
+const OVERLAY_Z_INDEX = 100;

 <Box
   width="100%"
   height="100%"
   position="absolute"
+  role="progressbar"
+  aria-label="Loading content"
   sx={{
     backgroundColor: theme.palette.primary.main,
-    opacity: 0.8,
-    zIndex: 100,
+    opacity: OVERLAY_OPACITY,
+    zIndex: OVERLAY_Z_INDEX,
   }}
 />

Committable suggestion skipped: line range outside the PR's diff.

<Box
height="100%"
position="absolute"
top="50%"
left="50%"
sx={{
transform: "translateX(-50%)",
zIndex: 101,
}}
>
<CircularProgress
sx={{
color: theme.palette.accent.main,
}}
/>
</Box>
</>
);
};

LoadingSpinner.propTypes = {
shouldRender: PropTypes.bool,
};
Comment on lines +42 to +44
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Lose yourself in the PropTypes, the moment, you better never let it go! 🎤

The prop validation needs to be more strict since shouldRender is essential for the component's functionality:

 LoadingSpinner.propTypes = {
-  shouldRender: PropTypes.bool,
+  shouldRender: PropTypes.bool.isRequired,
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LoadingSpinner.propTypes = {
shouldRender: PropTypes.bool,
};
LoadingSpinner.propTypes = {
shouldRender: PropTypes.bool.isRequired,
};


export default LoadingSpinner;
43 changes: 43 additions & 0 deletions Client/src/Pages/Uptime/Home/Components/SearchComponent/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useState } from "react";
import Search from "../../../../../Components/Inputs/Search";
import { Box } from "@mui/material";
import useDebounce from "../../Hooks/useDebounce";
import { useEffect } from "react";
import PropTypes from "prop-types";

const SearchComponent = ({ monitors, onSearchChange, setIsSearching }) => {
const [localSearch, setLocalSearch] = useState("");
const debouncedSearch = useDebounce(localSearch, 500);
useEffect(() => {
onSearchChange(debouncedSearch);
setIsSearching(false);
}, [debouncedSearch, onSearchChange, setIsSearching]);

const handleSearch = (value) => {
setLocalSearch(value);
setIsSearching(true);
};

return (
<Box
width="25%"
minWidth={150}
ml="auto"
>
<Search
options={monitors}
filteredBy="name"
inputValue={localSearch}
handleInputChange={handleSearch}
/>
</Box>
);
};

SearchComponent.propTypes = {
monitors: PropTypes.array,
onSearchChange: PropTypes.func,
setIsSearching: PropTypes.func,
};
Comment on lines +37 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Yo, these PropTypes need more sauce! 🍝

Let's make them more specific and mark required props:

 SearchComponent.propTypes = {
-  monitors: PropTypes.array,
-  onSearchChange: PropTypes.func,
-  setIsSearching: PropTypes.func,
+  monitors: PropTypes.arrayOf(
+    PropTypes.shape({
+      name: PropTypes.string.isRequired,
+    })
+  ).isRequired,
+  onSearchChange: PropTypes.func.isRequired,
+  setIsSearching: PropTypes.func.isRequired,
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SearchComponent.propTypes = {
monitors: PropTypes.array,
onSearchChange: PropTypes.func,
setIsSearching: PropTypes.func,
};
SearchComponent.propTypes = {
monitors: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
})
).isRequired,
onSearchChange: PropTypes.func.isRequired,
setIsSearching: PropTypes.func.isRequired,
};


export default SearchComponent;
36 changes: 36 additions & 0 deletions Client/src/Pages/Uptime/Home/Components/StatusBoxes/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import PropTypes from "prop-types";
import { Stack } from "@mui/material";
import StatusBox from "./statusBox";
import { useTheme } from "@emotion/react";
import SkeletonLayout from "./skeleton";

const StatusBoxes = ({ shouldRender, monitorsSummary }) => {
const theme = useTheme();
if (!shouldRender) return <SkeletonLayout shouldRender={shouldRender} />;
return (
<Stack
gap={theme.spacing(8)}
direction="row"
justifyContent="space-between"
>
<StatusBox
title="up"
value={monitorsSummary?.upMonitors ?? 0}
/>
<StatusBox
title="down"
value={monitorsSummary?.downMonitors ?? 0}
/>
<StatusBox
title="paused"
value={monitorsSummary?.pausedMonitors ?? 0}
/>
</Stack>
);
};

StatusBoxes.propTypes = {
monitorsSummary: PropTypes.object.isRequired,
};
Comment on lines +32 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Yo, we're missing some PropTypes validation! 📝

The shouldRender prop is used in the component but missing from PropTypes validation.

 StatusBoxes.propTypes = {
 	monitorsSummary: PropTypes.object.isRequired,
+	shouldRender: PropTypes.bool.isRequired,
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
StatusBoxes.propTypes = {
monitorsSummary: PropTypes.object.isRequired,
};
StatusBoxes.propTypes = {
monitorsSummary: PropTypes.object.isRequired,
shouldRender: PropTypes.bool.isRequired,
};


export default StatusBoxes;
31 changes: 31 additions & 0 deletions Client/src/Pages/Uptime/Home/Components/StatusBoxes/skeleton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Skeleton, Stack } from "@mui/material";
import { useTheme } from "@emotion/react";

const SkeletonLayout = () => {
const theme = useTheme();
return (
<Stack
gap={theme.spacing(12)}
direction="row"
justifyContent="space-between"
>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
<Skeleton
variant="rounded"
width="100%"
height={100}
/>
</Stack>
);
};

export default SkeletonLayout;
Loading