Merge pull request #1433 from bluewave-labs/fix/fe/refactor-config-box
fix: fe/refactor config box
This commit is contained in:
11 files changed
+117
-206
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { Stack, styled } from "@mui/material";
|
import { Stack, styled } from "@mui/material";
|
||||||
|
|
||||||
export const ConfigBox = styled(Stack)(({ theme }) => ({
|
const ConfigBox = styled(Stack)(({ theme }) => ({
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
@@ -34,3 +34,5 @@ export const ConfigBox = styled(Stack)(({ theme }) => ({
|
|||||||
color: theme.palette.text.tertiary,
|
color: theme.palette.text.tertiary,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export default ConfigBox;
|
||||||
@@ -40,6 +40,7 @@ const SearchAdornment = () => {
|
|||||||
|
|
||||||
//TODO keep search state inside of component
|
//TODO keep search state inside of component
|
||||||
const Search = ({
|
const Search = ({
|
||||||
|
label,
|
||||||
id,
|
id,
|
||||||
options,
|
options,
|
||||||
filteredBy,
|
filteredBy,
|
||||||
@@ -76,6 +77,14 @@ const Search = ({
|
|||||||
getOptionLabel={(option) => option[filteredBy]}
|
getOptionLabel={(option) => option[filteredBy]}
|
||||||
renderInput={(params) => (
|
renderInput={(params) => (
|
||||||
<Stack>
|
<Stack>
|
||||||
|
<Typography
|
||||||
|
component="h3"
|
||||||
|
fontSize={"var(--env-var-font-size-medium)"}
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
fontWeight={500}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</Typography>
|
||||||
<TextField
|
<TextField
|
||||||
{...params}
|
{...params}
|
||||||
error={Boolean(error)}
|
error={Boolean(error)}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import LoadingButton from "@mui/lab/LoadingButton";
|
|||||||
//Components
|
//Components
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import Link from "../../../Components/Link";
|
import Link from "../../../Components/Link";
|
||||||
import { ConfigBox } from "../../Uptime/styled";
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
import TextInput from "../../../Components/Inputs/TextInput";
|
import TextInput from "../../../Components/Inputs/TextInput";
|
||||||
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Box, Button, Stack, Typography } from "@mui/material";
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ConfigBox } from "./styled";
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||||
import { LocalizationProvider } from "@mui/x-date-pickers";
|
import { LocalizationProvider } from "@mui/x-date-pickers";
|
||||||
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
||||||
@@ -321,18 +321,27 @@ const CreateMaintenance = () => {
|
|||||||
Your pings won't be sent during this time frame
|
Your pings won't be sent during this time frame
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<ConfigBox direction="row">
|
<ConfigBox>
|
||||||
<Typography
|
<Box>
|
||||||
component="h2"
|
<Typography
|
||||||
variant="h2"
|
component="h2"
|
||||||
>
|
variant="h2"
|
||||||
General Settings
|
>
|
||||||
</Typography>
|
General Settings
|
||||||
<Box
|
</Typography>
|
||||||
px={theme.spacing(14)}
|
</Box>
|
||||||
borderLeft={1}
|
<Stack gap={theme.spacing(15)}>
|
||||||
borderLeftColor={theme.palette.border.light}
|
<TextInput
|
||||||
>
|
id="name"
|
||||||
|
label="Friendly name"
|
||||||
|
placeholder="Maintenance at __ : __ for ___ minutes"
|
||||||
|
value={form.name}
|
||||||
|
onChange={(event) => {
|
||||||
|
handleFormChange("name", event.target.value);
|
||||||
|
}}
|
||||||
|
error={errors["name"] ? true : false}
|
||||||
|
helperText={errors["name"]}
|
||||||
|
/>
|
||||||
<Select
|
<Select
|
||||||
id="repeat"
|
id="repeat"
|
||||||
name="maintenance-repeat"
|
name="maintenance-repeat"
|
||||||
@@ -346,15 +355,12 @@ const CreateMaintenance = () => {
|
|||||||
}}
|
}}
|
||||||
items={repeatConfig}
|
items={repeatConfig}
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack>
|
||||||
gap={theme.spacing(2)}
|
|
||||||
mt={theme.spacing(16)}
|
|
||||||
>
|
|
||||||
<Typography component="h3">Date</Typography>
|
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
id="startDate"
|
id="startDate"
|
||||||
disablePast
|
disablePast
|
||||||
|
label="Date"
|
||||||
disableHighlightToday
|
disableHighlightToday
|
||||||
value={form.startDate}
|
value={form.startDate}
|
||||||
slots={{ openPickerIcon: CalendarIcon }}
|
slots={{ openPickerIcon: CalendarIcon }}
|
||||||
@@ -403,72 +409,64 @@ const CreateMaintenance = () => {
|
|||||||
/>
|
/>
|
||||||
</LocalizationProvider>
|
</LocalizationProvider>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Stack direction="row">
|
<Box>
|
||||||
<Box>
|
<Typography
|
||||||
<Typography
|
component="h2"
|
||||||
component="h2"
|
variant="h2"
|
||||||
variant="h2"
|
>
|
||||||
>
|
Start time
|
||||||
Start time
|
</Typography>
|
||||||
</Typography>
|
<Typography>All dates and times are in GMT+0 time zone.</Typography>
|
||||||
<Typography>All dates and times are in GMT+0 time zone.</Typography>
|
</Box>
|
||||||
</Box>
|
<Stack gap={theme.spacing(15)}>
|
||||||
<Stack direction="row">
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<MobileTimePicker
|
||||||
<MobileTimePicker
|
id="startTime"
|
||||||
id="startTime"
|
label="Start time"
|
||||||
value={form.startTime}
|
value={form.startTime}
|
||||||
onChange={(newTime) => {
|
onChange={(newTime) => {
|
||||||
handleTimeChange("startTime", newTime);
|
handleTimeChange("startTime", newTime);
|
||||||
}}
|
}}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
nextIconButton: { sx: { ml: theme.spacing(2) } },
|
nextIconButton: { sx: { ml: theme.spacing(2) } },
|
||||||
field: {
|
field: {
|
||||||
sx: {
|
sx: {
|
||||||
width: "fit-content",
|
width: "fit-content",
|
||||||
"& > .MuiOutlinedInput-root": {
|
"& > .MuiOutlinedInput-root": {
|
||||||
flexDirection: "row-reverse",
|
flexDirection: "row-reverse",
|
||||||
},
|
|
||||||
"& input": {
|
|
||||||
height: 34,
|
|
||||||
p: 0,
|
|
||||||
pl: theme.spacing(5),
|
|
||||||
},
|
|
||||||
"& fieldset": {
|
|
||||||
borderColor: theme.palette.border.dark,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
},
|
|
||||||
"&:not(:has(.Mui-disabled)):not(:has(.Mui-error)) .MuiOutlinedInput-root:not(:has(input:focus)):hover fieldset":
|
|
||||||
{
|
|
||||||
borderColor: theme.palette.border.dark,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
"& input": {
|
||||||
|
height: 34,
|
||||||
|
p: 0,
|
||||||
|
pl: theme.spacing(5),
|
||||||
|
},
|
||||||
|
"& fieldset": {
|
||||||
|
borderColor: theme.palette.border.dark,
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
},
|
||||||
|
"&:not(:has(.Mui-disabled)):not(:has(.Mui-error)) .MuiOutlinedInput-root:not(:has(input:focus)):hover fieldset":
|
||||||
|
{
|
||||||
|
borderColor: theme.palette.border.dark,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}}
|
},
|
||||||
error={errors["startTime"]}
|
}}
|
||||||
/>
|
error={errors["startTime"]}
|
||||||
</LocalizationProvider>
|
/>
|
||||||
</Stack>
|
</LocalizationProvider>
|
||||||
</Stack>
|
|
||||||
<Stack direction="row">
|
|
||||||
<Box>
|
|
||||||
<Typography
|
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
>
|
|
||||||
Duration
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
|
alignItems="end"
|
||||||
spacing={theme.spacing(8)}
|
spacing={theme.spacing(8)}
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="number"
|
type="number"
|
||||||
id="duration"
|
id="duration"
|
||||||
|
label="Duration"
|
||||||
value={form.duration}
|
value={form.duration}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
handleFormChange("duration", event.target.value);
|
handleFormChange("duration", event.target.value);
|
||||||
@@ -491,66 +489,34 @@ const CreateMaintenance = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
<Box>
|
|
||||||
<Typography
|
<ConfigBox>
|
||||||
component="h2"
|
<Box>
|
||||||
variant="h2"
|
<Typography
|
||||||
fontSize={16}
|
component="h2"
|
||||||
my={theme.spacing(6)}
|
variant="h2"
|
||||||
>
|
>
|
||||||
Monitor related settings
|
Monitors to apply maintenance window to
|
||||||
</Typography>
|
</Typography>
|
||||||
<ConfigBox>
|
</Box>
|
||||||
<Stack direction="row">
|
<Stack gap={theme.spacing(15)}>
|
||||||
<Box>
|
<Search
|
||||||
<Typography
|
id={"monitors"}
|
||||||
component="h2"
|
label="Add monitors"
|
||||||
variant="h2"
|
multiple={true}
|
||||||
>
|
isAdorned={false}
|
||||||
Friendly name
|
options={monitors ? monitors : []}
|
||||||
</Typography>
|
filteredBy="name"
|
||||||
</Box>
|
secondaryLabel={"type"}
|
||||||
<Box>
|
inputValue={search}
|
||||||
<TextInput
|
value={form.monitors}
|
||||||
id="name"
|
handleInputChange={handleSearch}
|
||||||
placeholder="Maintenance at __ : __ for ___ minutes"
|
handleChange={handleSelectMonitors}
|
||||||
value={form.name}
|
error={errors["monitors"]}
|
||||||
onChange={(event) => {
|
disabled={maintenanceWindowId !== undefined}
|
||||||
handleFormChange("name", event.target.value);
|
/>
|
||||||
}}
|
</Stack>
|
||||||
error={errors["name"] ? true : false}
|
</ConfigBox>
|
||||||
helperText={errors["name"]}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
<Stack direction="row">
|
|
||||||
<Box>
|
|
||||||
<Typography
|
|
||||||
component="h2"
|
|
||||||
variant="h2"
|
|
||||||
>
|
|
||||||
Add monitors
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<Search
|
|
||||||
id={"monitors"}
|
|
||||||
multiple={true}
|
|
||||||
isAdorned={false}
|
|
||||||
options={monitors ? monitors : []}
|
|
||||||
filteredBy="name"
|
|
||||||
secondaryLabel={"type"}
|
|
||||||
inputValue={search}
|
|
||||||
value={form.monitors}
|
|
||||||
handleInputChange={handleSearch}
|
|
||||||
handleChange={handleSelectMonitors}
|
|
||||||
error={errors["monitors"]}
|
|
||||||
disabled={maintenanceWindowId !== undefined}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
</ConfigBox>
|
|
||||||
</Box>
|
|
||||||
<Box
|
<Box
|
||||||
ml="auto"
|
ml="auto"
|
||||||
display="inline-block"
|
display="inline-block"
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
import { Stack, styled } from "@mui/material";
|
|
||||||
|
|
||||||
export const ConfigBox = styled(Stack)(({ theme }) => ({
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.spacing(2),
|
|
||||||
backgroundColor: theme.palette.background.main,
|
|
||||||
"& > *": { padding: theme.spacing(14) },
|
|
||||||
"& > :first-of-type, & > .MuiStack-root > div:first-of-type": {
|
|
||||||
flex: 0.6,
|
|
||||||
},
|
|
||||||
"& > div:last-of-type, & > .MuiStack-root > div:last-of-type": {
|
|
||||||
flex: 1,
|
|
||||||
},
|
|
||||||
"& > .MuiStack-root > div:first-of-type": { paddingRight: theme.spacing(14) },
|
|
||||||
"& > .MuiStack-root > div:last-of-type": {
|
|
||||||
paddingLeft: theme.spacing(14),
|
|
||||||
},
|
|
||||||
"& h2": { fontSize: 13.5, fontWeight: 500 },
|
|
||||||
"& h3, & p": {
|
|
||||||
color: theme.palette.text.tertiary,
|
|
||||||
},
|
|
||||||
"& h3": { fontWeight: 500 },
|
|
||||||
}));
|
|
||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { ConfigBox } from "../../Uptime/styled";
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
import TextInput from "../../../Components/Inputs/TextInput";
|
import TextInput from "../../../Components/Inputs/TextInput";
|
||||||
import Select from "../../../Components/Inputs/Select";
|
import Select from "../../../Components/Inputs/Select";
|
||||||
import Checkbox from "../../../Components/Inputs/Checkbox";
|
import Checkbox from "../../../Components/Inputs/Checkbox";
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ import LoadingButton from "@mui/lab/LoadingButton";
|
|||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import TextInput from "../../../Components/Inputs/TextInput";
|
import TextInput from "../../../Components/Inputs/TextInput";
|
||||||
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
||||||
import { ConfigBox } from "../../Uptime/styled";
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
|
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import Radio from "../../../Components/Inputs/Radio";
|
import Radio from "../../../Components/Inputs/Radio";
|
||||||
import Checkbox from "../../../Components/Inputs/Checkbox";
|
import Checkbox from "../../../Components/Inputs/Checkbox";
|
||||||
|
|||||||
@@ -18,13 +18,12 @@ import LoadingButton from "@mui/lab/LoadingButton";
|
|||||||
import { setTimezone, setMode } from "../../Features/UI/uiSlice";
|
import { setTimezone, setMode } from "../../Features/UI/uiSlice";
|
||||||
import timezones from "../../Utils/timezones.json";
|
import timezones from "../../Utils/timezones.json";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { ConfigBox } from "./styled";
|
|
||||||
import { networkService } from "../../main";
|
import { networkService } from "../../main";
|
||||||
import { settingsValidation } from "../../Validation/validation";
|
import { settingsValidation } from "../../Validation/validation";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import Dialog from "../../Components/Dialog";
|
import Dialog from "../../Components/Dialog";
|
||||||
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
||||||
|
import ConfigBox from "../../Components/ConfigBox";
|
||||||
const SECONDS_PER_DAY = 86400;
|
const SECONDS_PER_DAY = 86400;
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
|||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { logger } from "../../../Utils/Logger";
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { ConfigBox } from "../styled";
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
import {
|
import {
|
||||||
updateUptimeMonitor,
|
updateUptimeMonitor,
|
||||||
pauseUptimeMonitor,
|
pauseUptimeMonitor,
|
||||||
|
|||||||
@@ -17,14 +17,13 @@ import LoadingButton from "@mui/lab/LoadingButton";
|
|||||||
|
|
||||||
//Components
|
//Components
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import { ConfigBox } from "../styled";
|
|
||||||
import TextInput from "../../../Components/Inputs/TextInput";
|
import TextInput from "../../../Components/Inputs/TextInput";
|
||||||
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import Radio from "../../../Components/Inputs/Radio";
|
import Radio from "../../../Components/Inputs/Radio";
|
||||||
import Checkbox from "../../../Components/Inputs/Checkbox";
|
import Checkbox from "../../../Components/Inputs/Checkbox";
|
||||||
import Select from "../../../Components/Inputs/Select";
|
import Select from "../../../Components/Inputs/Select";
|
||||||
|
import ConfigBox from "../../../Components/ConfigBox";
|
||||||
const CreateMonitor = () => {
|
const CreateMonitor = () => {
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
const SELECT_VALUES = [
|
const SELECT_VALUES = [
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { Stack, styled } from "@mui/material";
|
|
||||||
|
|
||||||
export const ConfigBox = styled(Stack)(({ theme }) => ({
|
|
||||||
flexDirection: "row",
|
|
||||||
border: 1,
|
|
||||||
borderStyle: "solid",
|
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
borderRadius: theme.spacing(2),
|
|
||||||
backgroundColor: theme.palette.background.main,
|
|
||||||
"& > *": {
|
|
||||||
paddingTop: theme.spacing(12),
|
|
||||||
paddingBottom: theme.spacing(18),
|
|
||||||
},
|
|
||||||
"& > div:first-of-type": {
|
|
||||||
flex: 0.7,
|
|
||||||
borderRight: 1,
|
|
||||||
borderRightStyle: "solid",
|
|
||||||
borderRightColor: theme.palette.border.light,
|
|
||||||
paddingRight: theme.spacing(15),
|
|
||||||
paddingLeft: theme.spacing(15),
|
|
||||||
},
|
|
||||||
"& > div:last-of-type": {
|
|
||||||
flex: 1,
|
|
||||||
paddingRight: theme.spacing(20),
|
|
||||||
paddingLeft: theme.spacing(18),
|
|
||||||
},
|
|
||||||
"& h2": {
|
|
||||||
color: theme.palette.text.secondary,
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: 600,
|
|
||||||
},
|
|
||||||
"& h3, & p": {
|
|
||||||
color: theme.palette.text.tertiary,
|
|
||||||
},
|
|
||||||
"& p": {
|
|
||||||
fontSize: 13,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
Reference in new issue
Block a user