diff --git a/framework/core/js/src/forum/utils/History.js b/framework/core/js/src/forum/utils/History.js index b71b84951..d8b2a89e5 100644 --- a/framework/core/js/src/forum/utils/History.js +++ b/framework/core/js/src/forum/utils/History.js @@ -92,7 +92,7 @@ export default class History { this.stack.pop(); - m.route(this.getCurrent().url); + this.canGoBack() ? m.route(this.getCurrent().url) : this.home(); } /** diff --git a/framework/core/js/src/forum/utils/UserControls.js b/framework/core/js/src/forum/utils/UserControls.js index c588af6df..07fb89090 100644 --- a/framework/core/js/src/forum/utils/UserControls.js +++ b/framework/core/js/src/forum/utils/UserControls.js @@ -1,3 +1,4 @@ +import Alert from '../../common/components/Alert'; import Button from '../../common/components/Button'; import Separator from '../../common/components/Separator'; import EditUserModal from '../components/EditUserModal'; @@ -95,15 +96,29 @@ export default { * Delete the user. */ deleteAction() { - if (confirm(app.translator.trans('core.forum.user_controls.delete_confirmation'))) { - this.delete().then(() => { - if (app.current instanceof UserPage && app.current.user === this) { - app.history.back(); - } else { - window.location.reload(); - } - }); + if (!confirm(app.translator.trans('core.forum.user_controls.delete_confirmation'))) { + return; } + + 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')); }, /**