From 7a2df877b7e92e27abc2cb03bd2361991e67a5f5 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Thu, 16 Mar 2023 10:47:11 +0100 Subject: [PATCH] feat: Add allow registration field to admin settings --- .../locales/en-US/admin-global-settings.json | 4 +++ src/constants/admin-settings.ts | 1 + .../GlobalSettingsRoute/SettingsForm.tsx | 26 +++++++++++++++++++ src/server-types.ts | 1 + 4 files changed, 32 insertions(+) diff --git a/public/locales/en-US/admin-global-settings.json b/public/locales/en-US/admin-global-settings.json index 155606c..b2668fd 100644 --- a/public/locales/en-US/admin-global-settings.json +++ b/public/locales/en-US/admin-global-settings.json @@ -66,6 +66,10 @@ "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." + }, + "allowRegistrations": { + "label": "Allow registrations", + "description": "If enabled, users will be able to register on your instance. This only affects new account registrations." } } } diff --git a/src/constants/admin-settings.ts b/src/constants/admin-settings.ts index 42c99cf..c98cc7c 100644 --- a/src/constants/admin-settings.ts +++ b/src/constants/admin-settings.ts @@ -14,4 +14,5 @@ export const DEFAULT_ADMIN_SETTINGS: AdminSettings = { allowStatistics: true, allowAliasDeletion: false, maxAliasesPerUser: 0, + allowRegistrations: true, } diff --git a/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx b/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx index 948867a..198e3da 100644 --- a/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx +++ b/src/route-widgets/GlobalSettingsRoute/SettingsForm.tsx @@ -79,6 +79,7 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { allowStatistics: yup.boolean().label(t("fields.allowStatistics.label")), allowAliasDeletion: yup.boolean().label(t("fields.allowAliasDeletion.label")), maxAliasesPerUser: yup.number().label(t("fields.maxAliasesPerUser.label")).min(0), + allowRegistrations: yup.boolean().label(t("fields.allowRegistrations.label")), } as Record) const {mutateAsync} = useMutation< @@ -520,6 +521,31 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) { + + + + } + disabled={formik.isSubmitting} + label={t("fields.allowRegistrations.label")} + /> + + {(formik.touched.allowRegistrations && + formik.errors.allowRegistrations) || + t("fields.allowRegistrations.description")} + + + diff --git a/src/server-types.ts b/src/server-types.ts index 7f6d24e..c835f8f 100644 --- a/src/server-types.ts +++ b/src/server-types.ts @@ -241,6 +241,7 @@ export interface AdminSettings { allowStatistics: boolean allowAliasDeletion: boolean maxAliasesPerUser: number + allowRegistrations: boolean } export interface ServerCronReport {