refactor: improve layout structure in StepOne component for better re… (#16209)

pull/16246/head
GuanMu 1 year ago committed by GitHub
parent a8879057c0
commit 106169ed7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -132,189 +132,191 @@ const StepOne = ({
}, [files, isShowVectorSpaceFull]) }, [files, isShowVectorSpaceFull])
return ( return (
<div className='flex w-full h-full'> <div className='w-full h-full overflow-x-auto'>
<div className='w-1/2 h-full overflow-y-auto relative'> <div className='flex w-full h-full min-w-[1440px]'>
<div className='flex justify-end'> <div className='w-1/2 h-full overflow-y-auto relative'>
<div className={classNames(s.form)}> <div className='flex justify-end'>
{ <div className={classNames(s.form)}>
shouldShowDataSourceTypeList && ( {
<div className={classNames(s.stepHeader, 'text-text-secondary system-md-semibold')}> shouldShowDataSourceTypeList && (
{t('datasetCreation.steps.one')} <div className={classNames(s.stepHeader, 'text-text-secondary system-md-semibold')}>
</div> {t('datasetCreation.steps.one')}
)
}
{
shouldShowDataSourceTypeList && (
<div className='grid grid-cols-3 mb-8 gap-4'>
<div
className={cn(
s.dataSourceItem,
'system-sm-medium',
dataSourceType === DataSourceType.FILE && s.active,
dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,
)}
onClick={() => {
if (dataSourceTypeDisable)
return
changeType(DataSourceType.FILE)
hideFilePreview()
hideNotionPagePreview()
}}
>
<span className={cn(s.datasetIcon)} />
<span
title={t('datasetCreation.stepOne.dataSourceType.file')}
className='truncate'
>
{t('datasetCreation.stepOne.dataSourceType.file')}
</span>
</div> </div>
<div )
className={cn( }
s.dataSourceItem, {
'system-sm-medium', shouldShowDataSourceTypeList && (
dataSourceType === DataSourceType.NOTION && s.active, <div className='grid grid-cols-3 mb-8 gap-4'>
dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled, <div
)} className={cn(
onClick={() => { s.dataSourceItem,
if (dataSourceTypeDisable) 'system-sm-medium',
return dataSourceType === DataSourceType.FILE && s.active,
changeType(DataSourceType.NOTION) dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,
hideFilePreview() )}
hideNotionPagePreview() onClick={() => {
}} if (dataSourceTypeDisable)
> return
<span className={cn(s.datasetIcon, s.notion)} /> changeType(DataSourceType.FILE)
<span hideFilePreview()
title={t('datasetCreation.stepOne.dataSourceType.notion')} hideNotionPagePreview()
className='truncate' }}
> >
{t('datasetCreation.stepOne.dataSourceType.notion')} <span className={cn(s.datasetIcon)} />
</span> <span
</div> title={t('datasetCreation.stepOne.dataSourceType.file')}
<div className='truncate'
className={cn( >
s.dataSourceItem, {t('datasetCreation.stepOne.dataSourceType.file')}
'system-sm-medium', </span>
dataSourceType === DataSourceType.WEB && s.active, </div>
dataSourceTypeDisable && dataSourceType !== DataSourceType.WEB && s.disabled, <div
)} className={cn(
onClick={() => changeType(DataSourceType.WEB)} s.dataSourceItem,
> 'system-sm-medium',
<span className={cn(s.datasetIcon, s.web)} /> dataSourceType === DataSourceType.NOTION && s.active,
<span dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled,
title={t('datasetCreation.stepOne.dataSourceType.web')} )}
className='truncate' onClick={() => {
if (dataSourceTypeDisable)
return
changeType(DataSourceType.NOTION)
hideFilePreview()
hideNotionPagePreview()
}}
> >
{t('datasetCreation.stepOne.dataSourceType.web')} <span className={cn(s.datasetIcon, s.notion)} />
</span> <span
</div> title={t('datasetCreation.stepOne.dataSourceType.notion')}
</div> className='truncate'
) >
} {t('datasetCreation.stepOne.dataSourceType.notion')}
{dataSourceType === DataSourceType.FILE && ( </span>
<> </div>
<FileUploader <div
fileList={files} className={cn(
titleClassName={!shouldShowDataSourceTypeList ? 'mt-[30px] !mb-[44px] !text-lg' : undefined} s.dataSourceItem,
prepareFileList={updateFileList} 'system-sm-medium',
onFileListUpdate={updateFileList} dataSourceType === DataSourceType.WEB && s.active,
onFileUpdate={updateFile} dataSourceTypeDisable && dataSourceType !== DataSourceType.WEB && s.disabled,
onPreview={updateCurrentFile} )}
notSupportBatchUpload={notSupportBatchUpload} onClick={() => changeType(DataSourceType.WEB)}
/> >
{isShowVectorSpaceFull && ( <span className={cn(s.datasetIcon, s.web)} />
<div className='max-w-[640px] mb-4'> <span
<VectorSpaceFull /> title={t('datasetCreation.stepOne.dataSourceType.web')}
className='truncate'
>
{t('datasetCreation.stepOne.dataSourceType.web')}
</span>
</div>
</div> </div>
)} )
<div className="flex justify-end gap-2 max-w-[640px]"> }
{/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */} {dataSourceType === DataSourceType.FILE && (
<Button disabled={nextDisabled} variant='primary' onClick={onStepChange}> <>
<span className="flex gap-0.5 px-[10px]"> <FileUploader
<span className="px-0.5">{t('datasetCreation.stepOne.button')}</span> fileList={files}
<RiArrowRightLine className="size-4" /> titleClassName={!shouldShowDataSourceTypeList ? 'mt-[30px] !mb-[44px] !text-lg' : undefined}
</span> prepareFileList={updateFileList}
</Button> onFileListUpdate={updateFileList}
</div> onFileUpdate={updateFile}
</> onPreview={updateCurrentFile}
)} notSupportBatchUpload={notSupportBatchUpload}
{dataSourceType === DataSourceType.NOTION && ( />
<> {isShowVectorSpaceFull && (
{!hasConnection && <NotionConnector onSetting={onSetting} />} <div className='max-w-[640px] mb-4'>
{hasConnection && ( <VectorSpaceFull />
<>
<div className='mb-8 w-[640px]'>
<NotionPageSelector
value={notionPages.map(page => page.page_id)}
onSelect={updateNotionPages}
onPreview={updateCurrentPage}
/>
</div> </div>
{isShowVectorSpaceFull && ( )}
<div className='max-w-[640px] mb-4'> <div className="flex justify-end gap-2 max-w-[640px]">
<VectorSpaceFull /> {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}
<Button disabled={nextDisabled} variant='primary' onClick={onStepChange}>
<span className="flex gap-0.5 px-[10px]">
<span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>
<RiArrowRightLine className="size-4" />
</span>
</Button>
</div>
</>
)}
{dataSourceType === DataSourceType.NOTION && (
<>
{!hasConnection && <NotionConnector onSetting={onSetting} />}
{hasConnection && (
<>
<div className='mb-8 w-[640px]'>
<NotionPageSelector
value={notionPages.map(page => page.page_id)}
onSelect={updateNotionPages}
onPreview={updateCurrentPage}
/>
</div> </div>
)} {isShowVectorSpaceFull && (
<div className="flex justify-end gap-2 max-w-[640px]"> <div className='max-w-[640px] mb-4'>
{/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */} <VectorSpaceFull />
<Button disabled={isShowVectorSpaceFull || !notionPages.length} variant='primary' onClick={onStepChange}> </div>
<span className="flex gap-0.5 px-[10px]"> )}
<span className="px-0.5">{t('datasetCreation.stepOne.button')}</span> <div className="flex justify-end gap-2 max-w-[640px]">
<RiArrowRightLine className="size-4" /> {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}
</span> <Button disabled={isShowVectorSpaceFull || !notionPages.length} variant='primary' onClick={onStepChange}>
</Button> <span className="flex gap-0.5 px-[10px]">
<span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>
<RiArrowRightLine className="size-4" />
</span>
</Button>
</div>
</>
)}
</>
)}
{dataSourceType === DataSourceType.WEB && (
<>
<div className={cn('mb-8 w-[640px]', !shouldShowDataSourceTypeList && 'mt-12')}>
<Website
onPreview={setCurrentWebsite}
checkedCrawlResult={websitePages}
onCheckedCrawlResultChange={updateWebsitePages}
onCrawlProviderChange={onWebsiteCrawlProviderChange}
onJobIdChange={onWebsiteCrawlJobIdChange}
crawlOptions={crawlOptions}
onCrawlOptionsChange={onCrawlOptionsChange}
/>
</div>
{isShowVectorSpaceFull && (
<div className='max-w-[640px] mb-4'>
<VectorSpaceFull />
</div> </div>
</> )}
)} <div className="flex justify-end gap-2 max-w-[640px]">
</> {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}
)} <Button disabled={isShowVectorSpaceFull || !websitePages.length} variant='primary' onClick={onStepChange}>
{dataSourceType === DataSourceType.WEB && ( <span className="flex gap-0.5 px-[10px]">
<> <span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>
<div className={cn('mb-8 w-[640px]', !shouldShowDataSourceTypeList && 'mt-12')}> <RiArrowRightLine className="size-4" />
<Website </span>
onPreview={setCurrentWebsite} </Button>
checkedCrawlResult={websitePages}
onCheckedCrawlResultChange={updateWebsitePages}
onCrawlProviderChange={onWebsiteCrawlProviderChange}
onJobIdChange={onWebsiteCrawlJobIdChange}
crawlOptions={crawlOptions}
onCrawlOptionsChange={onCrawlOptionsChange}
/>
</div>
{isShowVectorSpaceFull && (
<div className='max-w-[640px] mb-4'>
<VectorSpaceFull />
</div> </div>
)} </>
<div className="flex justify-end gap-2 max-w-[640px]"> )}
{/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */} {!datasetId && (
<Button disabled={isShowVectorSpaceFull || !websitePages.length} variant='primary' onClick={onStepChange}> <>
<span className="flex gap-0.5 px-[10px]"> <div className={s.dividerLine} />
<span className="px-0.5">{t('datasetCreation.stepOne.button')}</span> <span className="inline-flex items-center cursor-pointer text-[13px] leading-4 text-text-accent" onClick={modalShowHandle}>
<RiArrowRightLine className="size-4" /> <RiFolder6Line className="size-4 mr-1" />
</span> {t('datasetCreation.stepOne.emptyDatasetCreation')}
</Button> </span>
</div> </>
</> )}
)} </div>
{!datasetId && ( <EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} />
<>
<div className={s.dividerLine} />
<span className="inline-flex items-center cursor-pointer text-[13px] leading-4 text-text-accent" onClick={modalShowHandle}>
<RiFolder6Line className="size-4 mr-1" />
{t('datasetCreation.stepOne.emptyDatasetCreation')}
</span>
</>
)}
</div> </div>
<EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} />
</div> </div>
</div> <div className='w-1/2 h-full overflow-y-auto'>
<div className='w-1/2 h-full overflow-y-auto'> {currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}
{currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />} {currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />}
{currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />} {currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />}
{currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />} </div>
</div> </div>
</div> </div>
) )

Loading…
Cancel
Save