Skip to content

Commit

Permalink
Change user deletion warning to be more explicit.
Browse files Browse the repository at this point in the history
Issue #4583
- If a user has posts, show the count in the deletion warning.
  • Loading branch information
jaswilli committed Dec 10, 2014
1 parent 5d67f4a commit 83f1543
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
22 changes: 21 additions & 1 deletion core/client/controllers/modals/delete-user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
var DeleteUserController = Ember.Controller.extend({
var DeleteUserController = Ember.ObjectController.extend({
userPostCount: Ember.computed('id', function () {
var promise,
query = {
author: this.get('slug'),
status: 'all'
};

promise = this.store.find('post', query).then(function (results) {
return results.meta.pagination.total;
});

return Ember.Object.extend(Ember.PromiseProxyMixin, {
count: Ember.computed.alias('content'),

inflection: Ember.computed('count', function () {
return this.get('count') > 1 ? 'posts' : 'post';
})
}).create({promise: promise});
}),

actions: {
confirmAccept: function () {
var self = this,
Expand Down
11 changes: 8 additions & 3 deletions core/client/templates/modals/delete-user.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade"
title="Are you sure you want to delete this user?" confirm=confirm}}

<p>All posts and associated data will also be deleted. There is no way to recover this data.
</p>
{{#unless userPostCount.isPending}}
{{#if userPostCount.count}}
<strong>WARNING:</strong> <span class="red">This user is the author of {{userPostCount.count}} {{userPostCount.inflection}}.</span> All posts and user data will be deleted. There is no way to recover this.
{{else}}
<strong>WARNING:</strong> All user data will be deleted. There is no way to recover this.
{{/if}}
{{/unless}}

{{/gh-modal-dialog}}
{{/gh-modal-dialog}}

0 comments on commit 83f1543

Please sign in to comment.