diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6 index a4341d09d..8bbd72900 100644 --- a/app/assets/javascripts/admin/models/admin-user.js.es6 +++ b/app/assets/javascripts/admin/models/admin-user.js.es6 @@ -264,6 +264,7 @@ const AdminUser = Discourse.User.extend({ }, unblock() { + this.set('blockingUser', true); return Discourse.ajax('/admin/users/' + this.id + '/unblock', { type: 'PUT' }).then(function() { @@ -275,14 +276,33 @@ const AdminUser = Discourse.User.extend({ }, block() { - return Discourse.ajax('/admin/users/' + this.id + '/block', { - type: 'PUT' - }).then(function() { - window.location.reload(); - }).catch(function(e) { - var error = I18n.t('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body }); - bootbox.alert(error); - }); + const user = this, + message = I18n.t("admin.user.block_confirm"); + + const performBlock = function() { + user.set('blockingUser', true); + return Discourse.ajax('/admin/users/' + user.id + '/block', { + type: 'PUT' + }).then(function() { + window.location.reload(); + }).catch(function(e) { + var error = I18n.t('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body }); + bootbox.alert(error); + user.set('blockingUser', false); + }); + }; + + const buttons = [{ + "label": I18n.t("composer.cancel"), + "class": "cancel", + "link": true + }, { + "label": '' + I18n.t('admin.user.block_accept'), + "class": "btn btn-danger", + "callback": function() { performBlock(); } + }]; + + bootbox.dialog(message, buttons, { "classes": "delete-user-modal" }); }, sendActivationEmail() { diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index 32190c967..b868854e8 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -327,13 +327,21 @@
{{i18n 'admin.user.blocked'}}
{{model.blocked}}
- {{#if model.blocked}} - - {{i18n 'admin.user.block_explanation'}} - {{/if}} + {{#conditional-loading-spinner size="small" condition=model.blockingUser}} + {{#if model.blocked}} + + {{i18n 'admin.user.block_explanation'}} + {{else}} + + {{i18n 'admin.user.block_explanation'}} + {{/if}} + {{/conditional-loading-spinner}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 57501ee38..d39f76dfa 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2448,6 +2448,8 @@ en: deactivate_failed: "There was a problem deactivating the user." unblock_failed: 'There was a problem unblocking the user.' block_failed: 'There was a problem blocking the user.' + block_confirm: 'Are you sure you want to block this user? They will not be able to create any new topics or posts.' + block_accept: 'Yes, block this user' deactivate_explanation: "A deactivated user must re-validate their email." suspended_explanation: "A suspended user can't log in." block_explanation: "A blocked user can't post or start topics."