Feat: Support re-segmentation (#114)
Co-authored-by: John Wang <takatost@gmail.com> Co-authored-by: Jyong <718720800@qq.com> Co-authored-by: 金伟强 <iamjoel007@gmail.com>
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
'use client'
|
||||
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import { BookOpenIcon } from '@heroicons/react/24/outline'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import PermissionsRadio from '../permissions-radio'
|
||||
import IndexMethodRadio from '../index-method-radio'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { updateDatasetSetting, fetchDataDetail } from '@/service/datasets'
|
||||
import { DataSet } from '@/models/datasets'
|
||||
import { fetchDataDetail, updateDatasetSetting } from '@/service/datasets'
|
||||
import type { DataSet } from '@/models/datasets'
|
||||
|
||||
const rowClass = `
|
||||
flex justify-between py-4
|
||||
@@ -20,8 +20,7 @@ const labelClass = `
|
||||
const inputClass = `
|
||||
w-[480px] px-3 bg-gray-100 text-sm text-gray-800 rounded-lg outline-none appearance-none
|
||||
`
|
||||
|
||||
const useInitialValue = <T,>(depend: T, dispatch: Dispatch<SetStateAction<T>>) => {
|
||||
const useInitialValue = (depend: any, dispatch: any) => {
|
||||
useEffect(() => {
|
||||
dispatch(depend)
|
||||
}, [depend])
|
||||
@@ -32,7 +31,7 @@ type Props = {
|
||||
}
|
||||
|
||||
const Form = ({
|
||||
datasetId
|
||||
datasetId,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
@@ -44,7 +43,8 @@ const Form = ({
|
||||
const [indexMethod, setIndexMethod] = useState(currentDataset?.indexing_technique)
|
||||
|
||||
const handleSave = async () => {
|
||||
if (loading) return
|
||||
if (loading)
|
||||
return
|
||||
if (!name?.trim()) {
|
||||
notify({ type: 'error', message: t('datasetSettings.form.nameError') })
|
||||
return
|
||||
@@ -57,14 +57,16 @@ const Form = ({
|
||||
name,
|
||||
description,
|
||||
permission,
|
||||
indexing_technique: indexMethod
|
||||
}
|
||||
indexing_technique: indexMethod,
|
||||
},
|
||||
})
|
||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||
await mutateDatasets()
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
notify({ type: 'error', message: t('common.actionMsg.modificationFailed') })
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
@@ -142,4 +144,4 @@ const Form = ({
|
||||
)
|
||||
}
|
||||
|
||||
export default Form
|
||||
export default Form
|
||||
|
Reference in New Issue
Block a user