Fix error handling on the Delete Role Dialog (#231)

This commit is contained in:
Alexey Kontsevoy
2021-02-23 14:45:18 -05:00
committed by GitHub
parent 4a5ab166ee
commit ff940c6ebc
3 changed files with 5 additions and 2 deletions
@@ -36,12 +36,15 @@ export default function useAttemptNext(status = '' as Attempt['status']) {
return fn()
.then(() => {
setAttempt({ status: 'success' });
return true;
})
.catch(err => {
handleError(err);
return false;
});
} catch (err) {
handleError(err);
return Promise.resolve(false);
}
}
@@ -53,7 +53,7 @@ const sample = {
user: 'sam',
automatic: true,
setAutomatic: () => null,
createToken: () => Promise.resolve(),
createToken: () => Promise.resolve(true),
onClose() {
return null;
},
@@ -26,7 +26,7 @@ export default function DeleteRoleDialog(props: Props) {
const isDisabled = attempt.status === 'processing';
function onOk() {
run(() => onDelete()).then(() => onClose());
run(() => onDelete()).then(ok => ok && onClose());
}
return (