Commit 3f9af702 authored by JzoNg's avatar JzoNg

feat: update style of uploader

parent 68eb3126
...@@ -9,7 +9,6 @@ import { fetchFilePreview } from '@/service/common' ...@@ -9,7 +9,6 @@ import { fetchFilePreview } from '@/service/common'
type IProps = { type IProps = {
file?: File file?: File
notionPage?: any
hidePreview: () => void hidePreview: () => void
} }
...@@ -39,8 +38,10 @@ const FilePreview = ({ ...@@ -39,8 +38,10 @@ const FilePreview = ({
} }
useEffect(() => { useEffect(() => {
if (file) if (file) {
setLoading(true)
getPreviewContent(file.id) getPreviewContent(file.id)
}
}, [file]) }, [file])
return ( return (
......
.fileUploader { .fileUploader {
@apply mb-9; @apply mb-6;
} }
.fileUploader .title { .fileUploader .title {
@apply mb-2; @apply mb-2;
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
color: #344054; color: #344054;
} }
.fileUploader .tip { .fileUploader .tip {
@apply mt-2;
font-weight: 400; font-weight: 400;
font-size: 12px; font-size: 12px;
line-height: 26px; line-height: 18px;
color: #667085; color: #667085;
} }
.uploader { .uploader {
@apply relative box-border flex justify-center items-center; @apply relative box-border flex justify-center items-center mb-2;
flex-direction: column;
max-width: 640px; max-width: 640px;
height: 80px; height: 80px;
background: #F9FAFB; background: #F9FAFB;
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
color: #667085; color: #344054;
} }
.uploader.dragging { .uploader.dragging {
background: #F5F8FF; background: #F5F8FF;
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.uploader::before { .uploader .uploadIcon {
content: '';
display: block; display: block;
margin-right: 8px; margin-right: 8px;
width: 24px; width: 24px;
...@@ -53,14 +52,16 @@ ...@@ -53,14 +52,16 @@
} }
.file { .file {
@apply box-border relative flex items-center; @apply box-border relative flex items-center justify-between;
padding: 21px 24px 21px 64px; padding: 8px 12px 8px 8px;
max-width: 640px; max-width: 640px;
height: 80px; height: 40px;
background: #F9FAFB; background: #ffffff;
border: 1px solid #F2F4F7; border: 0.5px solid #EAECF0;
border-radius: 12px; box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);
border-radius: 8px;
overflow: hidden; overflow: hidden;
cursor: pointer;
} }
.progressbar { .progressbar {
position: absolute; position: absolute;
...@@ -69,36 +70,25 @@ ...@@ -69,36 +70,25 @@
height: 100%; height: 100%;
background-color: #F2F4F7; background-color: #F2F4F7;
} }
.file:hover {
background: #F5F8FF;
border: 1px solid #D1E0FF;
}
.file:hover .actionWrapper .buttonWrapper {
display: flex;
align-items: center;
}
.file:hover .actionWrapper .divider {
display: block;
}
.file.uploading, .file.uploading,
.file.uploading:hover { .file.uploading:hover {
background: #FCFCFD; background: #FCFCFD;
border: 1px solid #EAECF0; border: 0.5px solid #EAECF0;
} }
.file.uploading:hover .actionWrapper .percent { .file.active {
padding: 8px; background: #F5F8FF;
border: 1px solid #D1E0FF;
box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);
} }
.file.uploading:hover .actionWrapper .buttonWrapper { .file:hover {
display: flex; background: #F5F8FF;
align-items: center; border: 1px solid #D1E0FF;
box-shadow: 0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06);
} }
.fileIcon { .fileIcon {
@apply w-8 h-8 bg-center bg-no-repeat; @apply shrink-0 w-6 h-6 mr-2 bg-center bg-no-repeat;
position: absolute;
top: 24px;
left: 24px;
background-image: url(../assets/unknow.svg); background-image: url(../assets/unknow.svg);
background-size: 32px; background-size: 24px;
} }
.fileIcon.csv { .fileIcon.csv {
background-image: url(../assets/csv.svg); background-image: url(../assets/csv.svg);
...@@ -126,7 +116,7 @@ ...@@ -126,7 +116,7 @@
background-image: url(../assets/json.svg); background-image: url(../assets/json.svg);
} }
.fileInfo { .fileInfo {
@apply grow; @apply grow flex items-center;
z-index: 1; z-index: 1;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -134,46 +124,35 @@ ...@@ -134,46 +124,35 @@
} }
.filename { .filename {
font-weight: 500; font-weight: 500;
font-size: 14px; font-size: 13px;
line-height: 20px; line-height: 18px;
}
.name {
color: #1D2939; color: #1D2939;
line-height: 20px;
} }
.extension { .size {
color: #667085; @apply ml-3;
line-height: 20px; font-weight: 400;
}
.fileExtraInfo {
color: #667085;
font-size: 12px; font-size: 12px;
line-height: 18px; line-height: 18px;
color: #667085;
} }
.actionWrapper { .actionWrapper {
@apply flex items-center shrink-0; @apply flex items-center shrink-0;
z-index: 1; z-index: 1;
} }
.actionWrapper .percent { .actionWrapper .percent {
font-size: 16px; font-weight: 400;
line-height: 24px; font-size: 13px;
line-height: 18px;
color: #344054; color: #344054;
} }
.actionWrapper .divider {
display: none;
margin: 0 8px;
width: 1px;
height: 16px;
background: #FEE4E2;
}
.actionWrapper .remove { .actionWrapper .remove {
width: 32px; display: none;
height: 32px; width: 24px;
height: 24px;
background: center no-repeat url(../assets/trash.svg); background: center no-repeat url(../assets/trash.svg);
background-size: 16px; background-size: 16px;
cursor: pointer; cursor: pointer;
} }
.actionWrapper .buttonWrapper { .file:hover .actionWrapper .remove {
@apply flex items-center; display: block;
display: none;
} }
...@@ -6,13 +6,13 @@ import cn from 'classnames' ...@@ -6,13 +6,13 @@ import cn from 'classnames'
import s from './index.module.css' import s from './index.module.css'
import type { File as FileEntity } from '@/models/datasets' import type { File as FileEntity } from '@/models/datasets'
import { ToastContext } from '@/app/components/base/toast' import { ToastContext } from '@/app/components/base/toast'
import Button from '@/app/components/base/button'
import { upload } from '@/service/base' import { upload } from '@/service/base'
type IFileUploaderProps = { type IFileUploaderProps = {
file?: FileEntity files: FileEntity[]
onFileUpdate: (file?: FileEntity) => void onFileUpdate: (file?: FileEntity) => void
onPreview: (file: FileEntity) => void
} }
const ACCEPTS = [ const ACCEPTS = [
...@@ -27,9 +27,9 @@ const ACCEPTS = [ ...@@ -27,9 +27,9 @@ const ACCEPTS = [
'.csv', '.csv',
] ]
const MAX_SIZE = 15 * 1024 * 1024 const MAX_SIZE = 10 * 1024 * 1024
const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { const FileUploader = ({ files, onFileUpdate, onPreview }: IFileUploaderProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const [dragging, setDragging] = useState(false) const [dragging, setDragging] = useState(false)
...@@ -49,10 +49,6 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -49,10 +49,6 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
const arr = currentFile.name.split('.') const arr = currentFile.name.split('.')
return arr[arr.length - 1] return arr[arr.length - 1]
} }
const getFileName = (name: string) => {
const arr = name.split('.')
return arr.slice(0, -1).join()
}
const getFileSize = (size: number) => { const getFileSize = (size: number) => {
if (size / 1024 < 10) if (size / 1024 < 10)
return `${(size / 1024).toFixed(2)}KB` return `${(size / 1024).toFixed(2)}KB`
...@@ -83,6 +79,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -83,6 +79,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
const currentXHR = uploadPromise.current const currentXHR = uploadPromise.current
currentXHR.abort() currentXHR.abort()
} }
// TODO
const fileUpload = async (file?: File) => { const fileUpload = async (file?: File) => {
if (!file) if (!file)
return return
...@@ -133,6 +130,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -133,6 +130,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) e.target === dragRef.current && setDragging(false)
} }
// TODO
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
...@@ -153,6 +151,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -153,6 +151,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
if (fileUploader.current) if (fileUploader.current)
fileUploader.current.click() fileUploader.current.click()
} }
// TODO
const removeFile = () => { const removeFile = () => {
if (fileUploader.current) if (fileUploader.current)
fileUploader.current.value = '' fileUploader.current.value = ''
...@@ -160,6 +159,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -160,6 +159,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
setCurrentFile(undefined) setCurrentFile(undefined)
onFileUpdate() onFileUpdate()
} }
// TODO
const fileChangeHandle = (e: React.ChangeEvent<HTMLInputElement>) => { const fileChangeHandle = (e: React.ChangeEvent<HTMLInputElement>) => {
const currentFile = e.target.files?.[0] const currentFile = e.target.files?.[0]
onFileUpdate() onFileUpdate()
...@@ -183,83 +183,80 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { ...@@ -183,83 +183,80 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => {
<div className={s.fileUploader}> <div className={s.fileUploader}>
<input <input
ref={fileUploader} ref={fileUploader}
id="fileUploader"
style={{ display: 'none' }} style={{ display: 'none' }}
type="file" type="file"
id="fileUploader" multiple
accept={ACCEPTS.join(',')} accept={ACCEPTS.join(',')}
onChange={fileChangeHandle} onChange={fileChangeHandle}
/> />
<div className={s.title}>{t('datasetCreation.stepOne.uploader.title')}</div> <div className={s.title}>{t('datasetCreation.stepOne.uploader.title')}</div>
<div ref={dropRef}> <div ref={dropRef} className={cn(s.uploader, dragging && s.dragging)}>
{!currentFile && !file && ( <div className='flex justify-center items-center h-6 mb-2'>
<div className={cn(s.uploader, dragging && s.dragging)}> <span className={s.uploadIcon}/>
<span>{t('datasetCreation.stepOne.uploader.button')}</span> <span>{t('datasetCreation.stepOne.uploader.button')}</span>
<label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label> <label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label>
{dragging && <div ref={dragRef} className={s.draggingCover}/>} </div>
<div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip')}</div>
{dragging && <div ref={dragRef} className={s.draggingCover}/>}
</div>
<div className={s.fileList}>
{currentFile && (
<div
// onClick={() => onPreview(currentFile)}
className={cn(
s.file,
uploading && s.uploading,
// s.active,
)}
>
{uploading && (
<div className={s.progressbar} style={{ width: `${percent}%` }}/>
)}
<div className={s.fileInfo}>
<div className={cn(s.fileIcon, s[getFileType(currentFile)])}/>
<div className={s.filename}>{currentFile.name}</div>
<div className={s.size}>{getFileSize(currentFile.size)}</div>
</div>
<div className={s.actionWrapper}>
{uploading && (
<div className={s.percent}>{`${percent}%`}</div>
)}
{!uploading && (
<div className={s.remove} onClick={removeFile}/>
)}
</div>
</div> </div>
)} )}
</div> </div>
{currentFile && ( {/* TODO */}
<div className={cn(s.file, uploading && s.uploading)}> {!currentFile && files[0] && (
<div
// onClick={() => onPreview(currentFile)}
className={cn(
s.file,
uploading && s.uploading,
s.active,
)}
>
{uploading && ( {uploading && (
<div className={s.progressbar} style={{ width: `${percent}%` }}/> <div className={s.progressbar} style={{ width: `${percent}%` }}/>
)} )}
<div className={cn(s.fileIcon, s[getFileType(currentFile)])}/>
<div className={s.fileInfo}> <div className={s.fileInfo}>
<div className={s.filename}> <div className={cn(s.fileIcon, s[getFileType(files[0])])}/>
<span className={s.name}>{getFileName(currentFile.name)}</span> <div className={s.filename}>{files[0].name}</div>
<span className={s.extension}>{`.${getFileType(currentFile)}`}</span> <div className={s.size}>{getFileSize(files[0].size)}</div>
</div>
<div className={s.fileExtraInfo}>
<span className={s.size}>{getFileSize(currentFile.size)}</span>
<span className={s.error}></span>
</div>
</div> </div>
<div className={s.actionWrapper}> <div className={s.actionWrapper}>
{uploading && ( {uploading && (
<> <div className={s.percent}>{`${percent}%`}</div>
<div className={s.percent}>{`${percent}%`}</div>
<div className={s.divider}/>
<div className={s.buttonWrapper}>
<Button className={cn(s.button, 'ml-2 !h-8 bg-white')} onClick={abort}>{t('datasetCreation.stepOne.uploader.cancel')}</Button>
</div>
</>
)} )}
{!uploading && ( {!uploading && (
<>
<div className={s.buttonWrapper}>
<Button className={cn(s.button, 'ml-2 !h-8 bg-white')} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.change')}</Button>
<div className={s.divider}/>
<div className={s.remove} onClick={removeFile}/>
</div>
</>
)}
</div>
</div>
)}
{!currentFile && file && (
<div className={cn(s.file)}>
<div className={cn(s.fileIcon, s[file.extension])}/>
<div className={s.fileInfo}>
<div className={s.filename}>
<span className={s.name}>{getFileName(file.name)}</span>
<span className={s.extension}>{`.${file.extension}`}</span>
</div>
<div className={s.fileExtraInfo}>
<span className={s.size}>{getFileSize(file.size)}</span>
<span className={s.error}></span>
</div>
</div>
<div className={s.actionWrapper}>
<div className={s.buttonWrapper}>
<Button className={cn(s.button, 'ml-2 !h-8 bg-white')} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.change')}</Button>
<div className={s.divider}/>
<div className={s.remove} onClick={removeFile}/> <div className={s.remove} onClick={removeFile}/>
</div> )}
</div> </div>
</div> </div>
)} )}
<div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip')}</div>
</div> </div>
) )
} }
......
...@@ -30,7 +30,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { ...@@ -30,7 +30,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE) const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE)
const [step, setStep] = useState(1) const [step, setStep] = useState(1)
const [indexingTypeCache, setIndexTypeCache] = useState('') const [indexingTypeCache, setIndexTypeCache] = useState('')
const [file, setFile] = useState<File | undefined>() const [fileList, setFiles] = useState<File[]>([])
const [result, setResult] = useState<createDocumentResponse | undefined>() const [result, setResult] = useState<createDocumentResponse | undefined>()
const [hasError, setHasError] = useState(false) const [hasError, setHasError] = useState(false)
...@@ -39,8 +39,14 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { ...@@ -39,8 +39,14 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
setNotionPages(value) setNotionPages(value)
} }
// TODO
const updateFile = (file?: File) => { const updateFile = (file?: File) => {
setFile(file) if (file) {
setFiles([
...fileList,
file,
])
}
} }
const updateIndexingTypeCache = (type: string) => { const updateIndexingTypeCache = (type: string) => {
setIndexTypeCache(type) setIndexTypeCache(type)
...@@ -104,7 +110,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { ...@@ -104,7 +110,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
dataSourceType={dataSourceType} dataSourceType={dataSourceType}
dataSourceTypeDisable={!!detail?.data_source_type} dataSourceTypeDisable={!!detail?.data_source_type}
changeType={setDataSourceType} changeType={setDataSourceType}
file={file} files={fileList}
updateFile={updateFile} updateFile={updateFile}
notionPages={notionPages} notionPages={notionPages}
updateNotionPages={updateNotionPages} updateNotionPages={updateNotionPages}
...@@ -116,7 +122,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { ...@@ -116,7 +122,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
indexingType={detail?.indexing_technique || ''} indexingType={detail?.indexing_technique || ''}
datasetId={datasetId} datasetId={datasetId}
dataSourceType={dataSourceType} dataSourceType={dataSourceType}
file={file} files={fileList}
notionPages={notionPages} notionPages={notionPages}
onStepChange={changeStep} onStepChange={changeStep}
updateIndexingTypeCache={updateIndexingTypeCache} updateIndexingTypeCache={updateIndexingTypeCache}
......
...@@ -19,7 +19,7 @@ type IStepOneProps = { ...@@ -19,7 +19,7 @@ type IStepOneProps = {
dataSourceTypeDisable: Boolean dataSourceTypeDisable: Boolean
hasConnection: boolean hasConnection: boolean
onSetting: () => void onSetting: () => void
file?: File files: File[]
updateFile: (file?: File) => void updateFile: (file?: File) => void
notionPages?: any[] notionPages?: any[]
updateNotionPages: (value: any[]) => void updateNotionPages: (value: any[]) => void
...@@ -53,26 +53,29 @@ const StepOne = ({ ...@@ -53,26 +53,29 @@ const StepOne = ({
hasConnection, hasConnection,
onSetting, onSetting,
onStepChange, onStepChange,
file, files,
updateFile, updateFile,
notionPages = [], notionPages = [],
updateNotionPages, updateNotionPages,
}: IStepOneProps) => { }: IStepOneProps) => {
const [showModal, setShowModal] = useState(false) const [showModal, setShowModal] = useState(false)
const [showFilePreview, setShowFilePreview] = useState(true) const [currentFile, setCurrentFile] = useState<File | undefined>()
const [currentNotionPage, setCurrentNotionPage] = useState<Page | undefined>() const [currentNotionPage, setCurrentNotionPage] = useState<Page | undefined>()
const { t } = useTranslation() const { t } = useTranslation()
const hidePreview = () => setShowFilePreview(false)
const modalShowHandle = () => setShowModal(true) const modalShowHandle = () => setShowModal(true)
const modalCloseHandle = () => setShowModal(false) const modalCloseHandle = () => setShowModal(false)
const updateCurrentFile = (file: File) => {
setCurrentFile(file)
}
const hideFilePreview = () => {
setCurrentNotionPage(undefined)
}
const updateCurrentPage = (page: Page) => { const updateCurrentPage = (page: Page) => {
setCurrentNotionPage(page) setCurrentNotionPage(page)
} }
const hideNotionPagePreview = () => { const hideNotionPagePreview = () => {
setCurrentNotionPage(undefined) setCurrentNotionPage(undefined)
} }
...@@ -93,7 +96,8 @@ const StepOne = ({ ...@@ -93,7 +96,8 @@ const StepOne = ({
if (dataSourceTypeDisable) if (dataSourceTypeDisable)
return return
changeType(DataSourceType.FILE) changeType(DataSourceType.FILE)
hidePreview() hideFilePreview()
hideNotionPagePreview()
}} }}
> >
<span className={cn(s.datasetIcon)} /> <span className={cn(s.datasetIcon)} />
...@@ -109,7 +113,8 @@ const StepOne = ({ ...@@ -109,7 +113,8 @@ const StepOne = ({
if (dataSourceTypeDisable) if (dataSourceTypeDisable)
return return
changeType(DataSourceType.NOTION) changeType(DataSourceType.NOTION)
hidePreview() hideFilePreview()
hideNotionPagePreview()
}} }}
> >
<span className={cn(s.datasetIcon, s.notion)} /> <span className={cn(s.datasetIcon, s.notion)} />
...@@ -126,8 +131,9 @@ const StepOne = ({ ...@@ -126,8 +131,9 @@ const StepOne = ({
</div> </div>
{dataSourceType === DataSourceType.FILE && ( {dataSourceType === DataSourceType.FILE && (
<> <>
<FileUploader onFileUpdate={updateFile} file={file} /> <FileUploader onFileUpdate={updateFile} onPreview={updateCurrentFile} files={files} />
<Button disabled={!file} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button> {/* TODO */}
<Button disabled={!files.length} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
</> </>
)} )}
{dataSourceType === DataSourceType.NOTION && ( {dataSourceType === DataSourceType.NOTION && (
...@@ -152,7 +158,7 @@ const StepOne = ({ ...@@ -152,7 +158,7 @@ const StepOne = ({
</div> </div>
<EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} /> <EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} />
</div> </div>
{file && showFilePreview && <FilePreview file={file} hidePreview={hidePreview} />} {currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}
{currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />} {currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />}
</div> </div>
) )
......
...@@ -35,7 +35,7 @@ type StepTwoProps = { ...@@ -35,7 +35,7 @@ type StepTwoProps = {
datasetId?: string datasetId?: string
indexingType?: string indexingType?: string
dataSourceType: DataSourceType dataSourceType: DataSourceType
file?: File files: File[]
notionPages?: Page[] notionPages?: Page[]
onStepChange?: (delta: number) => void onStepChange?: (delta: number) => void
updateIndexingTypeCache?: (type: string) => void updateIndexingTypeCache?: (type: string) => void
...@@ -61,7 +61,7 @@ const StepTwo = ({ ...@@ -61,7 +61,7 @@ const StepTwo = ({
datasetId, datasetId,
indexingType, indexingType,
dataSourceType, dataSourceType,
file, files,
notionPages = [], notionPages = [],
onStepChange, onStepChange,
updateIndexingTypeCache, updateIndexingTypeCache,
...@@ -210,8 +210,7 @@ const StepTwo = ({ ...@@ -210,8 +210,7 @@ const StepTwo = ({
info_list: { info_list: {
data_source_type: dataSourceType, data_source_type: dataSourceType,
file_info_list: { file_info_list: {
// TODO multi files file_ids: files.map(file => file.id),
file_ids: [file?.id || ''],
}, },
}, },
indexing_technique: getIndexing_technique(), indexing_technique: getIndexing_technique(),
...@@ -252,8 +251,7 @@ const StepTwo = ({ ...@@ -252,8 +251,7 @@ const StepTwo = ({
} as CreateDocumentReq } as CreateDocumentReq
if (dataSourceType === DataSourceType.FILE) { if (dataSourceType === DataSourceType.FILE) {
params.data_source.info_list.file_info_list = { params.data_source.info_list.file_info_list = {
// TODO multi files file_ids: files.map(file => file.id),
file_ids: [file?.id || ''],
} }
} }
if (dataSourceType === DataSourceType.NOTION) if (dataSourceType === DataSourceType.NOTION)
...@@ -525,15 +523,21 @@ const StepTwo = ({ ...@@ -525,15 +523,21 @@ const StepTwo = ({
<Link className='text-[#155EEF]' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link> <Link className='text-[#155EEF]' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link>
</div> </div>
)} )}
{/* TODO multi files */}
<div className={s.source}> <div className={s.source}>
<div className={s.sourceContent}> <div className={s.sourceContent}>
{dataSourceType === DataSourceType.FILE && ( {dataSourceType === DataSourceType.FILE && (
<> <>
<div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.fileSource')}</div> <div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.fileSource')}</div>
<div className='flex items-center text-sm leading-6 font-medium text-gray-800'> <div className='flex items-center text-sm leading-6 font-medium text-gray-800'>
<span className={cn(s.fileIcon, file && s[file.extension])} /> <span className={cn(s.fileIcon, files.length && s[files[0].extension])} />
{getFileName(file?.name || '')} {getFileName(files[0].name || '')}
{files.length > 1 && (
<span className={s.sourceCount}>
<span>{t('datasetCreation.stepTwo.other')}</span>
<span>{files.length - 1}</span>
<span>{t('datasetCreation.stepTwo.fileUnit')}</span>
</span>
)}
</div> </div>
</> </>
)} )}
......
...@@ -85,7 +85,7 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => { ...@@ -85,7 +85,7 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => {
indexingType={indexingTechnique || ''} indexingType={indexingTechnique || ''}
isSetting isSetting
documentDetail={documentDetail} documentDetail={documentDetail}
file={documentDetail.data_source_info.upload_file} files={[documentDetail.data_source_info.upload_file]}
onSave={saveHandler} onSave={saveHandler}
onCancel={cancelHandler} onCancel={cancelHandler}
/> />
......
...@@ -23,7 +23,7 @@ const translation = { ...@@ -23,7 +23,7 @@ const translation = {
title: 'Upload text file', title: 'Upload text file',
button: 'Drag and drop file, or', button: 'Drag and drop file, or',
browse: 'Browse', browse: 'Browse',
tip: 'Supports txt, html, markdown, xlsx, and pdf.', tip: 'Supports txt, html, markdown, xlsx, and pdf. Max 10MB each.',
validation: { validation: {
typeError: 'File type not supported', typeError: 'File type not supported',
size: 'File too large. Maximum is 15MB', size: 'File too large. Maximum is 15MB',
......
...@@ -23,7 +23,7 @@ const translation = { ...@@ -23,7 +23,7 @@ const translation = {
title: '上传文本文件', title: '上传文本文件',
button: '拖拽文件至此,或者', button: '拖拽文件至此,或者',
browse: '选择文件', browse: '选择文件',
tip: '已支持 TXT, HTML, Markdown, PDF, XLSX', tip: '已支持 TXT、 HTML、 Markdown、 PDF、 XLSX,每个文件不超过 10 MB。',
validation: { validation: {
typeError: '文件类型不支持', typeError: '文件类型不支持',
size: '文件太大了,不能超过 15MB', size: '文件太大了,不能超过 15MB',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment