index.tsx


Overview

This file defines a React component ExeSQLForm that renders a form interface for configuring and executing SQL statements in a flow-based application. It leverages React Hook Form for form state management and validation, integrates UI components from an internal design system, and supports internationalization.

The form includes fields for SQL input and database connection parameters (such as DB type, username, host, port, etc.), and provides a "Test" button to submit and validate the SQL execution configuration. The file also defines a subcomponent ExeSQLFormWidgets responsible for rendering the database connection fields.

Key features:


Components and Functions

ExeSQLFormWidgets

A presentational component rendering the database connection related form fields and the submit button.

Props

Name

Type

Description

loading

boolean

Indicates whether the form is in a loading (submit) state, disabling the submit button accordingly.

Usage

<ExeSQLFormWidgets loading={isLoading} />

Description


ExeSQLForm

The main exported component that represents the SQL execution form.

Props

Name

Type

Description

node

INextOperatorForm

Object representing the current flow node with configuration and state.

Usage

<ExeSQLForm node={currentNode} />

Description


Important Implementation Details


Interaction with Other Parts of the System


Code Structure Diagram

The following Mermaid component diagram illustrates the relationship between the main components and hooks in this file:

componentDiagram
    component ExeSQLForm {
      +node: INextOperatorForm
      +renders FormWrapper
      +uses useForm
      +uses useSubmitForm
      +uses useFormValues
      +uses useWatchFormChange
      +renders RAGFlowFormItem -> PromptEditor
      +renders ExeSQLFormWidgets
      +renders Output
    }
    component ExeSQLFormWidgets {
      +loading: boolean
      +uses useFormContext
      +renders multiple FormField components
      +includes ButtonLoading
    }
    component useSubmitForm
    component useFormValues
    component useWatchFormChange
    component FormWrapper
    component Output
    component PromptEditor

    ExeSQLForm --> useSubmitForm
    ExeSQLForm --> useFormValues
    ExeSQLForm --> useWatchFormChange
    ExeSQLForm --> FormWrapper
    ExeSQLForm --> RAGFlowFormItem
    RAGFlowFormItem --> PromptEditor
    ExeSQLForm --> ExeSQLFormWidgets
    ExeSQLForm --> Output
    ExeSQLFormWidgets --> useFormContext
    ExeSQLFormWidgets --> ButtonLoading

Example Usage

import ExeSQLForm from './index';

function FlowNodeEditor({ currentNode }) {
  return (
    <div>
      <h2>Configure SQL Execution</h2>
      <ExeSQLForm node={currentNode} />
    </div>
  );
}

Summary

This file provides a well-structured, validated, and localized React form component for configuring SQL execution nodes within a flow. It cleanly separates UI concerns via modular components and custom hooks, integrates with a design system and internationalization, and manages complex form state and validation efficiently. The form supports real-time form value watching and output visualization, making it a core UI component in a larger flow-based automation or orchestration system.