feat(ui): new WorkflowElements using antd

This commit is contained in:
Fu Diwei
2025-01-03 20:29:34 +08:00
parent c6a8f923e4
commit 8a16893082
43 changed files with 805 additions and 810 deletions

View File

@@ -14,7 +14,7 @@ import { getNextCronExecutions, validCronExpression } from "@/utils/cron";
import { usePanel } from "../PanelProvider";
export type StartNodeFormProps = {
data: WorkflowNode;
node: WorkflowNode;
};
const initFormModel = () => {
@@ -24,7 +24,7 @@ const initFormModel = () => {
};
};
const StartNodeForm = ({ data }: StartNodeFormProps) => {
const StartNodeForm = ({ node }: StartNodeFormProps) => {
const { t } = useTranslation();
const { updateNode } = useWorkflowStore(useZustandShallowSelector(["updateNode"]));
@@ -54,11 +54,11 @@ const StartNodeForm = ({ data }: StartNodeFormProps) => {
formPending,
formProps,
} = useAntdForm<z.infer<typeof formSchema>>({
initialValues: data?.config ?? initFormModel(),
initialValues: node?.config ?? initFormModel(),
onSubmit: async (values) => {
await formInst.validateFields();
await updateNode(
produce(data, (draft) => {
produce(node, (draft) => {
draft.config = { ...values };
draft.validated = true;
})
@@ -67,12 +67,12 @@ const StartNodeForm = ({ data }: StartNodeFormProps) => {
},
});
const [triggerType, setTriggerType] = useState(data?.config?.executionMethod);
const [triggerType, setTriggerType] = useState(node?.config?.executionMethod);
const [triggerCronLastExecutions, setTriggerCronExecutions] = useState<Date[]>([]);
useEffect(() => {
setTriggerType(data?.config?.executionMethod);
setTriggerCronExecutions(getNextCronExecutions(data?.config?.crontab as string, 5));
}, [data?.config?.executionMethod, data?.config?.crontab]);
setTriggerType(node?.config?.executionMethod);
setTriggerCronExecutions(getNextCronExecutions(node?.config?.crontab as string, 5));
}, [node?.config?.executionMethod, node?.config?.crontab]);
const handleTriggerTypeChange = (value: string) => {
setTriggerType(value);