From 3ef0006c179e12bec82b63410eba17f9f218d27f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 14 May 2021 19:16:08 +0200 Subject: [PATCH] Ready to edit admin roles --- src/ui/accountSettings/GeneralSettings.tsx | 6 ++++-- src/ui/accountSettings/RoleSettingsSection.tsx | 18 ++++++++++++++++++ src/ui/routes/AccountSettingsRoute.tsx | 18 +++++++++++++++--- src/utils/AccountUtils.ts | 4 ++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/ui/accountSettings/RoleSettingsSection.tsx diff --git a/src/ui/accountSettings/GeneralSettings.tsx b/src/ui/accountSettings/GeneralSettings.tsx index d66df0a..1cb8391 100644 --- a/src/ui/accountSettings/GeneralSettings.tsx +++ b/src/ui/accountSettings/GeneralSettings.tsx @@ -11,7 +11,7 @@ import { snackbar, matAlert } from "../widgets/DialogsProvider"; import { SettingsSection } from "./SettingsSection"; export class GeneralSettings extends React.Component< - { admin: AdminAccount }, + { admin: AdminAccount; editable: boolean }, { newName: string; newEmail: string } > { constructor(p: any) { @@ -66,6 +66,7 @@ export class GeneralSettings extends React.Component< value={this.state.newName} onChange={this.changedName} style={{ width: "100%", paddingBottom: "20px" }} + disabled={!this.props.editable} />
); diff --git a/src/utils/AccountUtils.ts b/src/utils/AccountUtils.ts index 3a9abd3..2c3e49e 100644 --- a/src/utils/AccountUtils.ts +++ b/src/utils/AccountUtils.ts @@ -6,6 +6,10 @@ import { AccountHelper } from "../helpers/AccountHelper"; +export function adminID(): number { + return AccountHelper.currentAccount.id; +} + export function canManageAdmins(): boolean { return AccountHelper.currentAccount.roles.includes("manage_admins"); }