From b274cd4ad2599187452f3b508c0b7305a213d7e5 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 12 Apr 2024 11:36:30 +0200 Subject: [PATCH] settings frontend bugfix + refactoring --- react/admin-panel/src/AdminDashboard.jsx | 2 +- react/admin-panel/src/elements/form-group.js | 7 + .../admin-panel/src/views/profile/profile.js | 37 +++-- .../src/views/settings/input-check-box.js | 21 +++ .../src/views/settings/input-number.js | 22 +++ .../src/views/settings/input-password.js | 22 +++ .../src/views/settings/input-selection.js | 25 ++++ .../src/views/settings/input-text-values.js | 49 +++++++ .../src/views/settings/input-text.js | 20 +++ .../src/views/{ => settings}/settings.js | 131 ++++-------------- react/shared/util.js | 7 +- 11 files changed, 217 insertions(+), 126 deletions(-) create mode 100644 react/admin-panel/src/elements/form-group.js create mode 100644 react/admin-panel/src/views/settings/input-check-box.js create mode 100644 react/admin-panel/src/views/settings/input-number.js create mode 100644 react/admin-panel/src/views/settings/input-password.js create mode 100644 react/admin-panel/src/views/settings/input-selection.js create mode 100644 react/admin-panel/src/views/settings/input-text-values.js create mode 100644 react/admin-panel/src/views/settings/input-text.js rename react/admin-panel/src/views/{ => settings}/settings.js (75%) diff --git a/react/admin-panel/src/AdminDashboard.jsx b/react/admin-panel/src/AdminDashboard.jsx index c428878..4c7391d 100644 --- a/react/admin-panel/src/AdminDashboard.jsx +++ b/react/admin-panel/src/AdminDashboard.jsx @@ -21,7 +21,7 @@ const LogView = lazy(() => import("./views/log-view")); const AccessControlList = lazy(() => import("./views/access-control-list")); const RouteListView = lazy(() => import("./views/route/route-list")); const RouteEditView = lazy(() => import("./views/route/route-edit")); -const SettingsView = lazy(() => import("./views/settings")); +const SettingsView = lazy(() => import("./views/settings/settings")); const ProfileView = lazy(() => import("./views/profile/profile")); export default function AdminDashboard(props) { diff --git a/react/admin-panel/src/elements/form-group.js b/react/admin-panel/src/elements/form-group.js new file mode 100644 index 0000000..3ab1588 --- /dev/null +++ b/react/admin-panel/src/elements/form-group.js @@ -0,0 +1,7 @@ +import {FormGroup, styled} from "@mui/material"; + +const SpacedFormGroup = styled(FormGroup)((props) => ({ + marginBottom: props.theme.spacing(2) +})); + +export default SpacedFormGroup; \ No newline at end of file diff --git a/react/admin-panel/src/views/profile/profile.js b/react/admin-panel/src/views/profile/profile.js index 70fc5f8..163c373 100644 --- a/react/admin-panel/src/views/profile/profile.js +++ b/react/admin-panel/src/views/profile/profile.js @@ -27,6 +27,7 @@ import MfaTotp from "./mfa-totp"; import MfaFido from "./mfa-fido"; import Dialog from "shared/elements/dialog"; import PasswordStrength from "shared/elements/password-strength"; +import SpacedFormGroup from "../../elements/form-group"; const GpgKeyField = styled(TextField)((props) => ({ "& > div": { @@ -46,10 +47,6 @@ const GpgFingerprintBox = styled(Box)((props) => ({ } })); -const ProfileFormGroup = styled(FormGroup)((props) => ({ - marginBottom: props.theme.spacing(2) -})); - const MFAOptions = styled(Box)((props) => ({ "& > div": { borderColor: props.theme.palette.divider, @@ -231,7 +228,7 @@ export default function ProfileView(props) {
- + {L("account.username")} setProfile({...profile, name: e.target.value })} /> - - + + {L("account.full_name")} setProfile({...profile, fullName: e.target.value })} /> - + setOpenedTab(openedTab === "password" ? "" : "password")} icon={}> - + {L("account.password_old")} setChangePassword({...changePassword, old: e.target.value })} /> - - + + {L("account.password_new")} setChangePassword({...changePassword, new: e.target.value })} /> - - + + {L("account.password_confirm")} setChangePassword({...changePassword, confirm: e.target.value })} /> - + @@ -303,7 +300,7 @@ export default function ProfileView(props) { {profile.gpgKey.fingerprint} - + {L("account.password")} - + : - + {L("account.gpg_key")} - +