mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 11:45:57 +08:00
fix: add loading to 'delete' button & 'save' button (#9214)
This commit is contained in:
parent
5c76131d3d
commit
8bcad002df
@ -122,6 +122,7 @@ export const OperationAction: FC<{
|
|||||||
}> = ({ embeddingAvailable, datasetId, detail, onUpdate, scene = 'list', className = '' }) => {
|
}> = ({ embeddingAvailable, datasetId, detail, onUpdate, scene = 'list', className = '' }) => {
|
||||||
const { id, enabled = false, archived = false, data_source_type } = detail || {}
|
const { id, enabled = false, archived = false, data_source_type } = detail || {}
|
||||||
const [showModal, setShowModal] = useState(false)
|
const [showModal, setShowModal] = useState(false)
|
||||||
|
const [deleting, setDeleting] = useState(false)
|
||||||
const { notify } = useContext(ToastContext)
|
const { notify } = useContext(ToastContext)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -153,6 +154,7 @@ export const OperationAction: FC<{
|
|||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
opApi = deleteDocument
|
opApi = deleteDocument
|
||||||
|
setDeleting(true)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
|
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
|
||||||
@ -160,6 +162,8 @@ export const OperationAction: FC<{
|
|||||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||||
else
|
else
|
||||||
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
|
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
|
||||||
|
if (operationName === 'delete')
|
||||||
|
setDeleting(false)
|
||||||
onUpdate(operationName)
|
onUpdate(operationName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +299,8 @@ export const OperationAction: FC<{
|
|||||||
{showModal
|
{showModal
|
||||||
&& <Confirm
|
&& <Confirm
|
||||||
isShow={showModal}
|
isShow={showModal}
|
||||||
|
isLoading={deleting}
|
||||||
|
isDisabled={deleting}
|
||||||
title={t('datasetDocuments.list.delete.title')}
|
title={t('datasetDocuments.list.delete.title')}
|
||||||
content={t('datasetDocuments.list.delete.content')}
|
content={t('datasetDocuments.list.delete.content')}
|
||||||
confirmText={t('common.operation.sure')}
|
confirmText={t('common.operation.sure')}
|
||||||
|
@ -335,6 +335,8 @@ const Form = () => {
|
|||||||
<Button
|
<Button
|
||||||
className='min-w-24'
|
className='min-w-24'
|
||||||
variant='primary'
|
variant='primary'
|
||||||
|
loading={loading}
|
||||||
|
disabled={loading}
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
>
|
>
|
||||||
{t('datasetSettings.form.save')}
|
{t('datasetSettings.form.save')}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user