From 9ff82f999889640f395987841866fe4454f0181f Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 30 Apr 2022 13:49:43 +0800 Subject: [PATCH] fix: block template names updated in real time --- .../schemas/uiSchemaTemplates.ts | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts b/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts index 166c6e688..d7f9961d8 100644 --- a/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts +++ b/packages/core/client/src/schema-templates/schemas/uiSchemaTemplates.ts @@ -1,5 +1,18 @@ import { ISchema } from '@formily/react'; import { uid } from '@formily/shared'; +import { useUpdateActionProps } from '../../block-provider/hooks'; +import { useSchemaTemplateManager } from '../SchemaTemplateManagerProvider'; + +const useUpdateSchemaTemplateActionProps = () => { + const props = useUpdateActionProps(); + const { refresh } = useSchemaTemplateManager(); + return { + async onClick() { + await props.onClick(); + refresh(); + } + } +} export const uiSchemaTemplatesSchema: ISchema = { type: 'object', @@ -70,14 +83,14 @@ export const uiSchemaTemplatesSchema: ISchema = { split: '|', }, properties: { - view: { - title: '{{ t("View") }}', - 'x-action': 'view', - 'x-component': 'RecordLink', - 'x-component-props': { - to: '/admin/plugins/block-templates/${record.key}', - }, - }, + // view: { + // title: '{{ t("View") }}', + // 'x-action': 'view', + // 'x-component': 'RecordLink', + // 'x-component-props': { + // to: '/admin/plugins/block-templates/${record.key}', + // }, + // }, edit: { type: 'void', title: '{{ t("Edit") }}', @@ -132,13 +145,13 @@ export const uiSchemaTemplatesSchema: ISchema = { }, properties: { submit: { - title: 'Submit', + title: '{{t("Submit")}}', 'x-action': 'submit', 'x-component': 'Action', 'x-component-props': { type: 'primary', htmlType: 'submit', - useProps: '{{ useUpdateActionProps }}', + useProps: useUpdateSchemaTemplateActionProps, }, type: 'void', },