fix(plugin-workflow): fix configuration drawer close logic (#3001)
This commit is contained in:
parent
81cea6b596
commit
8ee8b0052a
@ -274,7 +274,7 @@ export function JobButton() {
|
||||
);
|
||||
}
|
||||
|
||||
function useNodeFormProps() {
|
||||
function useFormProviderProps() {
|
||||
return { form: useForm() };
|
||||
}
|
||||
|
||||
@ -379,7 +379,7 @@ export function NodeDefaultView(props) {
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
...instruction.scope,
|
||||
useNodeFormProps,
|
||||
useFormProviderProps,
|
||||
}}
|
||||
components={instruction.components}
|
||||
schema={{
|
||||
@ -427,7 +427,7 @@ export function NodeDefaultView(props) {
|
||||
'x-decorator': 'FormV2',
|
||||
'x-decorator-props': {
|
||||
// form,
|
||||
useProps: '{{ useNodeFormProps }}',
|
||||
useProps: '{{ useFormProviderProps }}',
|
||||
},
|
||||
'x-component': 'Action.Drawer',
|
||||
properties: {
|
||||
|
@ -3,6 +3,7 @@ import { createForm } from '@formily/core';
|
||||
import { ISchema, useForm } from '@formily/react';
|
||||
import {
|
||||
ActionContextProvider,
|
||||
FormProvider,
|
||||
SchemaComponent,
|
||||
SchemaInitializerItemOptions,
|
||||
css,
|
||||
@ -143,6 +144,10 @@ function TriggerExecution() {
|
||||
);
|
||||
}
|
||||
|
||||
function useFormProviderProps() {
|
||||
return { form: useForm() };
|
||||
}
|
||||
|
||||
export const TriggerConfig = () => {
|
||||
const api = useAPIClient();
|
||||
const { workflow, refresh } = useFlowContext();
|
||||
@ -169,15 +174,14 @@ export const TriggerConfig = () => {
|
||||
const values = cloneDeep(workflow?.config);
|
||||
return createForm({
|
||||
initialValues: values,
|
||||
values,
|
||||
disabled: workflow?.executed,
|
||||
});
|
||||
}, [workflow]);
|
||||
|
||||
const resetForm = useCallback(
|
||||
(changed) => {
|
||||
setFormValueChanged(changed);
|
||||
if (!changed) {
|
||||
(editing) => {
|
||||
setEditingConfig(editing);
|
||||
if (!editing) {
|
||||
form.reset();
|
||||
}
|
||||
},
|
||||
@ -241,12 +245,18 @@ export const TriggerConfig = () => {
|
||||
<ActionContextProvider
|
||||
value={{
|
||||
visible: editingConfig,
|
||||
setVisible: setEditingConfig,
|
||||
setVisible: resetForm,
|
||||
formValueChanged,
|
||||
setFormValueChanged: resetForm,
|
||||
setFormValueChanged,
|
||||
}}
|
||||
>
|
||||
<FormProvider form={form}>
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
...scope,
|
||||
useFormProviderProps,
|
||||
}}
|
||||
components={components}
|
||||
schema={{
|
||||
name: `workflow-trigger-${workflow.id}`,
|
||||
type: 'void',
|
||||
@ -266,7 +276,8 @@ export const TriggerConfig = () => {
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-decorator': 'FormV2',
|
||||
'x-decorator-props': {
|
||||
form,
|
||||
// form,
|
||||
useProps: '{{ useFormProviderProps }}',
|
||||
},
|
||||
properties: {
|
||||
...(trigger.description
|
||||
@ -324,9 +335,8 @@ export const TriggerConfig = () => {
|
||||
},
|
||||
},
|
||||
}}
|
||||
scope={scope}
|
||||
components={components}
|
||||
/>
|
||||
</FormProvider>
|
||||
</ActionContextProvider>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user