diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx index e44d371b6..2db9b7083 100644 --- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx +++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx @@ -93,7 +93,7 @@ const DatasetDetailLayout: FC = (props) => { const pathname = usePathname() const hideSideBar = /documents\/create$/.test(pathname) const { t } = useTranslation() - const { data: datasetRes, error } = useSWR({ + const { data: datasetRes, error, mutate: mutateDatasetRes } = useSWR({ action: 'fetchDataDetail', datasetId, }, apiParams => fetchDataDetail(apiParams.datasetId)) @@ -168,6 +168,7 @@ const DatasetDetailLayout: FC = (props) => { mutateDatasetRes(), }}>
{children}
diff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsx index 109424475..178bd237e 100644 --- a/web/app/components/datasets/create/file-uploader/index.tsx +++ b/web/app/components/datasets/create/file-uploader/index.tsx @@ -12,6 +12,7 @@ import { upload } from '@/service/base' type IFileUploaderProps = { file?: FileEntity + titleClassName?: string onFileUpdate: (file?: FileEntity) => void } @@ -29,7 +30,7 @@ const ACCEPTS = [ const MAX_SIZE = 15 * 1024 * 1024 -const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { +const FileUploader = ({ file, onFileUpdate, titleClassName }: IFileUploaderProps) => { const { t } = useTranslation() const { notify } = useContext(ToastContext) const [dragging, setDragging] = useState(false) @@ -189,7 +190,7 @@ const FileUploader = ({ file, onFileUpdate }: IFileUploaderProps) => { accept={ACCEPTS.join(',')} onChange={fileChangeHandle} /> -
{t('datasetCreation.stepOne.uploader.title')}
+
{t('datasetCreation.stepOne.uploader.title')}
{!currentFile && !file && (
diff --git a/web/app/components/datasets/create/step-one/index.tsx b/web/app/components/datasets/create/step-one/index.tsx index bec16f57d..aae31bbcf 100644 --- a/web/app/components/datasets/create/step-one/index.tsx +++ b/web/app/components/datasets/create/step-one/index.tsx @@ -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() @@ -77,56 +79,66 @@ const StepOne = ({ setCurrentNotionPage(undefined) } + const shouldShowDataSourceTypeList = !datasetId || (datasetId && !dataset?.data_source_type) + return (
-
{t('datasetCreation.steps.one')}
+ { + shouldShowDataSourceTypeList && ( +
{t('datasetCreation.steps.one')}
+ ) + }
-
-
{ - if (dataSourceTypeDisable) - return - changeType(DataSourceType.FILE) - hidePreview() - }} - > - - {t('datasetCreation.stepOne.dataSourceType.file')} -
-
{ - if (dataSourceTypeDisable) - return - changeType(DataSourceType.NOTION) - hidePreview() - }} - > - - {t('datasetCreation.stepOne.dataSourceType.notion')} -
-
changeType(DataSourceType.WEB)} - > - Coming soon - - {t('datasetCreation.stepOne.dataSourceType.web')} -
-
+ { + shouldShowDataSourceTypeList && ( +
+
{ + if (dataSourceTypeDisable) + return + changeType(DataSourceType.FILE) + hidePreview() + }} + > + + {t('datasetCreation.stepOne.dataSourceType.file')} +
+
{ + if (dataSourceTypeDisable) + return + changeType(DataSourceType.NOTION) + hidePreview() + }} + > + + {t('datasetCreation.stepOne.dataSourceType.notion')} +
+
changeType(DataSourceType.WEB)} + > + Coming soon + + {t('datasetCreation.stepOne.dataSourceType.web')} +
+
+ ) + } {dataSourceType === DataSourceType.FILE && ( <> - + )} diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index c1e13d773..8635aefb3 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -24,6 +24,7 @@ import { formatNumber } from '@/utils/format' import type { DataSourceNotionPage } from '@/models/common' import { DataSourceType } from '@/models/datasets' import NotionIcon from '@/app/components/base/notion-icon' +import { useDatasetDetailContext } from '@/context/dataset-detail' type Page = DataSourceNotionPage & { workspace_id: string } @@ -70,6 +71,7 @@ const StepTwo = ({ onCancel, }: StepTwoProps) => { const { t } = useTranslation() + const { mutateDatasetRes } = useDatasetDetailContext() const scrollRef = useRef(null) const [scrolled, setScrolled] = useState(false) const previewScrollRef = useRef(null) @@ -312,6 +314,8 @@ const StepTwo = ({ updateIndexingTypeCache && updateIndexingTypeCache(indexType) updateResultCache && updateResultCache(res) } + if (mutateDatasetRes) + mutateDatasetRes() onStepChange && onStepChange(+1) isSetting && onSave && onSave() } diff --git a/web/app/components/datasets/documents/index.tsx b/web/app/components/datasets/documents/index.tsx index 4a4c21f21..0f4a97248 100644 --- a/web/app/components/datasets/documents/index.tsx +++ b/web/app/components/datasets/documents/index.tsx @@ -220,7 +220,7 @@ const Documents: FC = ({ datasetId }) => { ? : total > 0 ? - : + : } {/* Show Pagination only if the total is more than the limit */} {(total && total > limit) diff --git a/web/context/dataset-detail.ts b/web/context/dataset-detail.ts index 9718ef279..de046ce7a 100644 --- a/web/context/dataset-detail.ts +++ b/web/context/dataset-detail.ts @@ -1,7 +1,7 @@ import { createContext, useContext } from 'use-context-selector' import type { DataSet } from '@/models/datasets' -const DatasetDetailContext = createContext<{ indexingTechnique?: string; dataset?: DataSet }>({}) +const DatasetDetailContext = createContext<{ indexingTechnique?: string; dataset?: DataSet; mutateDatasetRes?: () => void }>({}) export const useDatasetDetailContext = () => useContext(DatasetDetailContext)