|
@@ -12,10 +12,11 @@ import type { DataSourceNotionPage } from '@/models/common'
|
|
|
import { DataSourceType } from '@/models/datasets'
|
|
|
import Button from '@/app/components/base/button'
|
|
|
import { NotionPageSelector } from '@/app/components/base/notion-page-selector'
|
|
|
+import { useDatasetDetailContext } from '@/context/dataset-detail'
|
|
|
|
|
|
type IStepOneProps = {
|
|
|
datasetId?: string
|
|
|
- dataSourceType: DataSourceType
|
|
|
+ dataSourceType?: DataSourceType
|
|
|
dataSourceTypeDisable: Boolean
|
|
|
hasConnection: boolean
|
|
|
onSetting: () => void
|
|
@@ -58,6 +59,7 @@ const StepOne = ({
|
|
|
notionPages = [],
|
|
|
updateNotionPages,
|
|
|
}: IStepOneProps) => {
|
|
|
+ const { dataset } = useDatasetDetailContext()
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
const [showFilePreview, setShowFilePreview] = useState(true)
|
|
|
const [currentNotionPage, setCurrentNotionPage] = useState<Page | undefined>()
|
|
@@ -77,56 +79,66 @@ const StepOne = ({
|
|
|
setCurrentNotionPage(undefined)
|
|
|
}
|
|
|
|
|
|
+ const shouldShowDataSourceTypeList = !datasetId || (datasetId && !dataset?.data_source_type)
|
|
|
+
|
|
|
return (
|
|
|
<div className='flex w-full h-full'>
|
|
|
<div className='grow overflow-y-auto relative'>
|
|
|
- <div className={s.stepHeader}>{t('datasetCreation.steps.one')}</div>
|
|
|
+ {
|
|
|
+ shouldShowDataSourceTypeList && (
|
|
|
+ <div className={s.stepHeader}>{t('datasetCreation.steps.one')}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
<div className={s.form}>
|
|
|
- <div className={s.dataSourceTypeList}>
|
|
|
- <div
|
|
|
- className={cn(
|
|
|
- s.dataSourceItem,
|
|
|
- dataSourceType === DataSourceType.FILE && s.active,
|
|
|
- dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,
|
|
|
- )}
|
|
|
- onClick={() => {
|
|
|
- if (dataSourceTypeDisable)
|
|
|
- return
|
|
|
- changeType(DataSourceType.FILE)
|
|
|
- hidePreview()
|
|
|
- }}
|
|
|
- >
|
|
|
- <span className={cn(s.datasetIcon)} />
|
|
|
- {t('datasetCreation.stepOne.dataSourceType.file')}
|
|
|
- </div>
|
|
|
- <div
|
|
|
- className={cn(
|
|
|
- s.dataSourceItem,
|
|
|
- dataSourceType === DataSourceType.NOTION && s.active,
|
|
|
- dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled,
|
|
|
- )}
|
|
|
- onClick={() => {
|
|
|
- if (dataSourceTypeDisable)
|
|
|
- return
|
|
|
- changeType(DataSourceType.NOTION)
|
|
|
- hidePreview()
|
|
|
- }}
|
|
|
- >
|
|
|
- <span className={cn(s.datasetIcon, s.notion)} />
|
|
|
- {t('datasetCreation.stepOne.dataSourceType.notion')}
|
|
|
- </div>
|
|
|
- <div
|
|
|
- className={cn(s.dataSourceItem, s.disabled, dataSourceType === DataSourceType.WEB && s.active)}
|
|
|
- // onClick={() => changeType(DataSourceType.WEB)}
|
|
|
- >
|
|
|
- <span className={s.comingTag}>Coming soon</span>
|
|
|
- <span className={cn(s.datasetIcon, s.web)} />
|
|
|
- {t('datasetCreation.stepOne.dataSourceType.web')}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ {
|
|
|
+ shouldShowDataSourceTypeList && (
|
|
|
+ <div className={s.dataSourceTypeList}>
|
|
|
+ <div
|
|
|
+ className={cn(
|
|
|
+ s.dataSourceItem,
|
|
|
+ dataSourceType === DataSourceType.FILE && s.active,
|
|
|
+ dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,
|
|
|
+ )}
|
|
|
+ onClick={() => {
|
|
|
+ if (dataSourceTypeDisable)
|
|
|
+ return
|
|
|
+ changeType(DataSourceType.FILE)
|
|
|
+ hidePreview()
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <span className={cn(s.datasetIcon)} />
|
|
|
+ {t('datasetCreation.stepOne.dataSourceType.file')}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={cn(
|
|
|
+ s.dataSourceItem,
|
|
|
+ dataSourceType === DataSourceType.NOTION && s.active,
|
|
|
+ dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled,
|
|
|
+ )}
|
|
|
+ onClick={() => {
|
|
|
+ if (dataSourceTypeDisable)
|
|
|
+ return
|
|
|
+ changeType(DataSourceType.NOTION)
|
|
|
+ hidePreview()
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <span className={cn(s.datasetIcon, s.notion)} />
|
|
|
+ {t('datasetCreation.stepOne.dataSourceType.notion')}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={cn(s.dataSourceItem, s.disabled, dataSourceType === DataSourceType.WEB && s.active)}
|
|
|
+ // onClick={() => changeType(DataSourceType.WEB)}
|
|
|
+ >
|
|
|
+ <span className={s.comingTag}>Coming soon</span>
|
|
|
+ <span className={cn(s.datasetIcon, s.web)} />
|
|
|
+ {t('datasetCreation.stepOne.dataSourceType.web')}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
{dataSourceType === DataSourceType.FILE && (
|
|
|
<>
|
|
|
- <FileUploader onFileUpdate={updateFile} file={file} />
|
|
|
+ <FileUploader onFileUpdate={updateFile} file={file} titleClassName={(!shouldShowDataSourceTypeList) ? 'mt-[30px] !mb-[44px] !text-lg !font-semibold !text-gray-900' : undefined} />
|
|
|
<Button disabled={!file} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
|
|
|
</>
|
|
|
)}
|