From 438ec51e17c613fb149b1bd6d80e1e4fc134faef Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Mon, 20 Feb 2023 15:49:52 +0100 Subject: [PATCH] feat: Add maxAliasesPerUser to SettingsForm.tsx --- public/locales/en-US/translation.json | 4 + .../GlobalSettingsRoute/SettingsForm.tsx | 81 ++++++++++++++----- src/server-types.ts | 1 + 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/public/locales/en-US/translation.json b/public/locales/en-US/translation.json index 0f99c43..4807812 100644 --- a/public/locales/en-US/translation.json +++ b/public/locales/en-US/translation.json @@ -395,6 +395,10 @@ "allowAliasDeletion": { "label": "Allow alias deletion", "description": "If enabled, users will be able to delete their aliases." + }, + "maxAliasesPerUser": { + "label": "Maximum aliases per user", + "description": "The maximum number of aliases a user can create. 0 means unlimited. Existing aliases will not be affected." } } }, diff --git a/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx b/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx index 2877bec..6737e73 100644 --- a/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx +++ b/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx @@ -6,6 +6,9 @@ import {MdCheck, MdClear, MdOutlineChangeCircle, MdTextFormat} from "react-icons import {BsImage} from "react-icons/bs" import {AxiosError} from "axios" +import {FaMask} from "react-icons/fa" +import AliasesPercentageAmount from "./AliasPercentageAmount" + import { Checkbox, FormControlLabel, @@ -28,8 +31,6 @@ import {parseFastAPIError} from "~/utils" import {DEFAULT_ADMIN_SETTINGS} from "~/constants/admin-settings" import RandomAliasGenerator from "~/route-widgets/GlobalSettingsRoute/RandomAliasGenerator" -import AliasesPercentageAmount from "./AliasPercentageAmount" - export interface SettingsFormProps { settings: AdminSettings queryKey: readonly string[] @@ -84,7 +85,14 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { allowStatistics: yup .boolean() .label(t("routes.AdminRoute.forms.settings.allowStatistics.label")), - }) + allowAliasDeletion: yup + .boolean() + .label(t("routes.AdminRoute.forms.settings.allowAliasDeletion.label")), + maxAliasesPerUser: yup + .number() + .label(t("routes.AdminRoute.forms.settings.maxAliasesPerUser.label")) + .min(0), + } as Record) const {mutateAsync} = useMutation< UpdateAdminSettingsResponse, @@ -144,7 +152,40 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { - + + + + + ), + }} + /> + + - + - + - + - + - + - + - + - + - + @@ -423,12 +464,12 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { - + @@ -452,12 +493,12 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { - + @@ -481,12 +522,12 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { - + diff --git a/src/server-types.ts b/src/server-types.ts index d2dd5e1..bfe1b79 100644 --- a/src/server-types.ts +++ b/src/server-types.ts @@ -212,6 +212,7 @@ export interface AdminSettings { userEmailEnableOtherRelays: boolean allowStatistics: boolean allowAliasDeletion: boolean + maxAliasesPerUser: number } export interface ServerCronReport {