From 5fd8c2c5a4ecc3e9e10d755318e4a7386c64d298 Mon Sep 17 00:00:00 2001 From: bill Date: Wed, 10 Dec 2025 16:48:27 +0800 Subject: [PATCH] Feat: Convert webhook data into the format required by the backend. --- .../schema-editor/add-field-button.tsx | 5 +- .../components/schema-editor/context.ts | 9 ++ .../components/schema-editor/interface.ts | 1 + .../schema-editor/schema-property-editor.tsx | 4 + .../schema-editor/schema-visual-editor.tsx | 21 +++-- web/src/constants/agent.tsx | 16 ++++ .../agent/canvas/node/variable-display.tsx | 26 +----- web/src/pages/agent/constant/index.tsx | 4 + web/src/pages/agent/form/begin-form/index.tsx | 92 ++++++++++--------- .../form/begin-form/use-handle-mode-change.ts | 20 +++- .../agent/form/begin-form/webhook/auth.tsx | 17 +--- .../begin-form/webhook/dynamic-response.tsx | 2 +- .../agent/form/begin-form/webhook/index.tsx | 77 +++++++++------- .../form/begin-form/webhook/response.tsx | 7 +- .../agent/form/components/schema-dialog.tsx | 10 +- web/src/pages/agent/utils.ts | 38 ++++++++ 16 files changed, 215 insertions(+), 134 deletions(-) create mode 100644 web/src/components/jsonjoy-builder/components/schema-editor/context.ts create mode 100644 web/src/components/jsonjoy-builder/components/schema-editor/interface.ts diff --git a/web/src/components/jsonjoy-builder/components/schema-editor/add-field-button.tsx b/web/src/components/jsonjoy-builder/components/schema-editor/add-field-button.tsx index 7a25705f9..fe06c1952 100644 --- a/web/src/components/jsonjoy-builder/components/schema-editor/add-field-button.tsx +++ b/web/src/components/jsonjoy-builder/components/schema-editor/add-field-button.tsx @@ -20,6 +20,7 @@ import { CirclePlus, HelpCircle, Info } from 'lucide-react'; import { useId, useState, type FC, type FormEvent } from 'react'; import { useTranslation } from '../../hooks/use-translation'; import type { NewField, SchemaType } from '../../types/json-schema'; +import { KeyInputProps } from './interface'; import SchemaTypeSelector from './schema-type-selector'; interface AddFieldButtonProps { @@ -27,9 +28,10 @@ interface AddFieldButtonProps { variant?: 'primary' | 'secondary'; } -const AddFieldButton: FC = ({ +const AddFieldButton: FC = ({ onAddField, variant = 'primary', + pattern, }) => { const [dialogOpen, setDialogOpen] = useState(false); const [fieldName, setFieldName] = useState(''); @@ -120,6 +122,7 @@ const AddFieldButton: FC = ({ placeholder={t.fieldNamePlaceholder} className="font-mono text-sm w-full" required + searchValue={pattern} /> diff --git a/web/src/components/jsonjoy-builder/components/schema-editor/context.ts b/web/src/components/jsonjoy-builder/components/schema-editor/context.ts new file mode 100644 index 000000000..3fbb14a26 --- /dev/null +++ b/web/src/components/jsonjoy-builder/components/schema-editor/context.ts @@ -0,0 +1,9 @@ +import React, { useContext } from 'react'; +import { KeyInputProps } from './interface'; + +export const KeyInputContext = React.createContext({}); + +export function useInputPattern() { + const x = useContext(KeyInputContext); + return x.pattern; +} diff --git a/web/src/components/jsonjoy-builder/components/schema-editor/interface.ts b/web/src/components/jsonjoy-builder/components/schema-editor/interface.ts new file mode 100644 index 000000000..39e74a641 --- /dev/null +++ b/web/src/components/jsonjoy-builder/components/schema-editor/interface.ts @@ -0,0 +1 @@ +export type KeyInputProps = { pattern?: RegExp | string }; diff --git a/web/src/components/jsonjoy-builder/components/schema-editor/schema-property-editor.tsx b/web/src/components/jsonjoy-builder/components/schema-editor/schema-property-editor.tsx index f95031e9c..347d69d26 100644 --- a/web/src/components/jsonjoy-builder/components/schema-editor/schema-property-editor.tsx +++ b/web/src/components/jsonjoy-builder/components/schema-editor/schema-property-editor.tsx @@ -16,6 +16,7 @@ import { withObjectSchema, } from '../../types/json-schema'; import type { ValidationTreeNode } from '../../types/validation'; +import { useInputPattern } from './context'; import TypeDropdown from './type-dropdown'; import TypeEditor from './type-editor'; @@ -54,6 +55,8 @@ export const SchemaPropertyEditor: React.FC = ({ 'object' as SchemaType, ); + const pattern = useInputPattern(); + // Update temp values when props change useEffect(() => { setTempName(name); @@ -123,6 +126,7 @@ export const SchemaPropertyEditor: React.FC = ({ className="h-8 text-sm font-medium min-w-[120px] max-w-full z-10" autoFocus onFocus={(e) => e.target.select()} + searchValue={pattern} /> ) : (