diff --git a/app/assets/javascripts/discourse/controllers/group-manage.js.es6 b/app/assets/javascripts/discourse/controllers/group-manage.js.es6 index ea104333f79..9d100f63e68 100644 --- a/app/assets/javascripts/discourse/controllers/group-manage.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group-manage.js.es6 @@ -2,7 +2,6 @@ import { default as computed } from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ application: Ember.inject.controller(), - destroying: null, @computed("model.automatic") tabs(automatic) { @@ -23,27 +22,4 @@ export default Ember.Controller.extend({ return defaultTabs; }, - - actions: { - destroy() { - const group = this.get('model'); - this.set('destroying', true); - - bootbox.confirm( - I18n.t("admin.groups.delete_confirm"), - I18n.t("no_value"), - I18n.t("yes_value"), - confirmed => { - if (confirmed) { - group.destroy().then(() => { - self.transitionToRoute('groups.index'); - }).catch(() => bootbox.alert(I18n.t("admin.groups.delete_failed"))) - .finally(() => this.set('destroying', false)); - } else { - this.set('destroying', false); - } - } - ); - } - } }); diff --git a/app/assets/javascripts/discourse/controllers/group.js.es6 b/app/assets/javascripts/discourse/controllers/group.js.es6 index 6c0d32624a9..e9bf3bde7d1 100644 --- a/app/assets/javascripts/discourse/controllers/group.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group.js.es6 @@ -13,6 +13,7 @@ export default Ember.Controller.extend({ application: Ember.inject.controller(), counts: null, showing: 'members', + destroying: null, @computed('showMessages', 'model.user_count', 'canManageGroup') tabs(showMessages, userCount, canManageGroup) { @@ -92,6 +93,29 @@ export default Ember.Controller.extend({ actions: { messageGroup() { this.send('createNewMessageViaParams', this.get('model.name')); - } + }, + + destroy() { + const group = this.get('model'); + this.set('destroying', true); + + bootbox.confirm( + I18n.t("admin.groups.delete_confirm"), + I18n.t("no_value"), + I18n.t("yes_value"), + confirmed => { + if (confirmed) { + group.destroy().then(() => { + this.transitionToRoute('groups.index'); + }).catch(error => { + Ember.Logger.error(error); + bootbox.alert(I18n.t("admin.groups.delete_failed")); + }).finally(() => this.set('destroying', false)); + } else { + this.set('destroying', false); + } + } + ); + }, } }); diff --git a/app/assets/javascripts/discourse/templates/group.hbs b/app/assets/javascripts/discourse/templates/group.hbs index e41a22b8c5c..53fb6bf9761 100644 --- a/app/assets/javascripts/discourse/templates/group.hbs +++ b/app/assets/javascripts/discourse/templates/group.hbs @@ -43,6 +43,14 @@ icon="envelope" label="groups.message"}} {{/if}} + + {{#if currentUser.admin}} + {{d-button action="destroy" + disabled=destroying + icon="trash" + class='btn-danger' + label="admin.groups.delete"}} + {{/if}} diff --git a/app/assets/javascripts/discourse/templates/group/manage.hbs b/app/assets/javascripts/discourse/templates/group/manage.hbs index 1c4d3bf6142..0f1e4c9f88b 100644 --- a/app/assets/javascripts/discourse/templates/group/manage.hbs +++ b/app/assets/javascripts/discourse/templates/group/manage.hbs @@ -7,14 +7,6 @@ {{/link-to}} {{/each}} - -