index.tsx

Overview

This file defines a React functional component InvokeForm that provides a comprehensive form interface for configuring and invoking HTTP requests within a larger workflow or flow editor system. It leverages React Hook Form for form state management, integrates Monaco Editor for editing JSON headers, and supports dynamic variable management via modal dialogs and tables.

The form supports configuring key HTTP request parameters such as URL, method (GET, POST, PUT), timeout, headers (as JSON), proxy, and a toggle for cleaning HTML responses. It also allows the user to define, edit, and delete variables used within the request parameters. The form includes validation using Zod schemas and supports internationalization via react-i18next.

This component is memoized to optimize rendering performance and is designed to be embedded within a node-based workflow editor or similar system.


Detailed Explanation

Enumerations and Constants

enum Method

Defines HTTP methods supported by the form:

Value

Description

GET

HTTP GET method

POST

HTTP POST method

PUT

HTTP PUT method

MethodOptions

An array of objects mapping method names to { label, value } pairs for use in the method selection dropdown.


Interface: TimeoutInputProps

Props for the TimeoutInput component.

Property

Type

Description

value

[number \

undefined](/projects/311/74002)

onChange

[(value: number \

null) => void \


Component: TimeoutInput

A small controlled input component that allows users to input a numeric timeout value in seconds. It uses a custom NumberInput component and displays a localized label for "seconds".

Parameters:

Usage Example:

<TimeoutInput value={10} onChange={(val) => console.log(val)} />

Main Component: InvokeForm

Primary exported component, memoized for performance.

Props:

Property

Type

Description

node

INextOperatorForm

Represents the current workflow node this form configures.

Functionality:


Properties and Methods within InvokeForm


Usage Example

import InvokeForm from './index';

function MyNodeComponent({ node }) {
  return <InvokeForm node={node} />;
}

Important Implementation Details


Interaction with Other System Components


Visual Diagram

componentDiagram
    component "InvokeForm" {
        +render()
        -form : useForm<FormSchemaType>
        -variables : watched form field
        -showModal()
        -hideModal()
        -ok()
        -handleDeleteRecord()
    }
    component "TimeoutInput" {
        +render()
        -value: number | undefined
        -onChange: (number | null) => void
    }
    component "VariableTable"
    component "VariableDialog"
    component "FormWrapper"
    component "FormContainer"
    component "Collapse"
    component "Output"
    component "Monaco Editor"

    InvokeForm --> TimeoutInput : uses
    InvokeForm --> VariableTable : embeds
    InvokeForm --> VariableDialog : embeds (conditional)
    InvokeForm --> FormWrapper : wraps form
    InvokeForm --> FormContainer : contains form fields
    InvokeForm --> Collapse : toggles variable section
    InvokeForm --> Output : renders output list
    FormField --> Monaco Editor : for headers editing

Summary

This file implements a complex, validated, and internationalized HTTP invocation form as part of a node-based workflow editor. It integrates sophisticated UI components and hooks to manage variables, form state, and output display, providing users with a rich interface to configure HTTP requests dynamically within a larger system.