feat: Add loading to delete confirmation dialog

pull/12372/head
twwu 2 years ago
parent 7d4f8e0082
commit 837990cb80

@ -39,6 +39,10 @@ const Action: FC<Props> = ({
setFalse: hidePluginInfo, setFalse: hidePluginInfo,
}] = useBoolean(false) }] = useBoolean(false)
const mutateInstalledPluginList = usePluginPageContext(v => v.mutateInstalledPluginList) const mutateInstalledPluginList = usePluginPageContext(v => v.mutateInstalledPluginList)
const [deleting, {
setTrue: showDeleting,
setFalse: hideDeleting,
}] = useBoolean(false)
const handleFetchNewVersion = () => { } const handleFetchNewVersion = () => { }
@ -48,7 +52,9 @@ const Action: FC<Props> = ({
}] = useBoolean(false) }] = useBoolean(false)
const handleDelete = useCallback(async () => { const handleDelete = useCallback(async () => {
showDeleting()
const res = await uninstallPlugin(pluginId) const res = await uninstallPlugin(pluginId)
hideDeleting()
if (res.success) { if (res.success) {
hideDeleteConfirm() hideDeleteConfirm()
mutateInstalledPluginList() mutateInstalledPluginList()
@ -99,10 +105,8 @@ const Action: FC<Props> = ({
onHide={hidePluginInfo} onHide={hidePluginInfo}
/> />
)} )}
{
isShowDeleteConfirm && (
<Confirm <Confirm
isShow isShow={isShowDeleteConfirm}
title={t(`${i18nPrefix}.delete`)} title={t(`${i18nPrefix}.delete`)}
content={ content={
<div> <div>
@ -113,9 +117,9 @@ const Action: FC<Props> = ({
} }
onCancel={hideDeleteConfirm} onCancel={hideDeleteConfirm}
onConfirm={handleDelete} onConfirm={handleDelete}
isLoading={deleting}
isDisabled={deleting}
/> />
)
}
</div> </div>
) )
} }

Loading…
Cancel
Save