Merge branch 'master' into feat/issue-225-Maintenance-page

This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-07-07 21:57:44 -07:00
commit 4de1e71344
95 files changed
+3630 -1384

No files matched your search

+176
View File
@@ -0,0 +1,176 @@
.account h1.MuiTypography-root,
.account p.MuiTypography-root,
.account input,
.account button,
.account td,
.account .MuiSelect-select {
font-size: var(--env-var-font-size-medium);
}
.account h1.MuiTypography-root,
.account p.MuiTypography-root,
.account input,
.account .MuiSelect-select {
color: var(--env-var-color-2);
}
.account h1.MuiTypography-root {
font-weight: 600;
}
.account .MuiStack-root:not(.table-stack) {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
}
.account .MuiTabPanel-root {
padding: 0;
margin-top: 50px;
}
.account .MuiDivider-root:not(.short-divider) {
margin: 50px 0;
}
.account .MuiDivider-root,
.account .MuiOutlinedInput-root fieldset {
border-color: var(--env-var-color-29);
}
.account [class$="-form"] {
width: inherit;
}
.account [class$="__wrapper"],
.account [class$="__wrapper compact"] {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
}
.edit-profile-form__wrapper>.MuiStack-root:not(.row-stack),
.edit-password-form__wrapper>.MuiStack-root:not(.row-stack),
.edit-organization-form__wrapper>.MuiStack-root:not(.row-stack) {
flex-direction: column;
gap: 8px;
margin-right: 10px;
}
.edit-profile-form__wrapper p.MuiTypography-root,
.delete-profile-form__wrapper p.MuiTypography-root {
opacity: 0.6;
}
#modal-delete-account,
#modal-edit-org-name,
#modal-invite-member {
font-size: var(--env-var-font-size-large);
}
.edit-profile-form__wrapper:not(:first-of-type),
.edit-password-form__wrapper:not(:first-of-type),
.edit-team-form__wrapper:not(:first-of-type) {
margin-top: var(--env-var-spacing-4);
}
.edit-team-form__wrapper.compact {
margin-top: var(--env-var-spacing-3);
justify-content: flex-start;
align-items: center;
}
.edit-profile-form__wrapper input,
.edit-password-form__wrapper input,
#edit-organization-name,
#input-team-member {
padding: 10px;
}
#edit-new-password + div > button > svg,
#edit-confirm-password + div > button > svg,
#edit-current-password + div > button > svg {
color: var(--env-var-color-29);
}
#org-name-flex-container .Mui-disabled {
color: var(--env-var-color-2) !important;
}
.edit-team-form__wrapper td {
padding: 10px 0;
padding-top: 20px;
vertical-align: text-top;
}
.edit-team-form__wrapper th {
padding: var(--env-var-spacing-1) 0;
}
.edit-team-form__wrapper th:first-of-type {
padding-left: 20px;
}
.edit-team-form__wrapper td {
color: var(--env-var-color-25);
}
#select-actions,
#select-role {
padding: 5px 0;
padding-left: 15px;
padding-right: 50px;
line-height: 1.75;
}
.MuiInputBase-root:has(#select-actions) fieldset,
.MuiInputBase-root:has(#select-role) fieldset {
border-color: #a1a7b1;
margin: -1px;
border-width: 1px;
}
.MuiInputBase-root:has(#select-actions):hover fieldset,
.MuiInputBase-root:has(#select-role):hover fieldset {
border-color: var(--env-var-color-2);
}
.MuiStack-root:has(.MuiBox-root > .members-query) .MuiBox-root {
cursor: pointer;
}
.members-query {
display: inline-flex;
justify-content: center;
align-items: center;
margin-left: 6px;
padding: 2px;
font-size: 12px;
font-weight: 500;
color: var(--env-var-color-3);
background-color: #e0e9fd;
min-width: 22px;
min-height: 22px;
border-radius: 50%;
}
/* for testing, will remove later */
@media only screen and (max-width: 1600px) {
.edit-profile-form__wrapper .MuiStack-root:not(.row-stack),
.edit-password-form__wrapper .MuiStack-root:not(.row-stack),
.edit-organization-form__wrapper .MuiStack-root:not(.row-stack) {
margin-right: 30px;
}
}
.account .MuiStack-root:has(p.MuiTypography-root.input-error) {
position: relative;
}
.account .text-field-icon {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 18px !important;
height: 18px !important;
opacity: 0.8;
}
.account p.MuiTypography-root.input-error {
color: var(--env-var-color-24);
opacity: 0.8;
position: absolute;
top: calc(100% + 5px);
}
.account .email-text-field,
.account .password-text-field {
margin: 0;
}
.edit-profile-form__wrapper .MuiFormControl-root,
.edit-password-form__wrapper .MuiFormControl-root {
width: 100%;
}
.edit-profile-form__wrapper .MuiStack-root:has(.MuiFormControl-root),
.edit-password-form__wrapper .MuiStack-root:has(.MuiFormControl-root) {
margin: 0;
}
+84
View File
@@ -0,0 +1,84 @@
import PropTypes from "prop-types";
import { useState } from "react";
import { Box, Tab, useTheme } from "@mui/material";
import TabContext from "@mui/lab/TabContext";
import TabList from "@mui/lab/TabList";
import "./index.css";
import ProfilePanel from "../../Components/TabPanels/Account/ProfilePanel";
import PasswordPanel from "../../Components/TabPanels/Account/PasswordPanel";
import TeamPanel from "../../Components/TabPanels/Account/TeamPanel";
import { useNavigate } from "react-router";
/**
* Account component renders a settings page with tabs for Profile, Password, and Team settings.
* @param {string} [props.open] - Specifies the initially open tab: 'profile', 'password', or 'team'.
* @returns {JSX.Element}
*/
const tabList = ["Profile", "Password", "Team"];
const Account = ({ open = "profile" }) => {
const theme = useTheme();
const navigate = useNavigate();
const tab = open;
const handleTabChange = (event, newTab) => {
navigate(`/account/${newTab}`);
};
return (
<Box
//TODO - breakpoints for responsive design
minWidth={theme.spacing(55)}
maxWidth="1200px"
py={theme.content.pY}
px={theme.content.pX}
className="account"
>
<TabContext value={tab}>
<Box
sx={{
borderBottom: 1,
borderColor: theme.palette.section.borderColor,
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
}}
>
<TabList onChange={handleTabChange} aria-label="account tabs">
{tabList.map((label, index) => (
<Tab
label={label}
key={index}
value={label.toLowerCase()}
sx={{
fontSize: "13px",
color: theme.palette.secondary.main,
textTransform: "none",
minWidth: "fit-content",
minHeight: 0,
paddingLeft: "0",
paddingY: "10px",
marginRight: "20px",
"&:focus": {
outline: "none",
},
"& .MuiTouchRipple-root": {
pointerEvents: "none",
display: "none",
},
}}
/>
))}
</TabList>
</Box>
<ProfilePanel />
<PasswordPanel />
<TeamPanel />
</TabContext>
</Box>
);
};
Account.propTypes = {
open: PropTypes.oneOf(["profile", "password", "team"]),
};
export default Account;
@@ -0,0 +1,69 @@
.create-monitor-form h1.MuiTypography-root {
font-size: var(--env-var-font-size-large-plus);
color: var(--env-var-color-1);
}
.create-monitor-form h1.MuiTypography-root,
.create-monitor-form h2.MuiTypography-root {
font-weight: 600;
}
.create-monitor-form h2.MuiTypography-root {
font-size: var(--env-var-font-size-large);
}
.create-monitor-form p.MuiTypography-root,
.create-monitor-form button.MuiButtonBase-root,
#monitor-frequencies {
font-size: var(--env-var-font-size-medium);
}
.create-monitor-form h2.MuiTypography-root,
.create-monitor-form h6.MuiTypography-root,
.create-monitor-form p.MuiTypography-root,
#monitor-frequencies {
color: var(--env-var-color-2);
}
.create-monitor-form h6.MuiTypography-root {
font-size: var(--env-var-font-size-small-plus);
opacity: 0.8;
}
.create-monitor-form .error-container {
position: relative;
}
.create-monitor-form .error-container p.MuiTypography-root.input-error {
color: var(--env-var-color-24);
opacity: 0.8;
position: absolute;
top: 0;
}
/* for testing, will remove later */
/* .config-box:has(.error-container):has(.input-error) {
border-color: var(--env-var-color-24);
} */
.create-monitor-form .MuiSelect-select.MuiSelect-outlined.MuiInputBase-input {
padding: var(--env-var-spacing-1);
}
.create-monitor-form .MuiInputBase-root:has(#monitor-frequencies) {
min-width: 300px;
width: 100%;
height: 34px;
border: 1px solid var(--env-var-color-4);
border-radius: var(--env-var-radius-1);
overflow: hidden;
}
.create-monitor-form .MuiInputBase-root:has(#monitor-frequencies) fieldset {
outline: none;
border: none;
}
.monitors-gaps-medium {
height: var(--env-var-spacing-2);
}
.monitors-gaps-small-plus {
height: var(--env-var-spacing-1-plus);
}
.monitors-create-button-holder {
display: flex;
justify-content: end;
}
+454
View File
@@ -0,0 +1,454 @@
import "./index.css";
import ConfigBox from "../../Components/ConfigBox";
import FlexibileTextField from "../../Components/TextFields/Flexibile/FlexibileTextField";
import React, { useState } from "react";
import RadioButton from "../../Components/RadioButton";
import CustomizableCheckBox from "../../Components/Checkbox/CustomizableCheckbox";
import Button from "../../Components/Button";
import { Box, MenuItem, Select, Stack, Typography } from "@mui/material";
import { useSelector, useDispatch } from "react-redux";
import { createMonitorValidation } from "../../Validation/validation";
import { createMonitor } from "../../Features/Monitors/monitorsSlice";
import { useNavigate } from "react-router-dom";
import { useTheme } from "@emotion/react";
import WestRoundedIcon from "@mui/icons-material/WestRounded";
const CreateNewMonitor = () => {
const MS_PER_MINUTE = 60000;
const { user, authToken } = useSelector((state) => state.auth);
const dispatch = useDispatch();
const navigate = useNavigate();
const theme = useTheme();
const [errors, setErrors] = useState({});
//General Settings Form
const [generalSettings, setGeneralSettings] = useState({ url: "", name: "" });
//Checks Form
const [checks, setChecks] = useState({
type: "",
// port: ""
});
//Incidents Form
// const [notifications, setNotifications] = useState({
// viaSms: false,
// viaEmail: false,
// viaOther: false,
// email: "",
// });
//Advanced Settings Form
const [advancedSettings, setAdvancedSettings] = useState({
frequency: 1,
// retries: "",
// codes: "",
// redirects: "",
});
//Proxy Settings Form
// const [proxy, setProxy] = useState({
// enabled: false,
// protocol: "",
// address: "",
// proxy_port: "",
// });
const handleChange = (event, id, setState, checkbox) => {
const { value } = event.target;
setState((prev) => ({
...prev,
[id]: checkbox ? true : value,
}));
const validation = createMonitorValidation.validate(
{ [id]: value },
{ abortEarly: false }
);
setErrors((prev) => {
const updatedErrors = { ...prev };
if (validation.error) {
updatedErrors[id] = validation.error.details[0].message;
} else {
delete updatedErrors[id];
}
return updatedErrors;
});
};
// const handleCheck = (id, setState) => {
// setState((prev) => ({
// ...prev,
// [id]: !prev[id],
// }));
// };
const handleCreateNewMonitor = async (event) => {
event.preventDefault();
//obj to submit
let monitor = {
...generalSettings,
...checks,
};
const { error } = createMonitorValidation.validate(monitor, {
abortEarly: false,
});
if (error) {
const newErrors = {};
error.details.forEach((err) => {
newErrors[err.path[0]] = err.message;
});
setErrors(newErrors);
} else {
monitor = {
...monitor,
description: monitor.name,
userId: user._id,
// ...advancedSettings, // TODO frequency should be interval, then we can use spread
interval: advancedSettings.frequency * MS_PER_MINUTE,
};
try {
const action = await dispatch(createMonitor({ authToken, monitor }));
if (action.meta.requestStatus === "fulfilled") {
navigate("/monitors");
}
} catch (error) {
alert(error);
}
}
};
//select values
// const ports = ["Port 1", "Port 2", "Port 3"];
const frequencies = [1, 2, 3, 4, 5];
return (
<form
className="create-monitor-form"
onSubmit={handleCreateNewMonitor}
noValidate
spellCheck="false"
style={{
maxWidth: "1200px",
flex: 1,
padding: `${theme.content.pY} ${theme.content.pX}`,
}}
>
<Button
level="tertiary"
label="Back"
img={<WestRoundedIcon />}
onClick={() => navigate("/monitors")}
sx={{
backgroundColor: "#f4f4f4",
mb: theme.gap.medium,
px: theme.gap.ml,
"& svg.MuiSvgIcon-root": {
pr: theme.gap.small,
},
}}
/>
<Typography component="h1">Create new monitor</Typography>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<Stack gap={theme.gap.small}>
<Typography component="h2">General settings</Typography>
<Typography component="p">
Here you can select the URL of the host, together with the type of
monitor.
</Typography>
</Stack>
}
rightLayout={
<Stack gap={theme.gap.xl}>
<FlexibileTextField
id="monitor-url"
title="URL to monitor"
type="url"
placeholder="https://google.com"
value={generalSettings.url}
onChange={(event) =>
handleChange(event, "url", setGeneralSettings)
}
error={errors["url"]}
/>
<FlexibileTextField
id="monitor-name"
title={
<>
Friendly name <span>(optional)</span>
</>
}
type="text"
placeholder="Google"
value={generalSettings.name}
onChange={(event) =>
handleChange(event, "name", setGeneralSettings)
}
error={errors["name"]}
/>
</Stack>
}
/>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<Stack gap={theme.gap.small}>
<Typography component="h2">Checks to perform</Typography>
<Typography component="p">
You can always add or remove checks after adding your site.
</Typography>
</Stack>
}
rightLayout={
<Stack gap={theme.gap.large}>
<RadioButton
id="monitor-checks-http"
title="HTTP/website monitoring"
desc="Use HTTP(s) to monitor your website or API endpoint."
size="small"
value="http"
checked={checks.type === "http"}
onChange={(event) => handleChange(event, "type", setChecks)}
/>
<RadioButton
id="monitor-checks-ping"
title="Ping monitoring"
desc="Check whether your server is available or not."
size="small"
value="ping"
checked={checks.type === "ping"}
onChange={(event) => handleChange(event, "type", setChecks)}
/>
{/* TODO */}
{/* <RadioButton
id="monitor-checks-port"
title="Port monitoring"
desc="Monitor a specific service on your server."
value="port"
checked={checks.type === "port"}
onChange={(event) => handleChange(event, "type", setChecks)}
/>
<div className="monitors-gaps-small-plus"></div>
<div className="monitors-dropdown-holder">
<Select
id="monitor-ports"
value={checks.port || "placeholder"}
inputProps={{ id: "monitor-ports-select" }}
onChange={(event) => handleChange(event, "port", setChecks)}
>
<MenuItem id="port-placeholder" value="placeholder">
Select a port to check
</MenuItem>
{ports.map((port, index) => (
<MenuItem key={`port-${index}`} value={port}>
{port}
</MenuItem>
))}
</Select>
</div> */}
<Box className="error-container">
{errors["type"] ? (
<Typography component="p" className="input-error">
{errors["type"]}
</Typography>
) : (
""
)}
</Box>
</Stack>
}
/>
{/* TODO */}
{/* <div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Incident notifications</div>
<div className="config-box-desc-text">
When there is an incident, notify users.
</div>
</div>
}
rightLayout={
<div className="incident-notif-config">
<div className="incident-notif-config-title">
When there is a new incident,
</div>
<div className="monitors-gaps-medium"></div>
<div className="incident-notif-config-checks">
<CustomizableCheckBox
id="monitor-notify-sms"
title="Notify via SMS (to be implemented)"
isChecked={notifications.viaSms}
handleChange={() => handleCheck("viaSms", setNotifications)}
/>
<div className="monitors-gaps-medium"></div>
<CustomizableCheckBox
id="monitor-notify-email"
title="Notify via email (to current email address)"
isChecked={notifications.viaEmail}
handleChange={() => handleCheck("viaEmail", setNotifications)}
/>
<div className="monitors-gaps-medium"></div>
<CustomizableCheckBox
id="monitor-notify-other"
title="Notify via email (to another email address below)"
isChecked={notifications.viaOther}
handleChange={() => handleCheck("viaOther", setNotifications)}
/>
<div className="monitors-gaps-small-plus"></div>
<div className="monitors-dropdown-holder">
<FlexibileTextField
id="monitor-notify-other-email"
placeholder="notifications@gmail.com"
type="email"
value={notifications.email}
onChange={(event) =>
handleChange(event, "email", setNotifications)
}
/>
</div>
</div>
</div>
}
/> */}
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<Stack gap={theme.gap.small}>
<Typography component="h2">Advanced settings</Typography>
</Stack>
}
rightLayout={
<Stack gap={theme.gap.large}>
{/* TODO - refactor select component */}
<Box>
<Typography component="p" mb={theme.gap.small}>
Check frequency
</Typography>
<Select
id="monitor-frequencies"
value={advancedSettings.frequency || 1}
inputProps={{ id: "monitor-frequencies-select" }}
onChange={(event) =>
handleChange(event, "frequency", setAdvancedSettings)
}
MenuProps={{
PaperProps: {
style: {
marginTop: "10px",
},
},
}}
>
{frequencies.map((freq) => (
<MenuItem
key={`port-${freq}`}
value={freq}
sx={{
fontSize: "13px",
borderRadius: `${theme.shape.borderRadius}px`,
margin: "5px",
}}
>
{freq} {freq === 1 ? "minute" : "minutes"}
</MenuItem>
))}
</Select>
</Box>
{/* TODO */}
{/* <FlexibileTextField
id="monitor-settings-retries"
title="Maximum retries before the service is marked as down"
type="number"
value={advancedSettings.retries}
onChange={(event) =>
handleChange(event, "retries", setAdvancedSettings)
}
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
id="monitor-settings-codes"
title="Accepted status codes"
type="number"
value={advancedSettings.codes}
onChange={(event) =>
handleChange(event, "codes", setAdvancedSettings)
}
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
id="monitor-settings-redirects"
title="Maximum redirects"
type="number"
value={advancedSettings.redirects}
onChange={(event) =>
handleChange(event, "redirects", setAdvancedSettings)
}
/> */}
</Stack>
}
/>
{/* TODO */}
{/* <div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Proxy settings</div>
</div>
}
rightLayout={
<div className="proxy-setting-config">
<CustomizableCheckBox
id="monitor-proxy-enable"
title="Enable proxy"
isChecked={proxy.enabled}
handleChange={() => handleCheck("enabled", setProxy)}
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
id="monitor-proxy-protocol"
title="Proxy protocol"
value={proxy.protocol}
onChange={(event) => handleChange(event, "protocol", setProxy)}
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
id="monitor-proxy-address"
title="Proxy address"
value={proxy.address}
onChange={(event) => handleChange(event, "address", setProxy)}
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
id="monitor-proxy-port"
title="Proxy port"
value={proxy.proxy_port}
onChange={(event) => handleChange(event, "proxy_port", setProxy)}
/>
</div>
}
/> */}
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-small"></div>
<div className="monitors-create-button-holder">
<Button
id="create-new-monitor-btn"
level="primary"
label="Create new monitor"
sx={{ width: "210px", fontSize: "var(--env-var-font-size-medium)" }}
onClick={handleCreateNewMonitor}
disabled={Object.keys(errors).length !== 0 && true}
/>
</div>
</form>
);
};
export default CreateNewMonitor;
+36
View File
@@ -15,6 +15,7 @@ import {
Tabs,
Typography,
Stack,
Box,
} from "@mui/material";
import { ColoredLabel, StatusLabel } from "../../Components/Label/";
import Avatar from "../../Components/Avatar/";
@@ -29,12 +30,16 @@ import AddIcon from "@mui/icons-material/Add";
import Divider from "@mui/material/Divider";
import UploadIcon from "@mui/icons-material/Upload";
import SendIcon from "@mui/icons-material/Send";
import ImageIcon from "@mui/icons-material/Image";
// Redux
import { useSelector } from "react-redux";
import { useDispatch } from "react-redux";
import { getMonitors } from "../../Features/Monitors/monitorsSlice";
import { getMonitorsByUserId } from "../../Features/Monitors/monitorsSlice";
import ImageField from "../../Components/TextFields/Image";
import ProgressUpload from "../../Components/ProgressBars";
import Alert from "../../Components/Alert";
const cols = [
{
@@ -415,6 +420,37 @@ const Demo = () => {
/>
</Stack>
<Divider sx={{ margin: `${theme.spacing(2)}` }} />
<Stack justifyContent="center" alignItems="center">
<ImageField />
</Stack>
<Divider sx={{ margin: `${theme.spacing(2)}` }} />
<Stack justifyContent="center" alignItems="center">
<ProgressUpload icon={<ImageIcon />} label="image.jpg" size="2 MB" />
</Stack>
<Divider sx={{ margin: `${theme.spacing(2)}` }} />
<Stack justifyContent="center" alignItems="center">
<Box width="500px">
<Alert
variant="info"
title="SSO login"
body="Since you logged in via SSO, you cannot reset or modify your password."
/>
</Box>
<Box width="500px" mt="5px">
<Alert
variant="warning"
body="New password must contain at least 8 characters and must have at least one uppercase letter, one number and one symbol."
/>
</Box>
<Box width="500px" mt="5px">
<Alert
variant="error"
title="Error"
body="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
/>
</Box>
</Stack>
<Divider sx={{ margin: `${theme.spacing(2)}` }} />
</div>
);
};
+165 -5
View File
@@ -1,7 +1,167 @@
import React from "react";
import * as React from 'react';
import TextField from '@mui/material/TextField';
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
import { styled, useTheme } from '@mui/material/styles';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import { StatusLabel } from "../../Components/Label/";
import TuneIcon from '@mui/icons-material/Tune';
const Incidents = () => {
return <div>Incidents</div>;
};
/**
* Creates a styled TableCell component.
* @param {object} theme - The theme object.
* @returns {JSX.Element} The styled TableCell component.
*/
const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
backgroundColor: theme.palette.action.hover,
color: theme.palette.common.black,
},
[`&.${tableCellClasses.body}`]: {
fontSize: 14,
},
}));
export default Incidents;
/**
* Creates a styled TableRow component.
* @param {object} theme - The theme object.
* @returns {JSX.Element} The styled TableRow component.
*/
const StyledTableRow = styled(TableRow)(({ theme }) => ({
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover,
},
'&:nth-of-type(even)': {
backgroundColor: theme.palette.common.white,
},
'&:last-child td, &:last-child th': {
border: 0,
},
}));
const filterOptions = createFilterOptions({
matchFrom: 'start',
stringify: (option) => option.title,
});
const titles = [
{ title: 'Down' },
{ title: 'Cannot resolve' },
{ title: 'Clear / show all' },
];
/**
* Creates a data object for the table row.
* @param {JSX.Element} name - The status label JSX element.
* @param {string} date - The date and time string.
* @param {string} message - The message string.
* @returns {object} The data object containing name, date, and message.
*/
function createData(name, date, message) {
return { name, date, message };
}
/**
* Customized table component displaying incident history.
* @returns {JSX.Element} The JSX element representing the customized table.
*/
export default function CustomizedTables() {
const theme = useTheme();
const rows = [
createData(<StatusLabel status="Down" customStyles={{ backgroundColor: '#fff9f9', borderColor: '#ffcac6', color: '#344054' }} />, '2024-03-14 21:41:09', 'HTTP 350 - NOK'),
createData(<StatusLabel status="Down" customStyles={{ backgroundColor: '#fff9f9', borderColor: '#ffcac6', color: '#344054' }} />, '2024-03-14 21:41:09', 'timeout of 48000ms exceeded'),
createData(<StatusLabel status="Cannot resolve" customStyles={{ backgroundColor: '#f2f4f7', borderColor: '#d2d6de', color: '#344054' }} />, '2024-03-14 21:41:09', 'timeout of 48000ms exceeded'),
createData(<StatusLabel status="Cannot resolve" customStyles={{ backgroundColor: '#f2f4f7', borderColor: '#d2d6de', color: '#344054' }} />, '2024-03-14 21:41:09', 'timeout of 48000ms exceeded'),
createData(<StatusLabel status="Down" customStyles={{ backgroundColor: '#fff9f9', borderColor: '#ffcac6', color: '#344054' }} />, '2024-03-14 21:41:09', 'HTTP 350 - NOK'),
];
return (
<Box
sx={{
marginTop: theme.spacing(4),
marginX: 'auto',
width: '80%',
paddingX: theme.spacing(6),
[theme.breakpoints.down('md')]: {
width: '100%',
},
}}
>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: theme.spacing(2) }}>
<Typography variant="h6" component="div" sx={{ fontWeight: 600, fontSize: 16 }}>
Incident History
</Typography>
<Filter />
</Box>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 700 }} aria-label="customized table">
<TableHead>
<TableRow>
<StyledTableCell>Status</StyledTableCell>
<StyledTableCell align="right">Date & Time</StyledTableCell>
<StyledTableCell align="right">Message</StyledTableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row, index) => (
<StyledTableRow key={index}>
<StyledTableCell component="th" scope="row">
{row.name}
</StyledTableCell>
<StyledTableCell align="right">{row.date}</StyledTableCell>
<StyledTableCell align="right">{row.message}</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Box>
);
}
/**
* Filter component with autocomplete for status filtering.
* @returns {JSX.Element} The JSX element representing the filter component.
*/
function Filter() {
return (
<Autocomplete
id="filter-demo"
options={titles}
getOptionLabel={(option) => option.title}
filterOptions={filterOptions}
sx={{
width: 170,
'& .MuiAutocomplete-inputRoot': {
height: '50px',
},
'& .MuiAutocomplete-listbox': {
maxHeight: '200px',
},
}}
disableClearable
renderInput={(params) => (
<TextField
{...params}
size="small"
label={
<React.Fragment>
<TuneIcon sx={{ marginRight: '0.5rem', position: 'relative', top: '6px' }} />
Filter by status
</React.Fragment>
}
InputProps={{ ...params.InputProps, endAdornment: null }}
/>
)}
/>
);
}
+7 -1
View File
@@ -41,7 +41,13 @@
#login-email-input {
width: 308px;
height: 11px;
height: 1px;
font-size: var(--env-var-font-size-medium);
}
#login-password-input {
width: 308px;
height: 1px;
font-size: var(--env-var-font-size-medium);
}
+16
View File
@@ -13,6 +13,8 @@ import PasswordTextField from "../../Components/TextFields/Password/PasswordText
import { loginValidation } from "../../Validation/validation";
import { login } from "../../Features/Auth/authSlice";
import { useDispatch } from "react-redux";
import axios from "axios";
const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
const Login = () => {
const dispatch = useDispatch();
@@ -30,6 +32,19 @@ const Login = () => {
password: "",
});
useEffect(() => {
axios
.get(BASE_URL + "/auth/users/admin")
.then((response) => {
if (response.data.data === false) {
navigate("/register");
}
})
.catch((error) => {
console.log(error);
});
}, [navigate]);
useEffect(() => {
const { error } = loginValidation.validate(form, {
abortEarly: false,
@@ -83,6 +98,7 @@ const Login = () => {
const handleSignupClick = () => {
navigate("/register");
};
return (
<div className="login-page">
<BackgroundPattern></BackgroundPattern>
@@ -1,105 +0,0 @@
import ConfigBox from "../../Components/ConfigBox";
import FlexibileTextField from "../../Components/TextFields/Flexibile/FlexibileTextField";
import "./index.css";
import React from "react";
import RadioButton from "../../Components/RadioButton";
const CreateNewMonitor = () => {
return (
<div>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<div className="new-monitor-header">Create new monitor</div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">General settings</div>
<div className="config-box-desc-text">
Here you can select the URL of the host, together with the type of
monitor.
</div>
</div>
}
rightLayout={
<div className="config-box-inputs">
<FlexibileTextField
title="URL to monitor"
type="url"
placeholder="https://google.com"
/>
<div className="monitors-gaps-medium"></div>
<FlexibileTextField
title="Friendly name (optional)"
type="text"
placeholder="Google"
/>
</div>
}
/>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Checks to perform</div>
<div className="config-box-desc-text">
You can always add or remove checks after adding your site.
</div>
</div>
}
rightLayout={
<div className="service-check-list">
<RadioButton
title="HTTP/website monitoring"
desc="Use HTTP(s) to monitor your website or API endpoint."
/>
<div className="monitors-gaps-medium"></div>
<RadioButton
title="Ping monitoring"
desc="Check whether your server is available or not."
/>
<div className="monitors-gaps-medium"></div>
<RadioButton
title="Port monitoring"
desc="Monitor a specific service on your server."
/>
<div className="monitors-gaps-medium"></div>
</div>
}
/>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Incident notifications</div>
<div className="config-box-desc-text">
When there is an incident, notify users.
</div>
</div>
}
/>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Advanced settings</div>
</div>
}
/>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<ConfigBox
leftLayout={
<div className="config-box-desc">
<div className="config-box-desc-title">Proxy settings</div>
</div>
}
/>
</div>
);
};
export default CreateNewMonitor;
@@ -1,56 +0,0 @@
import Button from "../../Components/Button";
import ServerStatus from "../../Components/Charts/Servers/ServerStatus";
import CurrentMonitors from "../../Components/CurrentMonitors";
import PropTypes from "prop-types";
/**
* CurrentStats displays the current status of monitor
*
* @component
* @param {Array<Monitor>} monitors - An array of monitor objects to be displayed.
*/
const CurrentStats = ({ monitors }) => {
const up = monitors.reduce((acc, cur) => {
if (cur.checks.length > 0) {
return cur.checks[cur.checks.length - 1].status === true ? acc + 1 : acc;
}
return 0;
}, 0);
const down = monitors.reduce((acc, cur) => {
if (cur.checks.length > 0) {
return cur.checks[cur.checks.length - 1].status === false ? acc + 1 : acc;
}
return 0;
}, 0);
return (
<div>
<div className="monitors-gaps-medium"></div>
<div className="monitors-gaps-medium"></div>
<div className="monitors-bar">
<div className="monitors-bar-title">Hello, Jackie</div>
<Button
level="primary"
label="Create new monitor"
sx={{ padding: "10px 20px", fontSize: "13px" }}
/>
</div>
<div className="monitors-gaps-medium"></div>
<div className="monitors-stats">
<ServerStatus title="Up" value={up} state="up" />
<ServerStatus title="Down" value={down} state="down" />
<ServerStatus title="Paused" value={0} state="pause" />
</div>
<div className="monitors-gaps-medium"></div>
<CurrentMonitors monitors={monitors} />
</div>
);
};
CurrentStats.propTypes = {
monitors: PropTypes.arrayOf(PropTypes.object).isRequired,
};
export default CurrentStats;
+59
View File
@@ -4,7 +4,12 @@
padding: 4vw;
}
.monitors {
font-family: var(--env-var-font-familt-1);
}
.monitors-bar {
margin-top: calc(2 * var(--env-var-spacing-2));
display: flex;
justify-content: space-between;
align-items: center;
@@ -16,6 +21,7 @@
}
.monitors-stats {
margin-top: var(--env-var-spacing-2);
display: flex;
gap: 24px;
}
@@ -24,6 +30,14 @@
height: var(--env-var-spacing-2);
}
.monitors-gaps-small-plus {
height: var(--env-var-spacing-1-plus);
}
.monitors-gaps-small {
height: 6px;
}
.new-monitor-header {
color: var(--env-var-color-1);
font-size: var(--env-var-font-size-large-plus);
@@ -43,3 +57,48 @@
.host-status-box-text {
font-size: var(--env-var-font-size-medium);
}
.monitors-dropdown-holder {
padding-left: 30px;
}
#ports-list {
width: 172.92px;
height: 12px;
font-size: var(--env-var-font-size-small);
align-items: center;
}
.incident-notif-config-title,
.adv-setting-title {
color: var(--env-var-color-5);
font-size: var(--env-var-font-size-medium);
}
.adv-setting-title {
font-weight: 500;
}
.config-box-inputs,
.service-check-list,
.incident-notif-config,
.advanced-setting-config,
.proxy-setting-config {
min-width: 350px;
padding-right: 40px;
}
.monitors-create-button-holder {
display: flex;
justify-content: end;
}
#create-new-monitor-btn {
padding-top: 6px;
}
#ports-dropdown,
#freq-dropdown {
width: 226.8px;
height: 20px;
}
+54 -7
View File
@@ -1,23 +1,70 @@
// import CreateNewMonitor from "./CreateNewMonitor";
import CurrentStats from "./CurrentStats";
import "./index.css";
import "./monitors.css";
import { useEffect } from "react";
import { useSelector } from "react-redux";
import { useDispatch } from "react-redux";
import { useSelector, useDispatch } from "react-redux";
import { getMonitorsByUserId } from "../../Features/Monitors/monitorsSlice";
import { useNavigate } from "react-router-dom";
import Button from "../../Components/Button";
import ServerStatus from "../../Components/Charts/Servers/ServerStatus";
import SearchTextField from "../../Components/TextFields/Search/SearchTextField";
import HostsTable from "../../Components/HostsTable";
import Pagination from "../../Components/Pagination";
const Monitors = () => {
const navigate = useNavigate();
const monitorState = useSelector((state) => state.monitors);
const authstate = useSelector((state) => state.auth);
const authState = useSelector((state) => state.auth);
const dispatch = useDispatch();
useEffect(() => {
dispatch(getMonitorsByUserId(authstate.authToken));
dispatch(getMonitorsByUserId(authState.authToken));
}, []);
const up = monitorState.monitors.reduce((acc, cur) => {
return cur.status === true ? acc + 1 : acc;
}, 0);
const down = monitorState.monitors.length - up;
return (
<div className="monitors">
<CurrentStats monitors={monitorState.monitors} />
<div className="monitors-bar">
<div className="monitors-bar-title">
Hello, {authState.user.firstname}
</div>
<Button
level="primary"
label="Create new monitor"
onClick={() => {
navigate("/monitors/create");
}}
sx={{ padding: "10px 20px", fontSize: "13px" }}
/>
</div>
<div className="monitors-stats">
<ServerStatus title="Up" value={up} state="up" />
<ServerStatus title="Down" value={down} state="down" />
<ServerStatus title="Paused" value={0} state="pause" />
</div>
<div className="current-monitors">
<div className="current-monitors-bar">
<div className="current-monitors-title-holder">
<div className="current-monitors-title">Current monitors</div>
<div className="current-monitors-counter">
{monitorState.monitors.length}
</div>
</div>
<div className="current-monitors-search-bar">
<SearchTextField />
</div>
</div>
<div className="monitors-v-gaping"></div>
<HostsTable monitors={monitorState.monitors} />
<div className="monitors-v-gaping"></div>
<Pagination />
</div>
</div>
);
};
+118
View File
@@ -0,0 +1,118 @@
.current-monitors {
margin-top: var(--env-var-spacing-2);
border: 1px solid #eaecf0;
padding: 40px;
border-radius: 4px;
}
.current-monitors-title-holder {
display: flex;
}
.current-monitors-bar {
display: flex;
justify-content: space-between;
}
.current-monitors-title {
font-size: 1rem;
font-weight: bold;
margin-right: var(--env-var-spacing-1);
}
.current-monitors-counter {
width: var(--env-var-spacing-2);
height: var(--env-var-spacing-2);
background-color: var(--env-var-color-15);
border: 1px solid var(--env-var-color-6);
border-radius: 50%;
text-align: center;
align-items: center;
}
.monitors-v-gaping {
height: var(--env-var-spacing-3);
}
.current-monitors-table {
width: 100%;
text-align: left;
}
.current-monitors-table {
width: 100%;
text-align: left;
border-collapse: collapse;
border: 1px solid var(--env-var-color-16);
border-radius: var(--env-var-radius-1);
}
.current-monitors-table th,
.current-monitors-table td {
border: 1px solid var(--env-var-color-16);
border-left: none;
border-right: none;
padding: 8px;
}
.theader-row {
background-color: var(--env-var-color-13);
color: var(--env-var-color-2);
font-weight: 500;
}
.theader-row td {
padding: var(--env-var-spacing-1) var(--env-var-spacing-2);
font-size: var(--env-var-font-size-medium);
}
.host-list-item {
display: flex;
align-items: center;
cursor: pointer;
}
.host-list-item-open {
width: var(--env-var-img-width-2);
height: var(--env-var-img-width-2);
margin-right: 8px;
}
.host-list-item-name {
font-size: var(--env-var-font-size-medium);
font-weight: bold;
margin-right: var(--env-var-spacing-1);
}
.host-list-item-precentage {
font-size: var(--env-var-font-size-medium);
}
.tbody-row td {
padding: var(--env-var-spacing-2) var(--env-var-img-width-2);
}
.host-status-box {
display: flex;
width: fit-content;
border: 1px solid var(--env-var-color-4);
border-radius: var(--env-var-radius-2);
align-items: center;
padding: calc(var(--env-var-spacing-1) / 2);
}
.host-status-box-circle {
width: 6px;
height: 6px;
border-radius: 50%;
margin-right: calc(var(--env-var-spacing-1) / 2);
}
.host-actions {
margin: auto;
cursor: pointer;
}
.tbody-row-cell.actions-cell {
padding-left: 30px;
}
+4 -4
View File
@@ -4,12 +4,12 @@ import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
import HelpOutlineIcon from "@mui/icons-material/HelpOutline";
import WebsiteTextField from "../../Components/TextFields/Website/WebsiteTextField";
import DescriptionTextField from "../../Components/TextFields/Description/DescriptionTextField";
import AnnouncementsDualButton from "../../Components/Announcements/AnnouncementsDualButton/AnnouncementsDualButton";
import AnnouncementsDualButtonWithIcon from "../../Components/Announcements/AnnouncementsDualButtonWithIcon/AnnouncementsDualButtonWithIcon";
import AnnouncementsDualButton from "../../Components/Toast/AnnouncementsDualButton/AnnouncementsDualButton";
import AnnouncementsDualButtonWithIcon from "../../Components/Toast/AnnouncementsDualButtonWithIcon/AnnouncementsDualButtonWithIcon";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import ComplexAlert from "../../Components/Icons/ComplexAlert/ComplexAlert";
import AnnouncementsMessageBar from "../../Components/Announcements/AnnouncementsMessageBar/AnnouncementsMessageBar";
import AnnouncementUpdateSubscription from "../../Components/Announcements/AnnouncementUpdateSubscription/AnnouncementUpdateSubscription";
import AnnouncementsMessageBar from "../../Components/Toast/AnnouncementsMessageBar/AnnouncementsMessageBar";
import AnnouncementUpdateSubscription from "../../Components/Toast/AnnouncementUpdateSubscription/AnnouncementUpdateSubscription";
import PlayGroundCharts from "./PlayGround-Charts";
import PlayGroundPopupModals from "./PlayGround-Popup-Modals";
import PlayGroundTooltips from "./PlayGround-Tooltips";
+18 -2
View File
@@ -14,6 +14,7 @@ import { registerValidation } from "../../Validation/validation";
import { useDispatch } from "react-redux";
import { register } from "../../Features/Auth/authSlice";
import axios from "axios";
const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
@@ -36,8 +37,22 @@ const Register = () => {
lastname: "",
email: "",
password: "",
role: "",
});
useEffect(() => {
axios
.get(BASE_URL + "/auth/users/admin")
.then((response) => {
if (response.data.data === true) {
navigate("/login");
}
})
.catch((error) => {
console.log(error);
});
}, [form, navigate]);
useEffect(() => {
const { error } = registerValidation.validate(form, {
abortEarly: false,
@@ -62,8 +77,9 @@ const Register = () => {
const handleSubmit = async (e) => {
e.preventDefault();
try {
await registerValidation.validateAsync(form, { abortEarly: false });
const action = await dispatch(register(form));
const adminForm = { ...form, role: "admin" };
await registerValidation.validateAsync(adminForm, { abortEarly: false });
const action = await dispatch(register(adminForm));
if (action.meta.requestStatus === "fulfilled") {
const token = action.payload.data;
-196
View File
@@ -1,196 +0,0 @@
.settings h1.MuiTypography-root,
.settings p.MuiTypography-root,
.settings input,
.settings button,
.settings td,
.settings .MuiSelect-select {
font-size: var(--env-var-font-size-medium);
}
.settings h1.MuiTypography-root,
.settings p.MuiTypography-root,
.settings input,
.settings .MuiSelect-select {
color: var(--env-var-color-2);
}
.settings h1.MuiTypography-root {
font-weight: 600;
}
.settings .MuiStack-root:not(.table-stack) {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
}
.settings .MuiTabPanel-root {
padding: 0;
margin-top: 50px;
}
.settings .MuiDivider-root:not(.short-divider) {
margin: 50px 0;
}
.settings .MuiDivider-root,
.settings .MuiOutlinedInput-root fieldset,
.announcement-tile {
border-color: var(--env-var-color-29);
}
[class$="-form"] {
width: inherit;
}
[class$="__wrapper"],
[class$="__wrapper compact"] {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
}
.edit-profile-form__wrapper .MuiStack-root:not(.row-stack),
.edit-password-form__wrapper .MuiStack-root:not(.row-stack),
.edit-organization-form__wrapper .MuiStack-root:not(.row-stack) {
flex-direction: column;
gap: 8px;
margin-right: 10px;
}
.edit-profile-form__wrapper p.MuiTypography-root,
.delete-profile-form__wrapper p.MuiTypography-root {
opacity: 0.6;
}
#modal-delete-account,
#modal-edit-org-name,
#modal-invite-member {
font-size: var(--env-var-font-size-large);
}
.edit-profile-form__wrapper:not(:first-of-type),
.edit-password-form__wrapper:not(:first-of-type),
.edit-team-form__wrapper:not(:first-of-type) {
margin-top: var(--env-var-spacing-4);
}
.edit-team-form__wrapper.compact {
margin-top: var(--env-var-spacing-3);
justify-content: flex-start;
align-items: center;
}
.edit-profile-form__wrapper input,
.edit-password-form__wrapper input,
#edit-organization-name,
#input-team-member {
padding: 10px;
}
.edit-password-form__wrapper > .announcement-tile {
width: 100%;
}
.edit-password-form__wrapper
> .announcement-tile
.announcement-content-subject {
margin-bottom: 2px;
}
#edit-new-password + div > button > svg,
#edit-confirm-password + div > button > svg,
#edit-current-password + div > button > svg {
color: var(--env-var-color-29);
}
.edit-password-form__wrapper .announcement-tile {
margin: 0;
}
.edit-password-form__wrapper .announcement-tile .announcement-close {
margin-left: auto;
}
.MuiBox-root > .announcement-tile {
border-color: var(--env-var-color-27);
background-color: var(--lighter-env-var-color-27);
}
.MuiBox-root > .announcement-tile .announcement-content-body {
color: var(--env-var-color-28);
}
.MuiBox-root > .announcement-tile .announcement-close svg,
.edit-password-form__wrapper > .announcement-tile .announcement-close svg {
display: none;
}
#org-name-flex-container .Mui-disabled {
color: var(--env-var-color-2) !important;
}
.edit-team-form__wrapper td {
padding: 10px 0;
padding-top: 20px;
vertical-align: text-top;
}
.edit-team-form__wrapper th {
padding: var(--env-var-spacing-1) 0;
}
.edit-team-form__wrapper th:first-of-type {
padding-left: 20px;
}
.edit-team-form__wrapper td {
color: var(--env-var-color-25);
}
#select-actions,
#select-role {
padding: 5px 0;
padding-left: 15px;
padding-right: 50px;
line-height: 1.75;
}
.MuiInputBase-root:has(#select-actions) fieldset,
.MuiInputBase-root:has(#select-role) fieldset {
border-color: #a1a7b1;
margin: -1px;
border-width: 1px;
}
.MuiInputBase-root:has(#select-actions):hover fieldset,
.MuiInputBase-root:has(#select-role):hover fieldset {
border-color: var(--env-var-color-2);
}
.MuiStack-root:has(.MuiBox-root > .members-query) .MuiBox-root {
cursor: pointer;
}
.members-query {
display: inline-flex;
justify-content: center;
align-items: center;
margin-left: 6px;
padding: 2px;
font-size: 12px;
font-weight: 500;
color: var(--env-var-color-3);
background-color: #e0e9fd;
min-width: 22px;
min-height: 22px;
border-radius: 50%;
}
/* for testing, will remove later */
@media only screen and (max-width: 1600px) {
.settings {
max-width: calc(90vw - 250px) !important;
}
.edit-profile-form__wrapper .MuiStack-root:not(.row-stack),
.edit-password-form__wrapper .MuiStack-root:not(.row-stack),
.edit-organization-form__wrapper .MuiStack-root:not(.row-stack) {
margin-right: 30px;
}
}
.settings .MuiStack-root:has(p.MuiTypography-root.input-error){
position: relative;
margin-bottom: 8px;
}
.settings p.MuiTypography-root.input-error{
color: var(--env-var-color-24);
opacity: 0.8;
position: absolute;
top: calc(100% + 5px);
}
.settings .email-text-field,
.settings .password-text-field {
margin: 0;
}
.edit-profile-form__wrapper .MuiFormControl-root,
.edit-password-form__wrapper .MuiFormControl-root{
width: 100%;
}
.edit-profile-form__wrapper .MuiStack-root:has(.MuiFormControl-root),
.edit-password-form__wrapper .MuiStack-root:has(.MuiFormControl-root){
margin: 0;
}
+2 -81
View File
@@ -1,86 +1,7 @@
import PropTypes from "prop-types";
import { useState } from "react";
import { Box, Tab, useTheme } from "@mui/material";
import TabContext from "@mui/lab/TabContext";
import TabList from "@mui/lab/TabList";
import "./index.css";
import ProfilePanel from "../../Components/TabPanels/ProfileSettings/ProfilePanel";
import PasswordPanel from "../../Components/TabPanels/ProfileSettings/PasswordPanel";
import TeamPanel from "../../Components/TabPanels/ProfileSettings/TeamPanel";
/**
* Settings component renders a settings page with tabs for Profile, Password, and Team settings.
*
* @returns {JSX.Element}
*/
const tabList = ["Profile", "Password", "Team"];
import React from "react";
const Settings = () => {
const theme = useTheme();
//(tab) 0 - Profile
//(tab) 1 - Password
//(tab) 2 - Team
const [tab, setTab] = useState("0");
const handleTabChange = (event, newTab) => {
setTab(newTab);
};
return (
<Box
//TODO - breakpoints for responsive design
minWidth={theme.spacing(55)}
width="100vw"
maxWidth="calc(100vw - 800px)"
py={theme.spacing(5)}
px={theme.spacing(10)}
className="settings"
>
<TabContext value={tab}>
<Box
sx={{
borderBottom: 1,
borderColor: theme.palette.section.borderColor,
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
}}
>
<TabList onChange={handleTabChange} aria-label="settings tabs">
{tabList.map((label, index) => (
<Tab
label={label}
key={index}
value={index.toString()}
sx={{
fontSize: "13px",
color: theme.palette.secondary.main,
textTransform: "none",
minWidth: "fit-content",
minHeight: 0,
paddingLeft: "0",
paddingY: "10px",
marginRight: "20px",
"&:focus": {
outline: "none",
},
"& .MuiTouchRipple-root": {
pointerEvents: "none",
display: "none",
},
}}
/>
))}
</TabList>
</Box>
<ProfilePanel />
<PasswordPanel />
<TeamPanel />
</TabContext>
</Box>
);
};
Settings.propTypes = {
// No props are being passed to this component, hence no specific PropTypes are defined.
return <div>Settings</div>;
};
export default Settings;