fix(plugin-workflow): fix field crash in block (#5366)
Some checks are pending
auto-merge / push-commit (push) Waiting to run
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
deploy client docs / Build (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run

This commit is contained in:
Junyi 2024-10-08 16:01:57 +08:00 committed by GitHub
parent 69302e1ddf
commit f074029624
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 24 deletions

View File

@ -122,7 +122,7 @@ export const DataBlockContext = createContext<DataBlockContextValue<any>>({} as
DataBlockContext.displayName = 'DataBlockContext';
const DataBlockResourceContext = createContext<{ rerenderDataBlock: () => void }>(null);
const RerenderDataBlockProvider: FC = ({ children }) => {
export const RerenderDataBlockProvider: FC = ({ children }) => {
const [hidden, setHidden] = React.useState(false);
const value = useMemo(() => {
return {

View File

@ -18,6 +18,7 @@ import {
FormBlockContext,
FormV2,
RecordProvider,
RerenderDataBlockProvider,
useAPIClient,
useAssociationNames,
useBlockRequestContext,
@ -82,16 +83,18 @@ export function FormBlockProvider(props) {
<CollectionManagerProvider dataSource={dataSource}>
<CollectionProvider_deprecated collection={props.collection}>
<RecordProvider record={values} parent={null}>
<FormActiveFieldsProvider name="form">
<BlockRequestContext_deprecated.Provider
value={{ block: 'form', props, field, service, resource, __parent }}
>
<FormBlockContext.Provider value={formBlockValue}>
<FormV2.Templates style={{ marginBottom: token.margin }} form={form} />
<div ref={formBlockRef}>{props.children}</div>
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
</FormActiveFieldsProvider>
<RerenderDataBlockProvider>
<FormActiveFieldsProvider name="form">
<BlockRequestContext_deprecated.Provider
value={{ block: 'form', props, field, service, resource, __parent }}
>
<FormBlockContext.Provider value={formBlockValue}>
<FormV2.Templates style={{ marginBottom: token.margin }} form={form} />
<div ref={formBlockRef}>{props.children}</div>
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
</FormActiveFieldsProvider>
</RerenderDataBlockProvider>
</RecordProvider>
</CollectionProvider_deprecated>
</CollectionManagerProvider>

View File

@ -19,6 +19,7 @@ import {
CollectionManagerProvider,
CollectionProvider,
FormProvider,
RerenderDataBlockProvider,
SchemaComponent,
SchemaComponentOptions,
SchemaComponentProvider,
@ -57,8 +58,7 @@ export function AssignedFieldsFormSchemaConfig(props) {
const { setFormValueChanged } = useActionContext();
const api = useAPIClient();
const scope = useWorkflowVariableOptions();
const nodeForm = useForm();
const { values, setValuesIn } = nodeForm;
const { values, setValuesIn, disabled } = useForm();
const params = toJS(values.params);
const [dataSourceName, collectionName] = parseCollectionName(values.collection);
@ -121,17 +121,19 @@ export function AssignedFieldsFormSchemaConfig(props) {
<Card>
<CollectionManagerProvider dataSource={dataSourceName}>
<CollectionProvider name={collectionName}>
<FormProvider form={form}>
<FormLayout layout={'vertical'}>
<VariableScopeProvider scope={scope}>
<SchemaComponentProvider form={form} designable={!nodeForm.disabled}>
<SchemaComponentOptions {...schemaOptions}>
<SchemaComponent schema={schema} onChange={onChange} />
</SchemaComponentOptions>
</SchemaComponentProvider>
</VariableScopeProvider>
</FormLayout>
</FormProvider>
<RerenderDataBlockProvider>
<FormProvider form={form}>
<FormLayout layout={'vertical'}>
<VariableScopeProvider scope={scope}>
<SchemaComponentProvider form={form} designable={!disabled}>
<SchemaComponentOptions {...schemaOptions}>
<SchemaComponent schema={schema} onChange={onChange} />
</SchemaComponentOptions>
</SchemaComponentProvider>
</VariableScopeProvider>
</FormLayout>
</FormProvider>
</RerenderDataBlockProvider>
</CollectionProvider>
</CollectionManagerProvider>
</Card>