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

Conversation

Br0wnHammer
Copy link
Contributor

Describe your changes

Changed the display monitor types in UptimeDataTable from "HTTP" to "HTTP(s)" for better clarity and accuracy in representing HTTPS monitors.

Issue number

#1626

Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.

  • (Do not skip this or your PR will be closed) I deployed the application locally.
  • (Do not skip this or your PR will be closed) I have performed a self-review and testing of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Copy link

@llamapreview llamapreview bot left a comment

Choose a reason for hiding this comment

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

Auto Pull Request Review from LlamaPReview

Large PR Notification

Dear contributor,

Thank you for your substantial contribution to this project. LlamaPReview has detected that this Pull Request contains a large volume of changes, which exceeds our current processing capacity.

Details:

  • PR and related contents total size: Approximately 76,319 characters
  • Current limit: 50,000 characters

Next steps:

  1. Consider breaking this PR into smaller, more focused changes if possible.
  2. For manual review, please reach out to your team members or maintainers.

We appreciate your understanding and commitment to improving this project. Your contributions are valuable, and we want to ensure they receive the attention they deserve.

LlamaPReview is continuously evolving to better serve the community. Share your thoughts on handling large PRs in our GitHub Discussions - your feedback helps us improve and expand our capabilities.

If you have any questions or need assistance, our community and support team are here to help.

Best regards,
LlamaPReview Team

Copy link

coderabbitai bot commented Jan 27, 2025

Walkthrough

This pull request represents a comprehensive restructuring of the Uptime Monitoring section in the client-side application. The changes involve significant refactoring of file structures, introducing new components, hooks, and utility functions primarily within the Client/src/Pages/Uptime/Home directory. The modifications aim to improve code organization, enhance component modularity, and streamline data fetching and rendering processes for monitor-related functionality.

Changes

