diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index fbf5eab2f..4ff041587 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -251,23 +251,16 @@ const getAllkeys = (data, result) => { return result; }; -function AssignedFieldValues() { +export function AssignedFieldValues() { const { dn } = useDesignable(); const { t } = useTranslation(); const fieldSchema = useFieldSchema(); - const field = useField(); - const [initialSchema, setInitialSchema] = useState(); - useEffect(() => { - const schemaUid = uid(); - const schema: ISchema = { - type: 'void', - 'x-uid': schemaUid, - 'x-component': 'Grid', - 'x-initializer': 'CustomFormItemInitializers', - }; - setInitialSchema(schema); - }, [field.address]); - + const initialSchema = { + type: 'void', + 'x-uid': uid(), + 'x-component': 'Grid', + 'x-initializer': 'CustomFormItemInitializers', + }; const tips = { 'customize:update': t( 'After clicking the custom button, the following fields of the current record will be saved according to the following form.', @@ -289,7 +282,6 @@ function AssignedFieldValues() { }, [dn, fieldSchema], ); - return ( false}> diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx index 5f984a407..b80a07cd8 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx +++ b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdateAction.Settings.tsx @@ -1,20 +1,18 @@ -import React, { useCallback, useState, useEffect } from 'react'; +import React from 'react'; import { SchemaSettings, ActionDesigner, useSchemaToolbar, useDesignable, useCompile, - DefaultValueProvider, SchemaSettingsItemGroup, SchemaSettingsModalItem, - SchemaSettingsActionModalItem, SchemaSettingsSelectItem, - FlagProvider, + AssignedFieldValues, } from '@nocobase/client'; -import { isValid, uid } from '@formily/shared'; +import { isValid } from '@formily/shared'; import { useTranslation } from 'react-i18next'; -import { useField, useFieldSchema, ISchema } from '@formily/react'; +import { useFieldSchema, ISchema } from '@formily/react'; const MenuGroup = (props) => { const fieldSchema = useFieldSchema(); @@ -122,61 +120,6 @@ function AfterSuccess() { /> ); } -function AssignedFieldValues() { - const { dn } = useDesignable(); - const { t } = useTranslation(); - const fieldSchema = useFieldSchema(); - const field = useField(); - const [initialSchema, setInitialSchema] = useState(); - useEffect(() => { - const schemaUid = uid(); - const schema: ISchema = { - type: 'void', - 'x-uid': schemaUid, - 'x-component': 'Grid', - 'x-initializer': 'CustomFormItemInitializers', - }; - setInitialSchema(schema); - }, [field.address]); - - const tips = { - 'customize:update': t( - 'After clicking the custom button, the following fields of the current record will be saved according to the following form.', - ), - 'customize:save': t( - 'After clicking the custom button, the following fields of the current record will be saved according to the following form.', - ), - }; - const actionType = fieldSchema['x-action'] ?? ''; - const onSubmit = useCallback( - (assignedValues) => { - fieldSchema['x-action-settings']['assignedValues'] = assignedValues; - dn.emit('patch', { - schema: { - ['x-uid']: fieldSchema['x-uid'], - 'x-action-settings': fieldSchema['x-action-settings'], - }, - }); - }, - [dn, fieldSchema], - ); - - return ( - - false}> - - - - ); -} const bulkUpdateActionSettings = new SchemaSettings({ name: 'ActionSettings:customize:bulkUpdate', @@ -207,10 +150,10 @@ const bulkUpdateActionSettings = new SchemaSettings({ { name: 'assignFieldValues', Component: AssignedFieldValues, - useVisible() { - const fieldSchema = useFieldSchema(); - return isValid(fieldSchema?.['x-action-settings']?.assignedValues); - }, + // useVisible() { + // const fieldSchema = useFieldSchema(); + // return isValid(fieldSchema?.['x-action-settings']?.assignedValues); + // }, }, { name: 'afterSuccess', diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdatePluginProvider.tsx b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdatePluginProvider.tsx deleted file mode 100644 index b54eddcda..000000000 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/BulkUpdatePluginProvider.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { SchemaComponentOptions } from '@nocobase/client'; -import React from 'react'; -import { CustomizeActionInitializer } from './CustomizeActionInitializer'; -import { useCustomizeBulkUpdateActionProps } from './utils'; - -export const BulkUpdatePluginProvider = (props: any) => { - return ( - - {props.children} - - ); -}; diff --git a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/index.tsx b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/index.tsx index 70b8c4e6f..ce941e856 100644 --- a/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/index.tsx +++ b/packages/plugins/@nocobase/plugin-action-bulk-update/src/client/index.tsx @@ -1,9 +1,11 @@ import { Plugin, useCollection } from '@nocobase/client'; -import { BulkUpdatePluginProvider } from './BulkUpdatePluginProvider'; import { bulkUpdateActionSettings } from './BulkUpdateAction.Settings'; +import { CustomizeActionInitializer } from './CustomizeActionInitializer'; +import { useCustomizeBulkUpdateActionProps } from './utils'; export class BulkUpdatePlugin extends Plugin { async load() { - this.app.use(BulkUpdatePluginProvider); + this.app.addComponents({ CustomizeActionInitializer }); + this.app.addScopes({ useCustomizeBulkUpdateActionProps }); this.app.schemaSettingsManager.add(bulkUpdateActionSettings); const initializerData = {