Skip to content

Commit c466edb

Browse files
authored
Merge pull request #2220 from Br0wnHammer/feat/fe/uptime-ignore-tsl-error
Feat: Ignore TLS/SSL Error Option
2 parents 6ff287d + a8f46d9 commit c466edb

File tree

4 files changed

+60
-20
lines changed

4 files changed

+60
-20
lines changed

client/src/Pages/Uptime/Create/index.jsx

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMon
1313
import { createUptimeMonitor } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
1414
// MUI
1515
import { Box, Stack, Typography, Button, ButtonGroup } from "@mui/material";
16+
import Switch from "@mui/material/Switch";
17+
import FormControlLabel from "@mui/material/FormControlLabel";
1618

1719
//Components
1820
import Breadcrumbs from "../../../Components/Breadcrumbs";
@@ -92,6 +94,7 @@ const CreateMonitor = () => {
9294
url: "",
9395
name: "",
9496
type: "http",
97+
ignoreTlsErrors: false,
9598
notifications: [],
9699
interval: 1,
97100
});
@@ -107,6 +110,7 @@ const CreateMonitor = () => {
107110
port: monitor.type === "port" ? monitor.port : undefined,
108111
name: monitor.name || monitor.url.substring(0, 50),
109112
type: monitor.type,
113+
ignoreTlsErrors: monitor.ignoreTlsErrors,
110114
interval: monitor.interval * MS_PER_MINUTE,
111115
};
112116

@@ -130,19 +134,6 @@ const CreateMonitor = () => {
130134
return;
131135
}
132136

133-
if (monitor.type === "http") {
134-
// const checkEndpointAction = await dispatch(
135-
// checkEndpointResolution({ monitorURL: form.url })
136-
// );
137-
// if (checkEndpointAction.meta.requestStatus === "rejected") {
138-
// createToast({
139-
// body: "The endpoint you entered doesn't resolve. Check the URL again.",
140-
// });
141-
// setErrors({ url: "The entered URL is not reachable." });
142-
// return;
143-
// }
144-
}
145-
146137
form = {
147138
...form,
148139
description: monitor.name || monitor.url,
@@ -160,19 +151,21 @@ const CreateMonitor = () => {
160151
};
161152

162153
const handleChange = (event, formName) => {
163-
const { value } = event.target;
154+
const { type, checked, value } = event.target;
155+
156+
const newVal = type === "checkbox" ? checked : value;
164157

165158
const newMonitor = {
166159
...monitor,
167-
[formName]: value,
160+
[formName]: newVal,
168161
};
169162
if (formName === "type") {
170163
newMonitor.url = "";
171164
}
172165
setMonitor(newMonitor);
173166

174167
const { error } = monitorValidation.validate(
175-
{ type: monitor.type, [formName]: value },
168+
{ type: monitor.type, [formName]: newVal },
176169
{ abortEarly: false }
177170
);
178171
setErrors((prev) => ({
@@ -422,6 +415,25 @@ const CreateMonitor = () => {
422415
</Box>
423416
</Stack>
424417
</ConfigBox>
418+
<ConfigBox>
419+
<Box>
420+
<Typography component="h2">{t("ignoreTLSError")}</Typography>
421+
<Typography component="p">{t("ignoreTLSErrorDescription")}</Typography>
422+
</Box>
423+
<Stack>
424+
<FormControlLabel
425+
control={
426+
<Switch
427+
name="ignore-error"
428+
checked={monitor.ignoreTlsErrors}
429+
onChange={(event) => handleChange(event, "ignoreTlsErrors")}
430+
sx={{ mr: theme.spacing(2) }}
431+
/>
432+
}
433+
label={t("tlsErrorIgnored")}
434+
/>
435+
</Stack>
436+
</ConfigBox>
425437
<ConfigBox>
426438
<Box>
427439
<Typography component="h2">

client/src/Utils/Theme/globalTheme.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,32 @@ const baseTheme = (palette) => ({
463463
MuiSwitch: {
464464
styleOverrides: {
465465
root: ({ theme }) => ({
466+
width: 42,
467+
height: 26,
468+
padding: 0,
469+
"& .MuiSwitch-switchBase": {
470+
padding: 0,
471+
margin: 2,
472+
transitionDuration: "300ms",
473+
"&.Mui-checked": {
474+
transform: "translateX(16px)",
475+
color: "#fff",
476+
"& + .MuiSwitch-track": {
477+
backgroundColor: theme.palette.accent.main,
478+
opacity: 1,
479+
border: 0,
480+
},
481+
},
482+
},
483+
"& .MuiSwitch-thumb": {
484+
boxSizing: "border-box",
485+
width: 22,
486+
height: 22,
487+
},
466488
"& .MuiSwitch-track": {
467-
backgroundColor: theme.palette.primary.contrastText,
489+
borderRadius: 13,
490+
backgroundColor: theme.palette.secondary.light,
491+
opacity: 1,
468492
},
469493
}),
470494
},

client/src/Validation/validation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const monitorValidation = joi.object({
170170
"string.max": "This field should not exceed the 50 characters limit.",
171171
}),
172172
type: joi.string().trim().messages({ "string.empty": "This field is required." }),
173+
ignoreTlsErrors: joi.boolean(),
173174
interval: joi.number().messages({
174175
"number.base": "Frequency must be a number.",
175176
"any.required": "Frequency is required.",

client/src/locales/gb.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,12 @@
403403
"DragandDrop": "drag and drop",
404404
"MaxSize": "Maximum Size",
405405
"SupportedFormats": "Supported formats",
406-
"FirstName": "Name",
407-
"LastName": "Surname",
408-
"EmailDescriptionText": "Your current email—it cannot be changed.",
406+
"FirstName": "First name",
407+
"LastName": "Last name",
408+
"EmailDescriptionText": "This is your current email address — it cannot be changed.",
409+
"ignoreTLSError": "Ignore TLS/SSL error",
410+
"tlsErrorIgnored": "TLS/SSL errors ignored",
411+
"ignoreTLSErrorDescription": "Ignore TLS/SSL errors and continue checking the website's availability",
409412
"YourPhoto": "Profile photo",
410413
"PhotoDescriptionText": "This photo will be displayed in your profile page.",
411414
"save": "Save",

0 commit comments

Comments
 (0)