Merge pull request #884 from bluewave-labs/fix/fe-prop-errors

Fix/fe prop errors
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-09-25 20:09:10 -07:00
commit 5ec032466b
6 files changed
+46 -17

No files matched your search

+10 -1
View File
@@ -16,6 +16,7 @@ import "./index.css";
* @param {Object} props * @param {Object} props
* @param {string} [props.type] - Type of input field (e.g., 'text', 'password'). * @param {string} [props.type] - Type of input field (e.g., 'text', 'password').
* @param {string} props.id - ID of the input field. * @param {string} props.id - ID of the input field.
* @param {string} props.name - Name of the input field.
* @param {string} [props.label] - Label for the input field. * @param {string} [props.label] - Label for the input field.
* @param {boolean} [props.https] - Indicates if it should display http or https. * @param {boolean} [props.https] - Indicates if it should display http or https.
* @param {boolean} [props.isRequired] - Indicates if the field is required, will display a red asterisk. * @param {boolean} [props.isRequired] - Indicates if the field is required, will display a red asterisk.
@@ -27,6 +28,7 @@ import "./index.css";
* @param {function} props.onChange - Function called on input change. * @param {function} props.onChange - Function called on input change.
* @param {string} [props.error] - Error message to display for the input field. * @param {string} [props.error] - Error message to display for the input field.
* @param {boolean} [props.disabled] - Indicates if the input field is disabled. * @param {boolean} [props.disabled] - Indicates if the input field is disabled.
* @param {boolean} [props.hidden] - Indicates if the input field is hidden.
* @param {React.Ref} [ref] - Ref forwarded to the underlying `TextField` component. Allows for direct interactions such as focusing. * @param {React.Ref} [ref] - Ref forwarded to the underlying `TextField` component. Allows for direct interactions such as focusing.
*/ */
@@ -35,6 +37,7 @@ const Field = forwardRef(
{ {
type = "text", type = "text",
id, id,
name,
label, label,
https, https,
isRequired, isRequired,
@@ -47,6 +50,7 @@ const Field = forwardRef(
onInput, onInput,
error, error,
disabled, disabled,
hidden,
}, },
ref ref
) => { ) => {
@@ -107,6 +111,7 @@ const Field = forwardRef(
)} )}
<TextField <TextField
type={type === "password" ? (isVisible ? "text" : type) : type} type={type === "password" ? (isVisible ? "text" : type) : type}
name={name}
id={id} id={id}
autoComplete={autoComplete} autoComplete={autoComplete}
placeholder={placeholder} placeholder={placeholder}
@@ -136,7 +141,9 @@ const Field = forwardRef(
borderBottomLeftRadius: theme.shape.borderRadius, borderBottomLeftRadius: theme.shape.borderRadius,
}, },
} }
: {} : {
display: hidden ? "none" : "",
}
} }
InputProps={{ InputProps={{
startAdornment: type === "url" && ( startAdornment: type === "url" && (
@@ -213,6 +220,7 @@ Field.propTypes = {
"number", "number",
]), ]),
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
name: PropTypes.string,
label: PropTypes.string, label: PropTypes.string,
https: PropTypes.bool, https: PropTypes.bool,
isRequired: PropTypes.bool, isRequired: PropTypes.bool,
@@ -225,6 +233,7 @@ Field.propTypes = {
onInput: PropTypes.func, onInput: PropTypes.func,
error: PropTypes.string, error: PropTypes.string,
disabled: PropTypes.bool, disabled: PropTypes.bool,
hidden: PropTypes.bool,
}; };
export default Field; export default Field;
@@ -1,5 +1,5 @@
import TabPanel from "@mui/lab/TabPanel"; import TabPanel from "@mui/lab/TabPanel";
import React, { useState } from "react"; import { useState } from "react";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material"; import { Box, Stack, Typography } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
@@ -116,6 +116,14 @@ const PasswordPanel = () => {
<Box flex={0.9}> <Box flex={0.9}>
<Typography component="h1">Current password</Typography> <Typography component="h1">Current password</Typography>
</Box> </Box>
<Field
type="text"
id="hidden-username"
name="username"
autoComplete="username"
hidden={true}
value=""
/>
<Field <Field
type="password" type="password"
id="edit-current-password" id="edit-current-password"
+1 -1
View File
@@ -134,7 +134,7 @@ const Monitors = ({ isAdmin }) => {
</Box> </Box>
<Box width="25%" minWidth={150} ml="auto"> <Box width="25%" minWidth={150} ml="auto">
<Search <Search
options={monitorState?.monitorsSummary.monitors} options={monitorState?.monitorsSummary?.monitors ?? []}
filteredBy="name" filteredBy="name"
value={search} value={search}
handleInputChange={handleSearch} handleInputChange={handleSearch}
+1 -1
View File
@@ -54,7 +54,7 @@ const PageSpeedDetails = ({ isAdmin }) => {
normalize: null, normalize: null,
}); });
setMonitor(res?.data?.data ?? {}); setMonitor(res?.data?.data ?? {});
setAudits(res?.data?.data?.checks?.[0]?.audits ?? []); setAudits(res?.data?.data?.checks?.[0]?.audits ?? {});
} catch (error) { } catch (error) {
logger.error(logger); logger.error(logger);
navigate("/not-found", { replace: true }); navigate("/not-found", { replace: true });
+16 -11
View File
@@ -20,6 +20,7 @@ const SERVICE_NAME = "monitorController";
const { errorMessages, successMessages } = require("../utils/messages"); const { errorMessages, successMessages } = require("../utils/messages");
const jwt = require("jsonwebtoken"); const jwt = require("jsonwebtoken");
const { getTokenFromHeaders } = require("../utils/utils"); const { getTokenFromHeaders } = require("../utils/utils");
const logger = require("../utils/logger");
/** /**
* Returns all monitors * Returns all monitors
@@ -315,18 +316,22 @@ const deleteMonitor = async (req, res, next) => {
try { try {
const monitor = await req.db.deleteMonitor(req, res, next); const monitor = await req.db.deleteMonitor(req, res, next);
// Delete associated checks,alerts,and notifications // Delete associated checks,alerts,and notifications
await req.jobQueue.deleteJob(monitor); try {
await req.db.deleteChecks(monitor._id); await req.jobQueue.deleteJob(monitor);
await req.db.deleteAlertByMonitorId(monitor._id); await req.db.deleteChecks(monitor._id);
await req.db.deletePageSpeedChecksByMonitorId(monitor._id); await req.db.deletePageSpeedChecksByMonitorId(monitor._id);
await req.db.deleteNotificationsByMonitorId(monitor._id); await req.db.deleteNotificationsByMonitorId(monitor._id);
} catch (error) {
logger.error(
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`,
{
method: "deleteMonitor",
service: SERVICE_NAME,
error: error.message,
}
);
}
/**
* TODO
* We should remove all checks and alerts associated with this monitor
* when it is deleted so there is no orphaned data
* We also need to make sure to stop all running services for this monitor
*/
return res return res
.status(200) .status(200)
.json({ success: true, msg: successMessages.MONITOR_DELETE }); .json({ success: true, msg: successMessages.MONITOR_DELETE });
+9 -2
View File
@@ -44,10 +44,17 @@ class NetworkService {
} }
async handleStatusUpdate(job, isAlive) { async handleStatusUpdate(job, isAlive) {
let monitor;
// Look up the monitor, if it doesn't exist, it's probably been removed, return
try { try {
const { _id } = job.data; const { _id } = job.data;
const monitor = await this.db.getMonitorById(_id); monitor = await this.db.getMonitorById(_id);
} catch (error) {
return;
}
// Otherwise, try to update monitor status
try {
if (monitor === null || monitor === undefined) { if (monitor === null || monitor === undefined) {
logger.error(`Null Monitor: ${_id}`, { logger.error(`Null Monitor: ${_id}`, {
method: "handleStatusUpdate", method: "handleStatusUpdate",
@@ -90,7 +97,7 @@ class NetworkService {
const endTime = Date.now(); const endTime = Date.now();
error.responseTime = endTime - startTime; error.responseTime = endTime - startTime;
error.service === undefined ? (error.service = SERVICE_NAME) : null; error.service === undefined ? (error.service = SERVICE_NAME) : null;
error.mheotd === undefined error.method === undefined
? (error.method = "measureResponseTime") ? (error.method = "measureResponseTime")
: null; : null;
throw error; throw error;