index.tsx


Overview

index.tsx defines the React functional component FileMovingModal, a modal dialog used within a file management user interface to move files or folders to a different destination folder. The component leverages the Ant Design (antd) UI library for form and modal elements, and incorporates an asynchronous tree-select control for selecting the destination folder.

The modal includes form validation to ensure the user selects a destination before submitting, and provides a loading state while the move operation is in progress. It also supports internationalization through a custom translation hook.


Component: FileMovingModal

Description

FileMovingModal is a controlled modal component that allows users to pick a destination folder from a hierarchical tree and confirm the move operation. It uses an asynchronous tree select component (AsyncTreeSelect) to dynamically load folder options.

Props

The component expects the following props, extending from IModalManagerChildrenProps (except for showModal which is omitted):

Prop

Type

Description

visible

boolean

Controls whether the modal is visible or hidden.

hideModal

() => void

Callback function to hide/close the modal.

loading

boolean

Indicates if the modal is in a loading state, e.g., while waiting for the move operation.

onOk

(id: string) => void

Callback invoked when the form is successfully submitted, providing the selected folder ID.

Internal Types

type FieldType = {
  name?: string;
};

Methods

handleOk: () => Promise<void>

Usage Example

<FileMovingModal
  visible={isModalVisible}
  hideModal={() => setModalVisible(false)}
  loading={isMoving}
  onOk={(folderId) => handleMoveFile(folderId)}
/>

Implementation Details


Interactions with Other Parts of the System


Diagram: Component Structure and Workflow

componentDiagram
    component FileMovingModal {
        +visible: boolean
        +hideModal(): void
        +loading: boolean
        +onOk(folderId: string): void
        -handleOk(): Promise<void>
        -form: FormInstance
    }

    component Modal {
        +title: string
        +open: boolean
        +onOk(): void
        +onCancel(): void
        +okButtonProps: object
        +confirmLoading: boolean
    }

    component Form {
        +formInstance: FormInstance
        +validateFields(): Promise<object>
    }

    component AsyncTreeSelect {
        // Asynchronously loads tree nodes for folder selection
    }

    FileMovingModal --> Modal : renders
    FileMovingModal --> Form : uses for data entry
    Form --> AsyncTreeSelect : form field component
    Modal --> Form : contains

Summary


This documentation should enable developers to understand, integrate, and extend the FileMovingModal component effectively within the file management system.