fixed AliasesPreferencesForm.tsx

This commit is contained in:
Myzel394 2022-10-20 22:11:21 +02:00
parent 53589b9419
commit 6f979669b5
3 changed files with 162 additions and 116 deletions

View File

@ -1,6 +1,7 @@
import {ReactElement} from "react" import {ReactElement} from "react"
import {BiStats} from "react-icons/bi" import {BiStats} from "react-icons/bi"
import {MdMail, MdSettings} from "react-icons/md" import {MdSettings} from "react-icons/md"
import {FaMask} from "react-icons/fa"
import {Link as RouterLink, useLocation} from "react-router-dom" import {Link as RouterLink, useLocation} from "react-router-dom"
import {Button} from "@mui/material" import {Button} from "@mui/material"
@ -20,7 +21,7 @@ export interface NavigationButtonProps {
const SECTION_ICON_MAP: Record<NavigationSection, ReactElement> = { const SECTION_ICON_MAP: Record<NavigationSection, ReactElement> = {
[NavigationSection.Overview]: <BiStats />, [NavigationSection.Overview]: <BiStats />,
[NavigationSection.Aliases]: <MdMail />, [NavigationSection.Aliases]: <FaMask />,
[NavigationSection.Reports]: <Icon path={mdiTextBoxMultiple} size={0.8} />, [NavigationSection.Reports]: <Icon path={mdiTextBoxMultiple} size={0.8} />,
[NavigationSection.Settings]: <MdSettings />, [NavigationSection.Settings]: <MdSettings />,
} }

View File

@ -7,6 +7,7 @@ import React, {ReactElement, useContext} from "react"
import {useMutation} from "@tanstack/react-query" import {useMutation} from "@tanstack/react-query"
import { import {
Checkbox, Checkbox,
Collapse,
FormControlLabel, FormControlLabel,
FormGroup, FormGroup,
FormHelperText, FormHelperText,
@ -15,6 +16,8 @@ import {
MenuItem, MenuItem,
TextField, TextField,
Typography, Typography,
useMediaQuery,
useTheme,
} from "@mui/material" } from "@mui/material"
import {LoadingButton} from "@mui/lab" import {LoadingButton} from "@mui/lab"
@ -113,6 +116,8 @@ export default function AliasesPreferencesForm(): ReactElement {
} }
}, },
}) })
const theme = useTheme()
const isLarge = useMediaQuery(theme.breakpoints.up("md"))
return ( return (
<> <>
@ -133,12 +138,12 @@ export default function AliasesPreferencesForm(): ReactElement {
<form onSubmit={formik.handleSubmit}> <form onSubmit={formik.handleSubmit}>
<Grid <Grid
display="flex" display="flex"
flexDirection="column" flexDirection="row"
container container
spacing={4} spacing={4}
alignItems="flex-end" alignItems="flex-end"
> >
<Grid item> <Grid item md={6}>
<FormGroup> <FormGroup>
<FormControlLabel <FormControlLabel
disabled={formik.isSubmitting} disabled={formik.isSubmitting}
@ -168,7 +173,7 @@ export default function AliasesPreferencesForm(): ReactElement {
</FormHelperText> </FormHelperText>
</FormGroup> </FormGroup>
</Grid> </Grid>
<Grid item> <Grid item md={6}>
<FormGroup> <FormGroup>
<FormControlLabel <FormControlLabel
disabled={formik.isSubmitting} disabled={formik.isSubmitting}
@ -199,7 +204,7 @@ export default function AliasesPreferencesForm(): ReactElement {
</FormHelperText> </FormHelperText>
</FormGroup> </FormGroup>
</Grid> </Grid>
<Grid item> <Grid item xs={12}>
<FormGroup> <FormGroup>
<FormControlLabel <FormControlLabel
disabled={formik.isSubmitting} disabled={formik.isSubmitting}
@ -228,8 +233,20 @@ export default function AliasesPreferencesForm(): ReactElement {
"Proxies images in your emails through this KleckRelay instance. This adds an extra layer of privacy. Images are loaded immediately after we receive the email. They then will be stored for some time (cache time). During that time, the image will be served from us. This means the original server has no idea you have opened the mail. After the cache time, the image is loaded from the original server, but it gets proxied by us. This means the original server will not be able to access neither your IP address nor your user agent."} "Proxies images in your emails through this KleckRelay instance. This adds an extra layer of privacy. Images are loaded immediately after we receive the email. They then will be stored for some time (cache time). During that time, the image will be served from us. This means the original server has no idea you have opened the mail. After the cache time, the image is loaded from the original server, but it gets proxied by us. This means the original server will not be able to access neither your IP address nor your user agent."}
</FormHelperText> </FormHelperText>
</FormGroup> </FormGroup>
</Grid> <Collapse in={formik.values.proxyImages}>
<Grid item> <Grid
display="flex"
flexDirection={
isLarge ? "row" : "column"
}
container
marginY={2}
spacing={4}
alignItems={
isLarge ? "flex-start" : "flex-end"
}
>
<Grid item md={6}>
<FormGroup> <FormGroup>
<TextField <TextField
fullWidth fullWidth
@ -244,24 +261,38 @@ export default function AliasesPreferencesForm(): ReactElement {
name="imageProxyFormat" name="imageProxyFormat"
id="imageProxyFormat" id="imageProxyFormat"
label="Image File Type" label="Image File Type"
value={formik.values.imageProxyFormat} value={
onChange={formik.handleChange} formik.values
disabled={formik.isSubmitting} .imageProxyFormat
}
onChange={
formik.handleChange
}
disabled={
formik.isSubmitting
}
error={ error={
formik.touched.imageProxyFormat && formik.touched
.imageProxyFormat &&
Boolean( Boolean(
formik.errors.imageProxyFormat, formik.errors
.imageProxyFormat,
) )
} }
helperText={ helperText={
formik.touched.imageProxyFormat && formik.touched
formik.errors.imageProxyFormat .imageProxyFormat &&
formik.errors
.imageProxyFormat
} }
> >
{Object.entries( {Object.entries(
ImageProxyFormatType, ImageProxyFormatType,
).map(([key, value]) => ( ).map(([key, value]) => (
<MenuItem key={key} value={value}> <MenuItem
key={key}
value={value}
>
{ {
IMAGE_PROXY_FORMAT_TYPE_NAME_MAP[ IMAGE_PROXY_FORMAT_TYPE_NAME_MAP[
value value
@ -272,16 +303,20 @@ export default function AliasesPreferencesForm(): ReactElement {
</TextField> </TextField>
<FormHelperText <FormHelperText
error={Boolean( error={Boolean(
formik.touched.imageProxyFormat && formik.touched
formik.errors.imageProxyFormat, .imageProxyFormat &&
formik.errors
.imageProxyFormat,
)} )}
> >
{formik.touched.imageProxyFormat && {formik.touched
formik.errors.imageProxyFormat} .imageProxyFormat &&
formik.errors
.imageProxyFormat}
</FormHelperText> </FormHelperText>
</FormGroup> </FormGroup>
</Grid> </Grid>
<Grid item> <Grid item md={6}>
<FormGroup> <FormGroup>
<TextField <TextField
fullWidth fullWidth
@ -290,10 +325,15 @@ export default function AliasesPreferencesForm(): ReactElement {
id="imageProxyUserAgent" id="imageProxyUserAgent"
label="Image Proxy User Agent" label="Image Proxy User Agent"
value={ value={
formik.values.imageProxyUserAgent formik.values
.imageProxyUserAgent
}
onChange={
formik.handleChange
}
disabled={
formik.isSubmitting
} }
onChange={formik.handleChange}
disabled={formik.isSubmitting}
error={ error={
formik.touched formik.touched
.imageProxyUserAgent && .imageProxyUserAgent &&
@ -305,11 +345,13 @@ export default function AliasesPreferencesForm(): ReactElement {
helperText={ helperText={
formik.touched formik.touched
.imageProxyUserAgent && .imageProxyUserAgent &&
formik.errors.imageProxyUserAgent formik.errors
.imageProxyUserAgent
} }
> >
{Object.entries(ProxyUserAgentType).map( {Object.entries(
([key, value]) => ( ProxyUserAgentType,
).map(([key, value]) => (
<MenuItem <MenuItem
key={key} key={key}
value={value} value={value}
@ -320,8 +362,7 @@ export default function AliasesPreferencesForm(): ReactElement {
] as string ] as string
} }
</MenuItem> </MenuItem>
), ))}
)}
</TextField> </TextField>
<FormHelperText <FormHelperText
error={Boolean( error={Boolean(
@ -331,13 +372,17 @@ export default function AliasesPreferencesForm(): ReactElement {
.imageProxyUserAgent, .imageProxyUserAgent,
)} )}
> >
{(formik.touched.imageProxyUserAgent && {(formik.touched
.imageProxyUserAgent &&
formik.errors formik.errors
.imageProxyUserAgent) || .imageProxyUserAgent) ||
"An User Agent is a identifier each browser and email client sends when retrieving files, such as images. You can specify here what user agent you would like to be used by the proxy. User Agents are kept up-to-date."} "An User Agent is a identifier each browser and email client sends when retrieving files, such as images. You can specify here what user agent you would like to be used by the proxy. User Agents are kept up-to-date."}
</FormHelperText> </FormHelperText>
</FormGroup> </FormGroup>
</Grid> </Grid>
</Grid>
</Collapse>
</Grid>
<Grid item> <Grid item>
<LoadingButton <LoadingButton
loading={formik.isSubmitting} loading={formik.isSubmitting}

View File

@ -42,10 +42,10 @@ export default function AuthenticatedRoute(): ReactElement {
> >
<Grid <Grid
container container
justifyContent="center" justifyContent="space-between"
alignItems="flex-start" alignItems="center"
> >
<Grid item xs={12} sm={4}> <Grid item xs={12} sm={4} lg={2}>
<Box <Box
bgcolor={theme.palette.background.paper} bgcolor={theme.palette.background.paper}
component="nav" component="nav"
@ -61,11 +61,11 @@ export default function AuthenticatedRoute(): ReactElement {
</List> </List>
</Box> </Box>
</Grid> </Grid>
<Grid item xs={12} sm={8}> <Grid item xs={12} sm={8} lg={10}>
<Paper> <Paper>
<Box <Box
padding={4} padding={4}
maxHeight="80vh" maxHeight="60vh"
overflow="scroll" overflow="scroll"
> >
<Outlet /> <Outlet />