parameter-dialog.tsx


Overview

parameter-dialog.tsx defines a React modal dialog component for creating and editing parameters (referred to as "BeginQuery" objects) used within a flow or query configuration system. It provides a user interface to input and validate the parameter’s type, key, display name, optional status, and additional options if applicable. The dialog encapsulates a form built with react-hook-form and Zod schema validation, supporting dynamic UI changes based on the selected parameter type.

This component is tightly integrated with the UI framework components for dialogs, forms, inputs, switches, and select dropdowns, and leverages internationalization hooks for localization. It interacts with constants and types related to BeginQuery, ensuring consistent validation and rendering of parameter types with icons.


Classes and Components

ParameterForm

Description

A controlled form component managing the parameter input fields using react-hook-form and Zod for validation. It renders input controls for parameter properties and conditionally renders dynamic options when the parameter type is Options.

Props

Name

Type

Description

initialValue

BeginQuery

Initial values to populate the form (editing existing parameter).

otherThanCurrentQuery

BeginQuery[]

List of other parameters to validate uniqueness of the key field.

submit

(values: any) => void

Callback invoked with sanitized form data on submission.

State and Hooks

Zod Validation Schema

Methods

Rendered Form Fields

Usage Example

<ParameterForm
  initialValue={existingParameter}
  otherThanCurrentQuery={allOtherParameters}
  submit={(values) => console.log('Form submitted:', values)}
/>

ParameterDialog

Description

A modal dialog wrapper that displays the ParameterForm inside a dialog UI. It handles opening and closing the dialog and provides a submit button linked to the form.

Props

Name

Type

Description

initialValue

BeginQuery

Initial parameter values for editing.

hideModal

(open: boolean) => void

Callback to close the dialog.

otherThanCurrentQuery

BeginQuery[]

Other parameters for key uniqueness validation.

submit

(values: any) => void

Callback triggered upon form submission.

Behavior

Usage Example

<ParameterDialog
  initialValue={paramToEdit}
  otherThanCurrentQuery={paramsExcludingCurrent}
  submit={(values) => saveParameter(values)}
  hideModal={() => setShowDialog(false)}
/>

Important Implementation Details


Interaction with Other System Parts

This file likely functions as part of a larger flow or query configuration system where users define parameters that influence the runtime behavior of flows or queries.


Mermaid Component Diagram

classDiagram
    class ParameterDialog {
        +initialValue: BeginQuery
        +hideModal(open: boolean): void
        +otherThanCurrentQuery: BeginQuery[]
        +submit(values: any): void
    }
    class ParameterForm {
        -form: UseForm
        -FormSchema: z.ZodSchema
        -options: RAGFlowSelectOptionType[]
        -onSubmit(data: FormSchema): void
        -handleKeyChange(e: ChangeEvent<HTMLInputElement>): void
        +initialValue: BeginQuery
        +otherThanCurrentQuery: BeginQuery[]
        +submit(values: any): void
    }
    class BeginDynamicOptions

    ParameterDialog --> ParameterForm : renders >
    ParameterForm --> BeginDynamicOptions : conditionally renders >

Summary

The parameter-dialog.tsx file provides a comprehensive modal dialog solution for parameter management in a flow/query system. It combines robust form handling, validation, dynamic UI rendering, and localization to facilitate a user-friendly experience for defining complex parameters. Its integration with shared UI components and data models makes it a reusable and consistent part of the application’s configuration interface.