From e435fe0ff3895605a97d99b5c2893ed5bbc7d9ef Mon Sep 17 00:00:00 2001 From: semmy Date: Mon, 29 Nov 2021 20:59:31 +0800 Subject: [PATCH] feat: allow user to sign up --- packages/client/src/components/admin-layout/More.tsx | 7 +++++++ .../client/src/components/route-schema-renderer/index.tsx | 4 ++-- packages/client/src/locale/en_US.ts | 1 + packages/client/src/locale/zh_CN.ts | 1 + .../src/collections/system_settings.ts | 4 ++++ packages/plugin-ui-router/src/ui-schema/signin.ts | 1 + 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/admin-layout/More.tsx b/packages/client/src/components/admin-layout/More.tsx index 9629b5762..c1ed0ef2f 100644 --- a/packages/client/src/components/admin-layout/More.tsx +++ b/packages/client/src/components/admin-layout/More.tsx @@ -93,6 +93,13 @@ const schema: ISchema = { { label: '简体中文', value: 'zh-CN' }, ], }, + allowSignUp: { + type: 'string', + title: '{{t("Allow sign up")}}', + 'x-component': 'Checkbox', + 'x-decorator': 'FormItem', + default: true, + }, }, }, }, diff --git a/packages/client/src/components/route-schema-renderer/index.tsx b/packages/client/src/components/route-schema-renderer/index.tsx index c35315eb2..4f42ceb65 100644 --- a/packages/client/src/components/route-schema-renderer/index.tsx +++ b/packages/client/src/components/route-schema-renderer/index.tsx @@ -69,7 +69,7 @@ export function RouteSchemaRenderer({ route }) { }, ); const compile = useCompile(); - const { title } = useSystemSettings(); + const { title, allowSignUp = true } = useSystemSettings(); if (loading) { return ; } @@ -82,7 +82,7 @@ export function RouteSchemaRenderer({ route }) { diff --git a/packages/client/src/locale/en_US.ts b/packages/client/src/locale/en_US.ts index 9ca37ca3f..db064facd 100644 --- a/packages/client/src/locale/en_US.ts +++ b/packages/client/src/locale/en_US.ts @@ -39,6 +39,7 @@ export default { 'Switch role': 'Switch role', 'Super admin': 'Super admin', 'Language': 'Language', + 'Allow sign up': 'Allow sign up', 'Sign out': 'Sign out', 'Cancel': 'Cancel', 'Submit': 'Submit', diff --git a/packages/client/src/locale/zh_CN.ts b/packages/client/src/locale/zh_CN.ts index ea0432662..f54a00384 100644 --- a/packages/client/src/locale/zh_CN.ts +++ b/packages/client/src/locale/zh_CN.ts @@ -40,6 +40,7 @@ export default { 'Switch role': '切换角色', 'Super admin': '超级管理员', 'Language': '语言设置', + 'Allow sign up': '允许注册', 'Sign out': '注销', 'Cancel': '取消', 'Submit': '提交', diff --git a/packages/plugin-system-settings/src/collections/system_settings.ts b/packages/plugin-system-settings/src/collections/system_settings.ts index 82595e19a..b44144eac 100644 --- a/packages/plugin-system-settings/src/collections/system_settings.ts +++ b/packages/plugin-system-settings/src/collections/system_settings.ts @@ -11,6 +11,10 @@ export default { type: 'boolean', name: 'showLogoOnly', }, + { + type: 'boolean', + name: 'allowSignUp', + }, { type: 'belongsTo', name: 'logo', diff --git a/packages/plugin-ui-router/src/ui-schema/signin.ts b/packages/plugin-ui-router/src/ui-schema/signin.ts index 49ad27eb5..e9ab94cb5 100644 --- a/packages/plugin-ui-router/src/ui-schema/signin.ts +++ b/packages/plugin-ui-router/src/ui-schema/signin.ts @@ -49,6 +49,7 @@ export const signin = { registerlink: { type: 'void', 'x-component': 'Div', + 'x-hidden': '{{allowSignUp !== true}}', properties: { link: { type: 'void',