refactor: Remove unused file support types logic from CreateFormPipeline component

This commit is contained in:
twwu
2025-07-09 14:44:56 +08:00
parent 4a8061d14c
commit 4ea4d227c6
2 changed files with 9 additions and 38 deletions

View File

@ -1,12 +1,10 @@
import React, { useEffect, useMemo, useRef } from 'react'
import { type OnlineDriveFile, OnlineDriveFileType } from '@/models/pipeline'
import React, { useEffect, useRef } from 'react'
import type { OnlineDriveFile } from '@/models/pipeline'
import Item from './item'
import EmptyFolder from './empty-folder'
import EmptySearchResult from './empty-search-result'
import Loading from '@/app/components/base/loading'
import { RiLoader2Line } from '@remixicon/react'
import { useFileSupportTypes } from '@/service/use-common'
import { getFileExtension } from './utils'
import { useDataSourceStore } from '../../../store'
type FileListProps = {
@ -64,11 +62,6 @@ const List = ({
const isPartLoading = isLoading && fileList.length > 0
const isEmptyFolder = !isLoading && fileList.length === 0 && keywords.length === 0
const isSearchResultEmpty = !isLoading && fileList.length === 0 && keywords.length > 0
const { data: supportFileTypesRes } = useFileSupportTypes()
const supportedFileTypes = useMemo(() => {
if (!supportFileTypesRes) return []
return Array.from(new Set(supportFileTypesRes.allowed_extensions.map(item => item.toLowerCase())))
}, [supportFileTypesRes])
return (
<div className='grow overflow-hidden p-1 pt-0'>
@ -92,14 +85,11 @@ const List = ({
{
fileList.map((file) => {
const isSelected = selectedFileList.includes(file.key)
const extension = getFileExtension(file.key)
const disabled = file.type === OnlineDriveFileType.file && !supportedFileTypes.includes(extension)
return (
<Item
key={file.key}
file={file}
isSelected={isSelected}
disabled={disabled}
onSelect={handleSelectFile}
onOpen={handleOpenFolder}
isMultipleChoice={!isInPipeline}