File Path Change Summary
Client/src/Components/CircularCount/index.jsx New functional component for rendering circular count
Client/src/Components/StatBox/index.jsx Updated import path for useUtils hook
Client/src/Pages/Infrastructure/* Updated import paths for useUtils hook
Client/src/Pages/PageSpeed/* Updated import paths for useUtils hook
Client/src/Pages/Uptime/Home/Components/* Multiple new components added: LoadingSpinner, SearchComponent, StatusBoxes, SkeletonLayout, MonitorDataTable
Client/src/Pages/Uptime/Home/Hooks/* New custom hooks: useDebounce, useMonitorFetch
Server/controllers/monitorController.js Fixed typo in response method call
Server/db/mongo/modules/monitorModule.js Added console logging for debugging

Suggested Reviewers

  • ajhollid
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🔭 Outside diff range comments (1)
Server/db/mongo/modules/monitorModule.js (1)

Line range hint 500-524: Remove console.log statements and implement proper logging.

Console.log statements should be replaced with proper logging using the existing logger utility. This helps maintain consistent logging patterns and prevents potential security issues from exposing sensitive information in logs.

Apply this diff to use the logger utility:

-console.log("req.query", req.query);
+logger.debug("Processing monitor query parameters", { query: req.query });

-console.log("limit", limit);
-console.log("page", page);
-console.log("rowsPerPage", rowsPerPage);
-console.log("filter", filter);
-console.log("field", field);
-console.log("order", order);
-console.log("skip", skip);
-console.log("sort", sort);
+logger.debug("Monitor query parameters processed", {
+  limit,
+  page,
+  rowsPerPage,
+  filter,
+  field,
+  order,
+  skip,
+  sort
+});
🧹 Nitpick comments (14)
Client/src/Pages/Uptime/Home/Components/LoadingSpinner/index.jsx (2)

6-8: Bruh, let's make this early return cleaner than mom's spaghetti! 🍝

The early return logic could use some improvements:

  1. Make the return explicit
  2. Simplify the condition
  3. Add a default prop value
+LoadingSpinner.defaultProps = {
+  shouldRender: false,
+};

 const LoadingSpinner = ({ shouldRender }) => {
   const theme = useTheme();
-  if (shouldRender === false) {
-    return;
+  if (!shouldRender) {
+    return null;
   }

22-37: There's vomit on his sweater already, but this spinner positioning can be steady! 💫

Let's make the spinner positioning more robust:

+const SPINNER_Z_INDEX = OVERLAY_Z_INDEX + 1;

 <Box
   height="100%"
   position="absolute"
   top="50%"
   left="50%"
   sx={{
-    transform: "translateX(-50%)",
+    transform: "translate(-50%, -50%)",
-    zIndex: 101,
+    zIndex: SPINNER_Z_INDEX,
   }}
 >
Client/src/Pages/Uptime/Home/Components/UptimeDataTable/index.jsx (2)

37-38: Consider standardizing your property name.
You might want to use Canadian spelling for “colour” if your codebase is standardized on en-CA, but it's primarily a matter of style and consistency. Either way, ensure it aligns with the rest of your codebase.


212-212: Remove debug logs for production readiness.
console.log("rendering") can clutter logs and distract from critical issues. It's best to remove debug statements before merging.

- console.log("rendering");
Client/src/Pages/Uptime/Home/Components/SearchComponent/index.jsx (3)

1-6: Yo, let's clean up these imports, they're all over the place!

Consider consolidating React imports and organizing them better:

-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";
+import { useState, useEffect } from "react";
+import PropTypes from "prop-types";
+import { Box } from "@mui/material";
+import Search from "../../../../../Components/Inputs/Search";
+import useDebounce from "../../Hooks/useDebounce";

Also, that deep import path ../../../../../ is making my knees weak! Consider creating a barrel file to simplify imports.


8-10: Mom's spaghetti! That hardcoded debounce delay though...

The debounce delay of 500ms should be configurable through props or constants to make it more maintainable.

+const SEARCH_DEBOUNCE_DELAY = 500; // ms
+
 const SearchComponent = ({ monitors, onSearchChange, setIsSearching }) => {
   const [localSearch, setLocalSearch] = useState("");
-  const debouncedSearch = useDebounce(localSearch, 500);
+  const debouncedSearch = useDebounce(localSearch, SEARCH_DEBOUNCE_DELAY);

21-34: These hardcoded widths got me nervous, palms are sweaty!

The fixed width percentage might not be optimal for all screen sizes. Consider using MUI's responsive breakpoints.

 <Box
-  width="25%"
+  sx={{
+    width: {
+      xs: '50%',
+      sm: '35%',
+      md: '25%'
+    }
+  }}
   minWidth={150}
   ml="auto"
>
Client/src/Pages/Uptime/Home/Components/StatusBoxes/statusBox.jsx (2)

Line range hint 13-43: Yo dawg, let's optimize this repetitive logic!

The color and icon selection logic is repeated for each status. Consider extracting this to a configuration object to reduce complexity and improve maintainability.

+const STATUS_CONFIG = {
+  up: {
+    color: theme => theme.palette.success.lowContrast,
+    icon: props => (
+      <Box sx={{ ...props.sharedStyles, top: 8 }}>
+        <Arrow />
+      </Box>
+    )
+  },
+  down: {
+    color: theme => theme.palette.error.lowContrast,
+    icon: props => (
+      <Box sx={{ ...props.sharedStyles, transform: "rotate(180deg)", top: 5 }}>
+        <Arrow />
+      </Box>
+    )
+  },
+  paused: {
+    color: theme => theme.palette.warning.lowContrast,
+    icon: props => (
+      <Box sx={{ ...props.sharedStyles, top: 12, right: 12 }}>
+        <ClockSnooze />
+      </Box>
+    )
+  }
+};

Line range hint 11-21: Optimize performance with useMemo!

The sharedStyles object is recreated on every render. Consider memoizing it to improve performance.

+import { useMemo } from 'react';

 const StatusBox = ({ title, value }) => {
   const theme = useTheme();
 
-  let sharedStyles = {
+  const sharedStyles = useMemo(() => ({
     position: "absolute",
     right: 8,
     opacity: 0.5,
     "& svg path": { stroke: theme.palette.primary.contrastTextTertiary },
-  };
+  }), [theme.palette.primary.contrastTextTertiary]);
Client/src/Pages/Uptime/Home/Hooks/useMonitorFetch.jsx (1)

5-32: Yo, let's make this function more efficient!

The getMonitorWithPercentage function is recreated on every render and contains hardcoded color thresholds. Consider extracting it outside the component and using constants.

+const PERCENTAGE_THRESHOLDS = {
+  LOW: 0.25,
+  MEDIUM: 0.5,
+  HIGH: 0.75
+};

+const getColorForPercentage = (percentage, theme) => {
+  if (percentage < PERCENTAGE_THRESHOLDS.LOW) return theme.palette.error.main;
+  if (percentage < PERCENTAGE_THRESHOLDS.MEDIUM) return theme.palette.warning.main;
+  return theme.palette.success.main;
+};

-const getMonitorWithPercentage = (monitor, theme) => {
+export const getMonitorWithPercentage = (monitor, theme) => {
   let uptimePercentage = "";
   let percentageColor = "";
   
   if (monitor.uptimePercentage !== undefined) {
     uptimePercentage =
       monitor.uptimePercentage === 0 ? "0" : (monitor.uptimePercentage * 100).toFixed(2);
-    percentageColor =
-      monitor.uptimePercentage < 0.25
-        ? theme.palette.error.main
-        : monitor.uptimePercentage < 0.5
-          ? theme.palette.warning.main
-          : monitor.uptimePercentage < 0.75
-            ? theme.palette.success.main
-            : theme.palette.success.main;
+    percentageColor = getColorForPercentage(monitor.uptimePercentage, theme);
   }
Client/src/Pages/Uptime/Home/index.jsx (2)

23-43: Move this component to its own file, yo!

The CreateMonitorButton component should be moved to a separate file to improve code organization and maintainability.

Consider moving it to: Client/src/Pages/Uptime/Home/Components/CreateMonitorButton/index.jsx


108-108: That hardcoded prop is making me nervous!

The shouldRender prop is hardcoded to true, making the prop redundant. Consider removing it if it's always true.

-<CreateMonitorButton shouldRender={true} />
+<CreateMonitorButton />
Client/src/Pages/PageSpeed/Details/index.jsx (1)

Line range hint 279-279: Let's track that TODO properly!

The TODO comment about grid template columns should be tracked in an issue.

Would you like me to create an issue to track this grid layout enhancement task?

Server/db/mongo/modules/monitorModule.js (1)

851-869: Remove commented example values.

The commented example values at the end of the file serve no functional purpose and should be removed to maintain code cleanliness.

Apply this diff:

-// limit 25
-// page 1
-// rowsPerPage 25
-// filter undefined
-// field name
-// order asc
-// skip 25
-// sort { name: 1 }
-// filteredMonitors []
-
-// limit 25
-// page NaN
-// rowsPerPage 25
-// filter undefined
-// field name
-// order asc
-// skip 0
-// sort { name: 1 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4081e5 and f19ae02.

📒 Files selected for processing (25)
  • Client/src/Components/CircularCount/index.jsx (1 hunks)
  • Client/src/Components/StatBox/index.jsx (1 hunks)
  • Client/src/Pages/Infrastructure/Details/index.jsx (1 hunks)
  • Client/src/Pages/Infrastructure/index.jsx (2 hunks)
  • Client/src/Pages/PageSpeed/Configure/index.jsx (1 hunks)
  • Client/src/Pages/PageSpeed/Details/index.jsx (1 hunks)
  • Client/src/Pages/PageSpeed/card.jsx (1 hunks)
  • Client/src/Pages/Uptime/Details/index.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/ActionsMenu/index.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/Host/index.jsx (2 hunks)
  • Client/src/Pages/Uptime/Home/Components/LoadingSpinner/index.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/SearchComponent/index.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/StatusBoxes/index.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/StatusBoxes/skeleton.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Components/StatusBoxes/statusBox.jsx (2 hunks)
  • Client/src/Pages/Uptime/Home/Components/UptimeDataTable/index.jsx (6 hunks)
  • Client/src/Pages/Uptime/Home/Components/UptimeDataTable/skeleton.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Hooks/useDebounce.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/Hooks/useMonitorFetch.jsx (1 hunks)
  • Client/src/Pages/Uptime/Home/UptimeDataTable/Skeleton/index.jsx (0 hunks)
  • Client/src/Pages/Uptime/Home/fallback.jsx (0 hunks)
  • Client/src/Pages/Uptime/Home/index.css (0 hunks)
  • Client/src/Pages/Uptime/Home/index.jsx (2 hunks)
  • Server/controllers/monitorController.js (1 hunks)
  • Server/db/mongo/modules/monitorModule.js (4 hunks)
💤 Files with no reviewable changes (3)
  • Client/src/Pages/Uptime/Home/index.css
  • Client/src/Pages/Uptime/Home/fallback.jsx
  • Client/src/Pages/Uptime/Home/UptimeDataTable/Skeleton/index.jsx
✅ Files skipped from review due to trivial changes (6)
  • Client/src/Pages/PageSpeed/card.jsx
  • Client/src/Components/StatBox/index.jsx
  • Server/controllers/monitorController.js
  • Client/src/Pages/PageSpeed/Configure/index.jsx
  • Client/src/Pages/Infrastructure/index.jsx
  • Client/src/Pages/Uptime/Home/Components/ActionsMenu/index.jsx
🔇 Additional comments (12)
Client/src/Pages/Uptime/Home/Components/LoadingSpinner/index.jsx (1)

1-4: Yo, these imports are straight fire! 🔥

Clean imports and solid component declaration. The dependencies are properly scoped and the prop name is self-explanatory.

Client/src/Pages/Uptime/Home/Components/UptimeDataTable/index.jsx (2)

194-194: Great fix for HTTPS notation!
This line elegantly addresses the issue of monitors showing only "HTTP" by displaying "HTTP(s)" instead, improving clarity across the board. Rock on!


234-240: Slick usage of the new table and skeleton components!
Your composition of MonitorDataTable and UptimeDataTableSkeleton fosters a clean transition between loaded and loading states, increasing maintainability. Keep that synergy alive!

Client/src/Pages/Uptime/Home/Hooks/useDebounce.jsx (1)

3-16: This hook is crisp and clean.
The standard approach to debouncing is implemented correctly, preventing excessive function calls. No sweaty palms here—looks ready for the big stage.

Client/src/Pages/Uptime/Home/Components/UptimeDataTable/skeleton.jsx (1)

4-15: Kudos for the skeleton usage!
Guarding via shouldRender and the styled Skeleton is a fine approach to handle loading states. This adds a polished feel to the UI.

Client/src/Pages/Uptime/Home/Components/SearchComponent/index.jsx (2)

11-14: Straight fire! This effect handling is clean!

The useEffect implementation is solid with proper dependency array and clear side effects.


16-19: This handler's got no chill - it's perfect! 🔥

Clean and focused implementation of the search handler with proper state management.

Client/src/Pages/Uptime/Home/Components/StatusBoxes/skeleton.jsx (1)

1-31: Yo, this skeleton implementation is straight fire! 🔥

Clean implementation of loading state using MUI Skeleton components. The spacing and layout are on point.

Client/src/Pages/Uptime/Home/Components/Host/index.jsx (1)

Line range hint 1-31: Hold up! Where's the HTTP(s) display fix? 🤔

The PR's main objective is to fix the display of HTTPS monitors, but I don't see any changes addressing this. Consider updating the URL display logic to properly show "HTTP(s)" for HTTPS monitors.

Would you like me to help implement the HTTP(s) display logic?

Client/src/Pages/PageSpeed/Details/index.jsx (1)

22-22: LGTM! Import path update looks good.

The updated import path aligns with the new file structure.

Client/src/Pages/Uptime/Details/index.jsx (1)

22-22: LGTM! Import path update is consistent with project reorganization.

The import path change aligns with the broader restructuring of the project's file organization, moving utility hooks to a dedicated Hooks directory.

Client/src/Pages/Infrastructure/Details/index.jsx (1)

11-11: LGTM! Import path update is consistent with project reorganization.

The import path change aligns with the broader restructuring of the project's file organization, moving utility hooks to a dedicated Hooks directory.

Comment on lines +42 to +44
LoadingSpinner.propTypes = {
shouldRender: PropTypes.bool,
};
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,
};

Comment on lines +12 to +21
<Box
width="100%"
height="100%"
position="absolute"
sx={{
backgroundColor: theme.palette.primary.main,
opacity: 0.8,
zIndex: 100,
}}
/>
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.

Comment on lines +37 to +41
SearchComponent.propTypes = {
monitors: PropTypes.array,
onSearchChange: PropTypes.func,
setIsSearching: PropTypes.func,
};
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,
};

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.

Comment on lines +32 to +34
StatusBoxes.propTypes = {
monitorsSummary: PropTypes.object.isRequired,
};
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,
};

@@ -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);

Comment on lines +74 to +78
} catch (error) {
createToast({
body: error.message,
});
} finally {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make that error handling more specific, fam!

The error handling is too generic. Consider catching specific error types and providing more informative error messages.

 } catch (error) {
+  const errorMessage = error.response?.data?.message || error.message;
   createToast({
-    body: error.message,
+    body: `Failed to fetch monitors: ${errorMessage}`,
+    type: 'error'
   });
 }
📝 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
} catch (error) {
createToast({
body: error.message,
});
} finally {
} catch (error) {
const errorMessage = error.response?.data?.message || error.message;
createToast({
body: `Failed to fetch monitors: ${errorMessage}`,
type: 'error'
});
} finally {

@@ -675,6 +683,7 @@ const getMonitorsByTeamId = async (req) => {
]);

let { monitors, filteredMonitors, summary } = results[0];
console.log("filteredMonitors", filteredMonitors);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove console.log statement and implement proper logging.

Replace console.log with the logger utility for consistent logging patterns.

Apply this diff:

-console.log("filteredMonitors", filteredMonitors);
+logger.debug("Filtered monitors", { count: filteredMonitors.length });

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

Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

@Br0wnHammer nice work, that's what we're looking for 👍

Can you rebase this PR please? The branch it is based on has already been merged into develop with some further changes since this was checked out.

Or just close the PR and open a new one with only the http(s) change.

Thank you!

@Br0wnHammer
Copy link
Contributor Author

Thankyou @ajhollid, I will create a new PR with the said changes.

@Br0wnHammer Br0wnHammer deleted the fix/fe/uptime-refactor-http branch January 27, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants