Commit 0ee76706 authored by StyleZhang's avatar StyleZhang

fix: dataset detail context update

parent eac26f69
...@@ -59,7 +59,7 @@ const StepOne = ({ ...@@ -59,7 +59,7 @@ const StepOne = ({
notionPages = [], notionPages = [],
updateNotionPages, updateNotionPages,
}: IStepOneProps) => { }: IStepOneProps) => {
const { dataset, mutateDatasetRes } = useDatasetDetailContext() const { dataset } = useDatasetDetailContext()
const [showModal, setShowModal] = useState(false) const [showModal, setShowModal] = useState(false)
const [showFilePreview, setShowFilePreview] = useState(true) const [showFilePreview, setShowFilePreview] = useState(true)
const [currentNotionPage, setCurrentNotionPage] = useState<Page | undefined>() const [currentNotionPage, setCurrentNotionPage] = useState<Page | undefined>()
...@@ -79,12 +79,6 @@ const StepOne = ({ ...@@ -79,12 +79,6 @@ const StepOne = ({
setCurrentNotionPage(undefined) setCurrentNotionPage(undefined)
} }
const handleStepChange = () => {
if (mutateDatasetRes)
mutateDatasetRes()
onStepChange()
}
const shouldShowDataSourceTypeList = !datasetId || (datasetId && !dataset?.data_source_type) const shouldShowDataSourceTypeList = !datasetId || (datasetId && !dataset?.data_source_type)
return ( return (
...@@ -145,7 +139,7 @@ const StepOne = ({ ...@@ -145,7 +139,7 @@ const StepOne = ({
{dataSourceType === DataSourceType.FILE && ( {dataSourceType === DataSourceType.FILE && (
<> <>
<FileUploader onFileUpdate={updateFile} file={file} titleClassName={(!shouldShowDataSourceTypeList) ? 'mt-[30px] !mb-[44px] !text-lg !font-semibold !text-gray-900' : undefined} /> <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={handleStepChange}>{t('datasetCreation.stepOne.button')}</Button> <Button disabled={!file} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
</> </>
)} )}
{dataSourceType === DataSourceType.NOTION && ( {dataSourceType === DataSourceType.NOTION && (
...@@ -156,7 +150,7 @@ const StepOne = ({ ...@@ -156,7 +150,7 @@ const StepOne = ({
<div className='mb-8 w-[640px]'> <div className='mb-8 w-[640px]'>
<NotionPageSelector value={notionPages.map(page => page.page_id)} onSelect={updateNotionPages} onPreview={updateCurrentPage} /> <NotionPageSelector value={notionPages.map(page => page.page_id)} onSelect={updateNotionPages} onPreview={updateCurrentPage} />
</div> </div>
<Button disabled={!notionPages.length} className={s.submitButton} type='primary' onClick={handleStepChange}>{t('datasetCreation.stepOne.button')}</Button> <Button disabled={!notionPages.length} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
</> </>
)} )}
</> </>
......
...@@ -24,6 +24,7 @@ import { formatNumber } from '@/utils/format' ...@@ -24,6 +24,7 @@ import { formatNumber } from '@/utils/format'
import type { DataSourceNotionPage } from '@/models/common' import type { DataSourceNotionPage } from '@/models/common'
import { DataSourceType } from '@/models/datasets' import { DataSourceType } from '@/models/datasets'
import NotionIcon from '@/app/components/base/notion-icon' import NotionIcon from '@/app/components/base/notion-icon'
import { useDatasetDetailContext } from '@/context/dataset-detail'
type Page = DataSourceNotionPage & { workspace_id: string } type Page = DataSourceNotionPage & { workspace_id: string }
...@@ -70,6 +71,7 @@ const StepTwo = ({ ...@@ -70,6 +71,7 @@ const StepTwo = ({
onCancel, onCancel,
}: StepTwoProps) => { }: StepTwoProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const { mutateDatasetRes } = useDatasetDetailContext()
const scrollRef = useRef<HTMLDivElement>(null) const scrollRef = useRef<HTMLDivElement>(null)
const [scrolled, setScrolled] = useState(false) const [scrolled, setScrolled] = useState(false)
const previewScrollRef = useRef<HTMLDivElement>(null) const previewScrollRef = useRef<HTMLDivElement>(null)
...@@ -312,6 +314,8 @@ const StepTwo = ({ ...@@ -312,6 +314,8 @@ const StepTwo = ({
updateIndexingTypeCache && updateIndexingTypeCache(indexType) updateIndexingTypeCache && updateIndexingTypeCache(indexType)
updateResultCache && updateResultCache(res) updateResultCache && updateResultCache(res)
} }
if (mutateDatasetRes)
mutateDatasetRes()
onStepChange && onStepChange(+1) onStepChange && onStepChange(+1)
isSetting && onSave && onSave() isSetting && onSave && onSave()
} }
......
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