dataset-creating-dialog.tsx


Overview

dataset-creating-dialog.tsx defines React components that provide a user interface for creating a new dataset (or "knowledge base") by entering a name into a form within a modal dialog. It leverages form validation with zod and react-hook-form, internationalization via react-i18next, and custom UI components for dialogs, inputs, and buttons.

The primary functionality includes:


Components and Functions

Constants

FormId: string


InputForm

function InputForm({ onOk }: IModalProps<any>): JSX.Element

Description

Renders a form with a single input field for entering the dataset name. It uses react-hook-form integrated with a zod schema for validation. When the form is submitted successfully, it calls the onOk callback with the dataset name.

Parameters

Internal Details

Return Value

Usage Example

<InputForm onOk={(datasetName) => console.log('Dataset created:', datasetName)} />

DatasetCreatingDialog

function DatasetCreatingDialog({
  hideModal,
  onOk,
  loading,
}: IModalProps<any>): JSX.Element

Description

Renders a modal dialog containing the InputForm component and a submit button. It controls the dialog visibility and handles form submission and loading state display.

Parameters

Implementation Details

Return Value

Usage Example

<DatasetCreatingDialog
  hideModal={() => setDialogOpen(false)}
  onOk={(datasetName) => saveDataset(datasetName)}
  loading={isSaving}
/>

Important Implementation Details


Interaction with Other System Parts


Visual Diagram

classDiagram
    class InputForm {
        +onOk: function
        +onSubmit(data)
        -form: react-hook-form instance
        +render(): JSX.Element
    }
    class DatasetCreatingDialog {
        +hideModal: function
        +onOk: function
        +loading: boolean
        +render(): JSX.Element
    }
    DatasetCreatingDialog "1" --> "1" InputForm : renders >

Summary