Implementation:Infiniflow Ragflow MetadataConstants
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Knowledge_Base |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Metadata type enums, delete-confirmation message maps, and value-type label helpers for the dataset metadata subsystem.
Description
This constants module defines the MetadataType enum (Manage, UpdateSingle, Setting, SingleFileSetting) that controls metadata editing modes. MetadataDeleteMap is a factory that accepts an i18n translation function and returns per-mode warning messages for field and value deletion confirmations. The file also exports VALUE_TYPE_LABELS (string, time, number, list), metadataValueTypeEnum, metadataValueTypeOptions for select dropdowns, and getMetadataValueTypeLabel for display resolution.
Usage
Import these constants in metadata management components and hooks to drive conditional UI rendering, populate type selectors, and display context-appropriate deletion warnings.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/pages/dataset/components/metedata/constant.ts
- Lines: 1-81
Signature
export enum MetadataType {
Manage = 1, UpdateSingle = 2, Setting = 3, SingleFileSetting = 4,
}
export const MetadataDeleteMap = (t: TFunction): Record<MetadataType, { title: string; warnFieldText: string; warnValueText: string; warnFieldName: string; warnValueName: string }>;
export const DEFAULT_VALUE_TYPE: MetadataValueType;
export const VALUE_TYPE_LABELS: Record<MetadataValueType, string>;
export const metadataValueTypeEnum: Record<MetadataValueType, MetadataValueType>;
export const metadataValueTypeOptions: { label: string; value: string }[];
export const getMetadataValueTypeLabel: (value?: MetadataValueType) => string;
Import
import { MetadataType, MetadataDeleteMap, VALUE_TYPE_LABELS, metadataValueTypeOptions, getMetadataValueTypeLabel } from '../constant';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| t | TFunction | Yes | i18n translation function for MetadataDeleteMap |
| value | MetadataValueType | No | Value type key for getMetadataValueTypeLabel |
Outputs
| Name | Type | Description |
|---|---|---|
| MetadataDeleteMap result | Record<MetadataType, object> | Per-mode warning strings for delete confirmations |
| metadataValueTypeOptions | Array | Select dropdown options for value types |
Usage Examples
import { MetadataType, MetadataDeleteMap, metadataValueTypeOptions } from '../constant';
// Get delete warning text for the current mode
const warnings = MetadataDeleteMap(t)[MetadataType.Manage];
console.log(warnings.warnFieldText);
// Populate a select dropdown
<Select options={metadataValueTypeOptions} />