refactor(web): mark Props of datasets/ components as read-only (#25219) (#37300)

This commit is contained in:
Rohit Gahlawat 2026-06-11 05:46:21 +05:30 committed by GitHub
parent 9c6577804c
commit 56b82449fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
54 changed files with 108 additions and 108 deletions

View File

@ -5,10 +5,10 @@ import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
import { GeneralChunk, ParentChildChunk } from '@/app/components/base/icons/src/vender/knowledge'
type Props = {
type Props = Readonly<{
isGeneralMode: boolean
isQAMode: boolean
}
}>
const ChunkingModeLabel: FC<Props> = ({
isGeneralMode,

View File

@ -19,12 +19,12 @@ const extendToFileTypeMap: { [key: string]: FileAppearanceType } = {
docx: FileAppearanceTypeEnum.word,
}
type Props = {
type Props = Readonly<{
extension?: string
name?: string
size?: 'sm' | 'md' | 'lg' | 'xl'
className?: string
}
}>
const DocumentFileIcon: FC<Props> = ({
extension,

View File

@ -8,9 +8,9 @@ import {
} from '@langgenius/dify-ui/combobox'
import FileIcon from '../document-file-icon'
type Props = {
type Props = Readonly<{
className?: string
}
}>
function getDocumentExtension(document: SimpleDocumentDetail) {
const detailExtension = document.data_source_detail_dict?.upload_file?.extension

View File

@ -23,12 +23,12 @@ import { useDocumentList } from '@/service/knowledge/use-document'
import FileIcon from '../document-file-icon'
import DocumentList from './document-list'
type Props = {
type Props = Readonly<{
datasetId: string
value?: SimpleDocumentDetail | null
parentMode?: ParentMode
onChange: (value: SimpleDocumentDetail) => void
}
}>
function getDocumentLabel(document: SimpleDocumentDetail) {
return document.name

View File

@ -15,12 +15,12 @@ import { useTranslation } from 'react-i18next'
import Loading from '@/app/components/base/loading'
import FileIcon from '../document-file-icon'
type Props = {
type Props = Readonly<{
className?: string
value?: DocumentItem
files: DocumentItem[]
onChange: (value: DocumentItem) => void
}
}>
const PreviewDocumentPicker: FC<Props> = ({
className,

View File

@ -7,9 +7,9 @@ import { useTranslation } from 'react-i18next'
import { useAutoDisabledDocuments, useDocumentEnable, useInvalidDisabledDocument } from '@/service/knowledge/use-document'
import StatusWithAction from './status-with-action'
type Props = {
type Props = Readonly<{
datasetId: string
}
}>
const AutoDisabledDocument: FC<Props> = ({
datasetId,

View File

@ -9,9 +9,9 @@ import { retryErrorDocs } from '@/service/datasets'
import { useDatasetErrorDocs } from '@/service/knowledge/use-dataset'
import StatusWithAction from './status-with-action'
type Props = {
type Props = Readonly<{
datasetId: string
}
}>
type IIndexState = {
value: string
}

View File

@ -6,13 +6,13 @@ import * as React from 'react'
import Divider from '@/app/components/base/divider'
type Status = 'success' | 'error' | 'warning' | 'info'
type Props = {
type Props = Readonly<{
type?: Status
description: string
actionText?: string
onAction?: () => void
disabled?: boolean
}
}>
const IconMap = {
success: {

View File

@ -9,11 +9,11 @@ import { EffectColor } from '../../settings/chunk-structure/types'
import OptionCard from '../../settings/option-card'
import RetrievalParamConfig from '../retrieval-param-config'
type Props = {
type Props = Readonly<{
disabled?: boolean
value: RetrievalConfig
onChange: (value: RetrievalConfig) => void
}
}>
const EconomicalRetrievalMethodConfig: FC<Props> = ({
disabled = false,

View File

@ -18,12 +18,12 @@ import { EffectColor } from '../../settings/chunk-structure/types'
import OptionCard from '../../settings/option-card'
import RetrievalParamConfig from '../retrieval-param-config'
type Props = {
type Props = Readonly<{
disabled?: boolean
value: RetrievalConfig
showMultiModalTip?: boolean
onChange: (value: RetrievalConfig) => void
}
}>
const RetrievalMethodConfig: FC<Props> = ({
disabled = false,

View File

@ -7,9 +7,9 @@ import RadioCard from '@/app/components/base/radio-card'
import { RETRIEVE_METHOD } from '@/types/app'
import { retrievalIcon } from '../../create/icons'
type Props = {
type Props = Readonly<{
value: RetrievalConfig
}
}>
export const getIcon = (type: RETRIEVE_METHOD) => {
return ({

View File

@ -27,12 +27,12 @@ import { RETRIEVE_METHOD } from '@/types/app'
import ProgressIndicator from '../../create/assets/progress-indicator.svg'
import Reranking from '../../create/assets/rerank.svg'
type Props = {
type Props = Readonly<{
type: RETRIEVE_METHOD
value: RetrievalConfig
showMultiModalTip?: boolean
onChange: (value: RetrievalConfig) => void
}
}>
const RetrievalParamConfig: FC<Props> = ({
type,

View File

@ -9,11 +9,11 @@ import { useTranslation } from 'react-i18next'
import ActionButton from '@/app/components/base/action-button'
import { formatFileSize } from '@/utils/format'
type Props = {
type Props = Readonly<{
file: File | undefined
updateFile: (file?: File) => void
className?: string
}
}>
const Uploader: FC<Props> = ({ file, updateFile, className }) => {
const { t } = useTranslation()
const [dragging, setDragging] = useState(false)

View File

@ -3,14 +3,14 @@ import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { cn } from '@langgenius/dify-ui/cn'
import { Infotip } from '@/app/components/base/infotip'
type Props = {
type Props = Readonly<{
className?: string
isChecked: boolean
onChange: (isChecked: boolean) => void
label: string
labelClassName?: string
tooltip?: string
}
}>
export default function CheckboxWithLabel({
className = '',

View File

@ -7,13 +7,13 @@ import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
type Props = {
type Props = Readonly<{
payload: CrawlResultItemType
isChecked: boolean
isPreview: boolean
onCheckChange: (checked: boolean) => void
onPreview: () => void
}
}>
const CrawledResultItem: FC<Props> = ({
isPreview,

View File

@ -10,14 +10,14 @@ import CrawledResultItem from './crawled-result-item'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
className?: string
list: CrawlResultItem[]
checkedList: CrawlResultItem[]
onSelectedChange: (selected: CrawlResultItem[]) => void
onPreview: (payload: CrawlResultItem) => void
usedTime: number
}
}>
const CrawledResult: FC<Props> = ({
className = '',

View File

@ -4,11 +4,11 @@ import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { RowStruct } from '@/app/components/base/icons/src/public/other'
type Props = {
type Props = Readonly<{
className?: string
crawledNum: number
totalNum: number
}
}>
const Crawling: FC<Props> = ({
className = '',

View File

@ -4,11 +4,11 @@ import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
type Props = {
type Props = Readonly<{
className?: string
title: string
errorMsg?: string
}
}>
const ErrorMessage: FC<Props> = ({
className,

View File

@ -5,7 +5,7 @@ import * as React from 'react'
import { Infotip } from '@/app/components/base/infotip'
import Input from './text-input'
type Props = {
type Props = Readonly<{
className?: string
label: string
labelClassName?: string
@ -15,7 +15,7 @@ type Props = {
placeholder?: string
isNumber?: boolean
tooltip?: string
}
}>
const Field: FC<Props> = ({
className,

View File

@ -10,11 +10,11 @@ import { ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
className?: string
children: React.ReactNode
controlFoldOptions?: number
}
}>
const OptionsWrap: FC<Props> = ({
className = '',

View File

@ -3,12 +3,12 @@ import type { FC } from 'react'
import * as React from 'react'
import { useCallback } from 'react'
type Props = {
type Props = Readonly<{
value: string | number
onChange: (value: string | number) => void
placeholder?: string
isNumber?: boolean
}
}>
const MIN_VALUE = 0

View File

@ -9,10 +9,10 @@ import Input from './text-input'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
isRunning: boolean
onRun: (url: string) => void
}
}>
const UrlInput: FC<Props> = ({
isRunning,

View File

@ -19,14 +19,14 @@ import Options from './options'
const ERROR_I18N_PREFIX = 'errorMsg'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
onPreview: (payload: CrawlResultItem) => void
checkedCrawlResult: CrawlResultItem[]
onCheckedCrawlResultChange: (payload: CrawlResultItem[]) => void
onJobIdChange: (jobId: string) => void
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
}
}>
const Step = {
init: 'init',
running: 'running',

View File

@ -10,11 +10,11 @@ import Field from '../base/field'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
className?: string
payload: CrawlOptions
onChange: (payload: CrawlOptions) => void
}
}>
const Options: FC<Props> = ({
className = '',

View File

@ -16,7 +16,7 @@ import JinaReader from './jina-reader'
import NoData from './no-data'
import Watercrawl from './watercrawl'
type Props = {
type Props = Readonly<{
onPreview: (payload: CrawlResultItem) => void
checkedCrawlResult: CrawlResultItem[]
onCheckedCrawlResultChange: (payload: CrawlResultItem[]) => void
@ -25,7 +25,7 @@ type Props = {
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
authedDataSourceList: DataSourceAuth[]
}
}>
const Website: FC<Props> = ({
onPreview,

View File

@ -9,10 +9,10 @@ import { useDocLink } from '@/context/i18n'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
isRunning: boolean
onRun: (url: string) => void
}
}>
const UrlInput: FC<Props> = ({
isRunning,

View File

@ -19,14 +19,14 @@ import Options from './options'
const ERROR_I18N_PREFIX = 'errorMsg'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
onPreview: (payload: CrawlResultItem) => void
checkedCrawlResult: CrawlResultItem[]
onCheckedCrawlResultChange: (payload: CrawlResultItem[]) => void
onJobIdChange: (jobId: string) => void
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
}
}>
const Step = {
init: 'init',
running: 'running',

View File

@ -10,11 +10,11 @@ import Field from '../base/field'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
className?: string
payload: CrawlOptions
onChange: (payload: CrawlOptions) => void
}
}>
const Options: FC<Props> = ({
className = '',

View File

@ -10,10 +10,10 @@ import s from './index.module.css'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
onConfig: () => void
provider: DataSourceProvider
}
}>
const NoData: FC<Props> = ({
onConfig,

View File

@ -19,14 +19,14 @@ import Options from './options'
const ERROR_I18N_PREFIX = 'errorMsg'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
onPreview: (payload: CrawlResultItem) => void
checkedCrawlResult: CrawlResultItem[]
onCheckedCrawlResultChange: (payload: CrawlResultItem[]) => void
onJobIdChange: (jobId: string) => void
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
}
}>
const Step = {
init: 'init',
running: 'running',

View File

@ -10,11 +10,11 @@ import Field from '../base/field'
const I18N_PREFIX = 'stepOne.website'
type Props = {
type Props = Readonly<{
className?: string
payload: CrawlOptions
onChange: (payload: CrawlOptions) => void
}
}>
const Options: FC<Props> = ({
className = '',

View File

@ -10,13 +10,13 @@ import { useTranslation } from 'react-i18next'
import Input from '@/app/components/base/input'
import { renameDocumentName } from '@/service/datasets'
type Props = {
type Props = Readonly<{
datasetId: string
documentId: string
name: string
onClose: () => void
onSaved: () => void
}
}>
const RenameModal: FC<Props> = ({
documentId,

View File

@ -16,10 +16,10 @@ import { upload } from '@/service/base'
import { useFileUploadConfig } from '@/service/use-common'
import { Theme } from '@/types/app'
type Props = {
type Props = Readonly<{
file: FileItem | undefined
updateFile: (file?: FileItem) => void
}
}>
const CSVUploader: FC<Props> = ({ file, updateFile }) => {
const { t } = useTranslation()
const [dragging, setDragging] = useState(false)

View File

@ -44,9 +44,9 @@ import ModifyRetrievalModal from './modify-retrieval-modal'
const limit = 10
type Props = {
type Props = Readonly<{
datasetId: string
}
}>
const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
const { t } = useTranslation()

View File

@ -17,13 +17,13 @@ import { useDocLink } from '@/context/i18n'
import { ModelTypeEnum } from '../../header/account-setting/model-provider-page/declarations'
import { checkShowMultiModalTip } from '../settings/utils'
type Props = {
type Props = Readonly<{
indexMethod: string
value: RetrievalConfig
isShow: boolean
onHide: () => void
onSave: (value: RetrievalConfig) => void
}
}>
const ModifyRetrievalModal: FC<Props> = ({ indexMethod, value, isShow, onHide, onSave }) => {
const ref = useRef(null)
const { t } = useTranslation()

View File

@ -9,12 +9,12 @@ import DatasetCard from './dataset-card'
import DatasetCardSkeleton from './dataset-card-skeleton'
import NewDatasetCard from './new-dataset-card'
type Props = {
type Props = Readonly<{
tags: string[]
keywords: string
includeAll: boolean
onOpenTagManagement?: () => void
}
}>
const Datasets = ({
tags,

View File

@ -12,12 +12,12 @@ import DatePicker from '@/app/components/base/date-and-time-picker/date-picker'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import useTimestamp from '@/hooks/use-timestamp'
type Props = {
type Props = Readonly<{
className?: string
label?: string
value?: number
onChange: (date: number | null) => void
}
}>
const WrappedDatePicker = ({
className,
label,

View File

@ -7,12 +7,12 @@ import * as React from 'react'
import InputCombined from './input-combined'
import Label from './label'
type Props = {
type Props = Readonly<{
className?: string
payload: MetadataItemWithEdit
onChange: (value: MetadataItemWithEdit) => void
onRemove: () => void
}
}>
const AddRow: FC<Props> = ({
className,

View File

@ -10,12 +10,12 @@ import InputCombined from './input-combined'
import InputHasSetMultipleValue from './input-has-set-multiple-value'
import Label from './label'
type Props = {
type Props = Readonly<{
payload: MetadataItemWithEdit
onChange: (payload: MetadataItemWithEdit) => void
onRemove: (id: string) => void
onReset: (id: string) => void
}
}>
const EditMetadatabatchItem: FC<Props> = ({
payload,

View File

@ -7,9 +7,9 @@ import * as React from 'react'
import { useRef } from 'react'
import { useTranslation } from 'react-i18next'
type Props = {
type Props = Readonly<{
onReset: () => void
}
}>
const EditedBeacon: FC<Props> = ({
onReset,

View File

@ -14,14 +14,14 @@ import * as React from 'react'
import Datepicker from '../base/date-picker'
import { DataType } from '../types'
type Props = {
type Props = Readonly<{
className?: string
label: string
type: DataType
value: any
onChange: (value: any) => void
readOnly?: boolean
}
}>
const InputCombined: FC<Props> = ({
className: configClassName,

View File

@ -5,10 +5,10 @@ import { RiCloseLine } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
type Props = {
type Props = Readonly<{
onClear: () => void
readOnly?: boolean
}
}>
const InputHasSetMultipleValue: FC<Props> = ({
onClear,

View File

@ -3,11 +3,11 @@ import type { FC } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
type Props = {
type Props = Readonly<{
isDeleted?: boolean
className?: string
text: string
}
}>
const Label: FC<Props> = ({
isDeleted,

View File

@ -19,14 +19,14 @@ import AddedMetadataItem from './add-row'
import EditMetadataBatchItem from './edit-row'
const i18nPrefix = 'metadata.batchEditMetadata'
type Props = {
type Props = Readonly<{
datasetId: string
documentNum: number
list: MetadataItemInBatchEdit[]
onSave: (editedList: MetadataItemInBatchEdit[], addedList: MetadataItemInBatchEdit[], isApplyToAllSelectDocument: boolean) => void
onHide: () => void
onShowManage: () => void
}
}>
const EditMetadataBatchModal: FC<Props> = ({ datasetId, documentNum, list, onSave, onHide, onShowManage }) => {
const { t } = useTranslation()
const [templeList, setTempleList] = useState<MetadataItemWithEdit[]>(list)

View File

@ -7,12 +7,12 @@ import { useMemo } from 'react'
import { useBatchUpdateDocMetadata } from '@/service/knowledge/use-metadata'
import { UpdateType } from '../types'
type Props = {
type Props = Readonly<{
datasetId: string
docList: SimpleDocumentDetail[]
selectedDocumentIds?: string[]
onUpdate: () => void
}
}>
const useBatchEditDocumentMetadata = ({ datasetId, docList, selectedDocumentIds, onUpdate }: Props) => {
const [isShowEditModal, { setTrue: showEditModal, setFalse: hideEditModal }] = useBoolean(false)
const metaDataList: MetadataItemWithValue[][] = (() => {

View File

@ -10,11 +10,11 @@ import { useBatchUpdateDocMetadata, useCreateMetaData, useDatasetMetaData, useDo
import { DataType } from '../types'
import useCheckMetadataName from './use-check-metadata-name'
type Props = {
type Props = Readonly<{
datasetId: string
documentId: string
docDetail: FullDocumentDetail
}
}>
const useMetadataDocument = ({ datasetId, documentId, docDetail }: Props) => {
const { t } = useTranslation()
const { dataset } = useDatasetDetailContext()

View File

@ -11,12 +11,12 @@ import Field from './field'
const i18nPrefix = 'metadata.createMetadata'
export type Props = {
export type Props = Readonly<{
onClose?: () => void
onSave: (data: BuiltInMetadataItem) => void
hasBack?: boolean
onBack?: () => void
}
}>
export function CreateContent({
onClose = noop,

View File

@ -4,12 +4,12 @@ import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/pop
import * as React from 'react'
import { CreateContent } from './create-content'
type Props = {
type Props = Readonly<{
open: boolean
setOpen: (open: boolean) => void
trigger: React.ReactNode
popupLeft?: number
} & CreateContentProps
}> & CreateContentProps
export function CreateMetadataModal({
open,

View File

@ -38,7 +38,7 @@ import Field from './field'
const i18nPrefix = 'metadata.datasetMetadata'
type Props = {
type Props = Readonly<{
userMetadata: MetadataItemWithValueLength[]
builtInMetadata: BuiltInMetadataItem[]
isBuiltInEnabled: boolean
@ -47,7 +47,7 @@ type Props = {
onAdd: (payload: BuiltInMetadataItem) => void
onRename: (payload: MetadataItemWithValueLength) => void
onRemove: (metaDataId: string) => void
}
}>
type ItemProps = {
readonly?: boolean

View File

@ -2,11 +2,11 @@
import type { FC } from 'react'
import * as React from 'react'
type Props = {
type Props = Readonly<{
className?: string
label: string
children: React.ReactNode
}
}>
const Field: FC<Props> = ({
className,

View File

@ -2,10 +2,10 @@
import type { FC } from 'react'
import * as React from 'react'
type Props = {
type Props = Readonly<{
label: string
children: React.ReactNode
}
}>
const Field: FC<Props> = ({
label,

View File

@ -13,12 +13,12 @@ import NoData from './no-data'
const i18nPrefix = 'metadata.documentMetadata'
type Props = {
type Props = Readonly<{
datasetId: string
documentId: string
className?: string
docDetail: FullDocumentDetail
}
}>
const MetadataDocument: FC<Props> = ({
datasetId,
documentId,

View File

@ -14,7 +14,7 @@ import { DatasetMetadataPicker } from '../metadata-dataset/dataset-metadata-pick
import { DataType, isShowManageMetadataLocalStorageKey } from '../types'
import Field from './field'
type Props = {
type Props = Readonly<{
dataSetId: string
className?: string
noHeader?: boolean
@ -29,7 +29,7 @@ type Props = {
onDelete?: (item: MetadataItemWithValue) => void
onSelect?: (item: MetadataItemWithValue) => void
onAdd?: (item: BuiltInMetadataItem) => void
}
}>
const InfoGroup: FC<Props> = ({
dataSetId,

View File

@ -5,9 +5,9 @@ import { RiArrowRightLine } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
type Props = {
type Props = Readonly<{
onStart: () => void
}
}>
const NoData: FC<Props> = ({
onStart,