ui: Improve pgp settings page

This commit is contained in:
Myzel394 2023-04-10 13:14:30 +02:00
parent a610f735ee
commit 1765235be2
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
3 changed files with 16 additions and 12 deletions

View File

@ -16,6 +16,6 @@
"description": "We found a public key for your email! Would you like to use it? The key has been created on {{createdAt}} and is of type {{type}}. This is the fingerprint:", "description": "We found a public key for your email! Would you like to use it? The key has been created on {{createdAt}} and is of type {{type}}. This is the fingerprint:",
"continueActionLabel": "Use Key" "continueActionLabel": "Use Key"
}, },
"alreadyConfigured": "PGP encryption is activated. You are using a public key with this fingerprint:", "alreadyConfigured": "PGP encryption is activated. You are using a public key with this fingerprint: ",
"remove": "Disable PGP encryption" "remove": "Disable PGP encryption"
} }

View File

@ -1,15 +1,18 @@
import {Alert, CircularProgress, Grid} from "@mui/material"
import {ReactElement, useContext} from "react"
import {useTranslation} from "react-i18next"
import {LoadingButton} from "@mui/lab"
import {SimpleDetailResponse, User} from "~/server-types"
import {UpdatePreferencesData, updatePreferences} from "~/apis"
import {useMutation} from "@tanstack/react-query"
import {AxiosError} from "axios" import {AxiosError} from "axios"
import {useErrorSuccessSnacks} from "~/hooks"
import {AuthContext} from "~/components"
import {useAsync} from "react-use" import {useAsync} from "react-use"
import {readKey} from "openpgp" import {readKey} from "openpgp"
import {FaLockOpen} from "react-icons/fa"
import {ReactElement, useContext} from "react"
import {useTranslation} from "react-i18next"
import {Alert, CircularProgress, Grid} from "@mui/material"
import {LoadingButton} from "@mui/lab"
import {useMutation} from "@tanstack/react-query"
import {SimpleDetailResponse, User} from "~/server-types"
import {UpdatePreferencesData, updatePreferences} from "~/apis"
import {useErrorSuccessSnacks} from "~/hooks"
import {AuthContext} from "~/components"
export default function AlreadyConfigured(): ReactElement { export default function AlreadyConfigured(): ReactElement {
const {t} = useTranslation(["settings-email-pgp", "common"]) const {t} = useTranslation(["settings-email-pgp", "common"])
@ -51,13 +54,14 @@ export default function AlreadyConfigured(): ReactElement {
<Grid item> <Grid item>
<Alert severity="success" variant="standard"> <Alert severity="success" variant="standard">
{t("alreadyConfigured")} {t("alreadyConfigured")}
{isLoadingFingerprint ? <CircularProgress /> : <code>{fingerprint}</code>}
</Alert> </Alert>
{isLoadingFingerprint ? <CircularProgress /> : <code>{fingerprint}</code>}
</Grid> </Grid>
<Grid item> <Grid item>
<LoadingButton <LoadingButton
variant="contained" variant="contained"
loading={isLoading} loading={isLoading}
startIcon={<FaLockOpen />}
onClick={() => onClick={() =>
mutateAsync({ mutateAsync({
emailGpgPublicKey: null, emailGpgPublicKey: null,

View File

@ -96,7 +96,7 @@ export default function SetupPGPEncryptionForm(): ReactElement {
fullWidth fullWidth
multiline multiline
minRows={5} minRows={5}
maxRows={20} maxRows={15}
label={t("form.fields.publicKey.label")} label={t("form.fields.publicKey.label")}
name="publicKey" name="publicKey"
value={formik.values.publicKey} value={formik.values.publicKey}