Improve feedback on user deletion

Fixes #1750, #1777
This commit is contained in:
Tobias Karlsson 2019-08-13 22:56:24 +02:00 committed by Daniël Klabbers
parent fcb3921a42
commit be6d42d46f
2 changed files with 24 additions and 9 deletions

View File

@ -92,7 +92,7 @@ export default class History {
this.stack.pop(); this.stack.pop();
m.route(this.getCurrent().url); this.canGoBack() ? m.route(this.getCurrent().url) : this.home();
} }
/** /**

View File

@ -1,3 +1,4 @@
import Alert from '../../common/components/Alert';
import Button from '../../common/components/Button'; import Button from '../../common/components/Button';
import Separator from '../../common/components/Separator'; import Separator from '../../common/components/Separator';
import EditUserModal from '../components/EditUserModal'; import EditUserModal from '../components/EditUserModal';
@ -95,15 +96,29 @@ export default {
* Delete the user. * Delete the user.
*/ */
deleteAction() { deleteAction() {
if (confirm(app.translator.trans('core.forum.user_controls.delete_confirmation'))) { if (!confirm(app.translator.trans('core.forum.user_controls.delete_confirmation'))) {
this.delete().then(() => { return;
if (app.current instanceof UserPage && app.current.user === this) {
app.history.back();
} else {
window.location.reload();
}
});
} }
const showAlert = type => {
const { username, email } = this.data.attributes;
app.alerts.show(new Alert({
type,
children: app.translator.trans(
`core.forum.user.delete_alert_${type}`, { username, email }
)
}));
};
this.delete().then(() => {
showAlert('success');
if (app.current instanceof UserPage && app.current.user === this) {
app.history.back();
} else {
window.location.reload();
}
}).catch(() => showAlert('error'));
}, },
/** /**