From f508f6bcf111b28572aa29bbe5143c432758e14b Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 29 Oct 2023 18:26:54 +0800 Subject: [PATCH] fix: improve code --- .../plugin-auth/src/client/basic/Options.tsx | 2 +- .../client/settings/schemas/authenticators.ts | 10 +++++-- .../plugin-cas/src/client/Options.tsx | 2 +- packages/presets/nocobase/src/server/index.ts | 2 +- .../20231029104932-set-charts-local.ts | 27 +++++++++++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 packages/presets/nocobase/src/server/migrations/20231029104932-set-charts-local.ts diff --git a/packages/plugins/@nocobase/plugin-auth/src/client/basic/Options.tsx b/packages/plugins/@nocobase/plugin-auth/src/client/basic/Options.tsx index 6392104b21..72adfa48f8 100644 --- a/packages/plugins/@nocobase/plugin-auth/src/client/basic/Options.tsx +++ b/packages/plugins/@nocobase/plugin-auth/src/client/basic/Options.tsx @@ -18,7 +18,7 @@ export const Options = () => { allowSignup: { 'x-decorator': 'FormItem', type: 'boolean', - title: '{{t("Allow to sign up")}}', + 'x-content': '{{t("Allow to sign up")}}', 'x-component': 'Checkbox', 'x-component-props': { defaultChecked: true, diff --git a/packages/plugins/@nocobase/plugin-auth/src/client/settings/schemas/authenticators.ts b/packages/plugins/@nocobase/plugin-auth/src/client/settings/schemas/authenticators.ts index 4554c8080b..2c9892402e 100644 --- a/packages/plugins/@nocobase/plugin-auth/src/client/settings/schemas/authenticators.ts +++ b/packages/plugins/@nocobase/plugin-auth/src/client/settings/schemas/authenticators.ts @@ -38,8 +38,9 @@ const collection = { name: 'authType', uiSchema: { type: 'string', - title: '{{t("Auth Type")}}', + title: '{{t("Auth type")}}', 'x-component': 'Select', + 'x-disabled': true, dataSource: '{{ types }}', required: true, }, @@ -69,7 +70,7 @@ const collection = { name: 'enabled', uiSchema: { type: 'boolean', - title: '{{t("Enabled")}}', + 'x-content': '{{t("Enabled the auth type")}}', 'x-component': 'Checkbox', }, }, @@ -108,6 +109,7 @@ export const createFormSchema: ISchema = { authType: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', + 'x-disabled': true, 'x-component-props': { options: '{{ types }}', }, @@ -123,6 +125,9 @@ export const createFormSchema: ISchema = { enabled: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', + 'x-decorator-props': { + marginBottom: 0, + }, }, options: { type: 'object', @@ -299,6 +304,7 @@ export const authenticatorsSchema: ISchema = { type: 'void', 'x-decorator': 'Table.Column.Decorator', 'x-component': 'Table.Column', + title: '{{t("Enabled")}}', properties: { enabled: { type: 'boolean', diff --git a/packages/plugins/@nocobase/plugin-cas/src/client/Options.tsx b/packages/plugins/@nocobase/plugin-cas/src/client/Options.tsx index 5baf24705f..107e83450f 100644 --- a/packages/plugins/@nocobase/plugin-cas/src/client/Options.tsx +++ b/packages/plugins/@nocobase/plugin-cas/src/client/Options.tsx @@ -15,7 +15,7 @@ export const Options = () => { autoSignup: { 'x-decorator': 'FormItem', type: 'boolean', - title: '{{t("Sign up automatically when the user does not exist")}}', + 'x-content': '{{t("Sign up automatically when the user does not exist")}}', 'x-component': 'Checkbox', }, casUrl: { diff --git a/packages/presets/nocobase/src/server/index.ts b/packages/presets/nocobase/src/server/index.ts index 05e31bdf6d..bab07615a0 100644 --- a/packages/presets/nocobase/src/server/index.ts +++ b/packages/presets/nocobase/src/server/index.ts @@ -23,7 +23,6 @@ export class PresetNocoBase extends Plugin { 'duplicator', 'iframe-block', 'formula-field', - 'charts', 'data-visualization', 'auth', 'sms-auth', @@ -31,6 +30,7 @@ export class PresetNocoBase extends Plugin { ]; localPlugins = [ + ['charts', '0.9.1-alpha.2'], ['audit-logs', '0.7.1-alpha.4'], ['sample-hello', '0.8.0-alpha.4'], ['multi-app-manager', '0.7.0-alpha.1'], diff --git a/packages/presets/nocobase/src/server/migrations/20231029104932-set-charts-local.ts b/packages/presets/nocobase/src/server/migrations/20231029104932-set-charts-local.ts new file mode 100644 index 0000000000..e5ce7eee0e --- /dev/null +++ b/packages/presets/nocobase/src/server/migrations/20231029104932-set-charts-local.ts @@ -0,0 +1,27 @@ +import { Migration } from '@nocobase/server'; + +export default class SetAuditPluginAsLocalMigration extends Migration { + async up() { + const version = await this.app.version.satisfies('<=0.14.0-alpha.8'); + if (!version) { + return; + } + const repository = this.context.db.getRepository('applicationPlugins'); + const audit = await repository.findOne({ + filter: { + name: 'charts', + }, + }); + if (!audit) { + return; + } + await repository.update({ + values: { + builtIn: false, + }, + filter: { + name: 'charts', + }, + }); + } +}