index.tsx

Overview

index.tsx defines a React functional component named ChunkCreatingModal that provides a modal dialog interface for creating or editing a "chunk" entity within a knowledge management system. This modal allows users to input chunk content, associate keywords and tags, toggle availability, and optionally delete an existing chunk.

The component integrates form management (Ant Design Form), state handling, data fetching, and mutation hooks to handle chunk data lifecycle. It adapts its UI based on the parser type (tag or otherwise), supporting different tag inputs and feature configurations.


Component: ChunkCreatingModal

Description

ChunkCreatingModal is a modal dialog component for creating or editing a chunk. A chunk is a piece of content with associated keywords, tags, and configurable features used in a knowledge base or document parser.

It supports:

Props

The component merges modal props (IModalProps<any>) with additional properties specific to chunk handling:

Prop

Type

Description

doc_id

string

ID of the document containing chunks.

chunkId

[string \

undefined](/projects/311/74002)

parserId

string

Identifier for the parser type, affects UI rendering.

hideModal

() => void

Callback to close the modal.

onOk

[(values: any) => void \

undefined](/projects/311/71637)

loading

boolean

Loading state for submission button.

State

State

Type

Description

checked

boolean

Indicates chunk availability toggle (enabled/disabled).

Hooks Used

Key Functions / Methods

handleOk

handleRemove

handleCheck

Effects

Rendered JSX Structure


Important Implementation Details


Interaction with Other Parts of the Application


Usage Example

<ChunkCreatingModal
  doc_id="12345"
  chunkId="67890" // undefined for creating new chunk
  parserId="tag"
  hideModal={() => setModalVisible(false)}
  onOk={(values) => {
    // Handle form submission, e.g., save or update chunk
    console.log('Chunk data submitted:', values);
  }}
  loading={isSaving}
/>

Visual Diagram

componentDiagram
    direction TB
    ChunkCreatingModal -- uses --> Form
    ChunkCreatingModal -- uses --> Modal
    ChunkCreatingModal -- uses --> EditTag
    ChunkCreatingModal -- uses --> TagFeatureItem
    ChunkCreatingModal -- uses --> useFetchChunk
    ChunkCreatingModal -- uses --> useDeleteChunkByIds
    ChunkCreatingModal -- uses --> transformTagFeaturesArrayToObject
    ChunkCreatingModal -- uses --> transformTagFeaturesObjectToArray
    ChunkCreatingModal -- uses --> useTranslation
    ChunkCreatingModal -- uses --> useState
    ChunkCreatingModal -- uses --> useEffect
    ChunkCreatingModal -- uses --> useCallback

Summary

The index.tsx file encapsulates a reusable modal component that manages creation and editing of "chunks"—content entities enriched with keywords and tag features. It integrates tightly with backend data fetching and mutation hooks and adapts its UI dynamically based on parser type. With form validation and state synchronization, it ensures correct data flow and user experience in knowledge base management workflows.