From d3491c53b98f6177ed59184ef1090a3f39990273 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Sat, 19 Jul 2014 01:58:27 +0100 Subject: [PATCH] Adding helper for invite status closes #3309, refs #3229 - adds different message depending on status - doesn't delete the new user if the problem was an email error - filters the 2 lists based on all statuses --- ghost/admin/controllers/modals/invite-new-user.js | 7 ++++++- ghost/admin/controllers/settings/users/index.js | 4 ++-- ghost/admin/controllers/settings/users/user.js | 1 + ghost/admin/models/user.js | 10 ++++++++-- ghost/admin/templates/settings/users/index.hbs | 6 +++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ghost/admin/controllers/modals/invite-new-user.js b/ghost/admin/controllers/modals/invite-new-user.js index 9c43d8ffdc..7a1de6e21a 100644 --- a/ghost/admin/controllers/modals/invite-new-user.js +++ b/ghost/admin/controllers/modals/invite-new-user.js @@ -37,7 +37,12 @@ var InviteNewUserController = Ember.Controller.extend({ self.notifications.showSuccess(notificationText, false); }).catch(function (errors) { - newUser.deleteRecord(); + if (errors[0].message.indexOf('Email Error:') === -1) { + newUser.deleteRecord(); + } else { + newUser.set('status', 'invited-pending'); + } + self.notifications.closePassive(); self.notifications.showErrors(errors); }); diff --git a/ghost/admin/controllers/settings/users/index.js b/ghost/admin/controllers/settings/users/index.js index 6f1bf7305c..0bb053defb 100644 --- a/ghost/admin/controllers/settings/users/index.js +++ b/ghost/admin/controllers/settings/users/index.js @@ -1,9 +1,9 @@ var UsersIndexController = Ember.ArrayController.extend({ users: Ember.computed.alias('model'), - activeUsers: Ember.computed.filterBy('users', 'status', 'active'), + activeUsers: Ember.computed.filterBy('users', 'active', true).property('users'), - invitedUsers: Ember.computed.filterBy('users', 'status', 'invited') + invitedUsers: Ember.computed.filterBy('users', 'invited', true).property('users') }); export default UsersIndexController; diff --git a/ghost/admin/controllers/settings/users/user.js b/ghost/admin/controllers/settings/users/user.js index 4fd39b2cb4..f9bf741d86 100644 --- a/ghost/admin/controllers/settings/users/user.js +++ b/ghost/admin/controllers/settings/users/user.js @@ -63,6 +63,7 @@ var SettingsUserController = Ember.ObjectController.extend({ var self = this; this.get('model').resendInvite().then(function () { + self.get('model').set('status', 'invited'); var notificationText = 'Invitation resent! (' + self.get('email') + ')'; self.notifications.showSuccess(notificationText, false); }).catch(function (error) { diff --git a/ghost/admin/models/user.js b/ghost/admin/models/user.js index 86cf4a188a..46fc42a9b2 100644 --- a/ghost/admin/models/user.js +++ b/ghost/admin/models/user.js @@ -64,8 +64,14 @@ var User = DS.Model.extend(NProgressSaveMixin, ValidationEngine, { return validationErrors; }.property('password', 'newPassword', 'ne2Password'), - isPasswordValid: Ember.computed.empty('passwordValidationErrors.[]') - + isPasswordValid: Ember.computed.empty('passwordValidationErrors.[]'), + active: function () { + return _.contains(['active', 'warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'], this.get('status')); + }.property('status'), + invited: function () { + return _.contains(['invited', 'invited-pending'], this.get('status')); + }.property('status'), + pending: Ember.computed.equal('status', 'invited-pending').property('status') }); export default User; diff --git a/ghost/admin/templates/settings/users/index.hbs b/ghost/admin/templates/settings/users/index.hbs index 7e732f5c1f..66e62ef95d 100644 --- a/ghost/admin/templates/settings/users/index.hbs +++ b/ghost/admin/templates/settings/users/index.hbs @@ -19,7 +19,11 @@
{{email}}
- Invitation sent: {{created_at}} + {{#if pending}} + Invitation not sent - please try again + {{else}} + Invitation sent: {{created_at}} + {{/if}}