fix: block template names updated in real time

This commit is contained in:
chenos 2022-04-30 13:49:43 +08:00
parent 515d952767
commit 9ff82f9998

View File

@ -1,5 +1,18 @@
import { ISchema } from '@formily/react'; import { ISchema } from '@formily/react';
import { uid } from '@formily/shared'; 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 = { export const uiSchemaTemplatesSchema: ISchema = {
type: 'object', type: 'object',
@ -70,14 +83,14 @@ export const uiSchemaTemplatesSchema: ISchema = {
split: '|', split: '|',
}, },
properties: { properties: {
view: { // view: {
title: '{{ t("View") }}', // title: '{{ t("View") }}',
'x-action': 'view', // 'x-action': 'view',
'x-component': 'RecordLink', // 'x-component': 'RecordLink',
'x-component-props': { // 'x-component-props': {
to: '/admin/plugins/block-templates/${record.key}', // to: '/admin/plugins/block-templates/${record.key}',
}, // },
}, // },
edit: { edit: {
type: 'void', type: 'void',
title: '{{ t("Edit") }}', title: '{{ t("Edit") }}',
@ -132,13 +145,13 @@ export const uiSchemaTemplatesSchema: ISchema = {
}, },
properties: { properties: {
submit: { submit: {
title: 'Submit', title: '{{t("Submit")}}',
'x-action': 'submit', 'x-action': 'submit',
'x-component': 'Action', 'x-component': 'Action',
'x-component-props': { 'x-component-props': {
type: 'primary', type: 'primary',
htmlType: 'submit', htmlType: 'submit',
useProps: '{{ useUpdateActionProps }}', useProps: useUpdateSchemaTemplateActionProps,
}, },
type: 'void', type: 'void',
}, },