From 43fe63d956da28568af53ea10227063886979693 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Thu, 31 Jul 2014 00:23:42 -0700 Subject: [PATCH] User Settings: Display cog based on rights closes #3400 - The user view has been extended to have properties indicating whether the user has rights to make the displayed user an owner or delete him/her - Handlebar conditionals decide whether or not to display the cog --- ghost/admin/templates/settings/users/user.hbs | 16 +++++++++------- ghost/admin/templates/user-actions-menu.hbs | 6 +++++- ghost/admin/views/settings/users/user.js | 13 ++++++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ghost/admin/templates/settings/users/user.hbs b/ghost/admin/templates/settings/users/user.hbs index 2fc2cc2869..bba20f0a7b 100644 --- a/ghost/admin/templates/settings/users/user.hbs +++ b/ghost/admin/templates/settings/users/user.hbs @@ -12,13 +12,15 @@
- {{#gh-popover-button popoverName="user-actions-menu" tagName="a" classNames="button only-has-icon user-actions-cog" title="User Actions"}} - - - {{/gh-popover-button}} - {{#gh-popover name="user-actions-menu" classNames="user-actions-menu menu-drop-right"}} - {{render "user-actions-menu" model}} - {{/gh-popover}} + {{#if view.userActionsAreVisible}} + {{#gh-popover-button popoverName="user-actions-menu" tagName="a" classNames="button only-has-icon user-actions-cog" title="User Actions"}} + + + {{/gh-popover-button}} + {{#gh-popover name="user-actions-menu" classNames="user-actions-menu menu-drop-right"}} + {{render "user-actions-menu"}} + {{/gh-popover}} + {{/if}}
diff --git a/ghost/admin/templates/user-actions-menu.hbs b/ghost/admin/templates/user-actions-menu.hbs index 1e3af8c52d..63137db7b5 100644 --- a/ghost/admin/templates/user-actions-menu.hbs +++ b/ghost/admin/templates/user-actions-menu.hbs @@ -1,2 +1,6 @@ +{{#if view.parentView.rolesDropdownIsVisible}} Make Owner -Delete User \ No newline at end of file +{{/if}} +{{#if view.parentView.deleteUserActionIsVisible}} +Delete User +{{/if}} \ No newline at end of file diff --git a/ghost/admin/views/settings/users/user.js b/ghost/admin/views/settings/users/user.js index 7dc31c351b..14c8040f4d 100644 --- a/ghost/admin/views/settings/users/user.js +++ b/ghost/admin/views/settings/users/user.js @@ -7,7 +7,18 @@ var SettingsUserView = Ember.View.extend({ canAssignRoles: Ember.computed.or('currentUser.isAdmin', 'currentUser.isOwner'), - rolesDropdownIsVisible: Ember.computed.and('isNotOwnProfile', 'canAssignRoles') + rolesDropdownIsVisible: Ember.computed.and('isNotOwnProfile', 'canAssignRoles'), + + deleteUserActionIsVisible: Ember.computed('currentUser', 'canAssignRoles', 'controller.user', function () { + if ((this.get('canAssignRoles') && this.get('isNotOwnProfile') && !this.get('controller.user.isOwner')) || + (this.get('currentUser.isEditor') && (!this.get('isNotOwnProfile') || + this.get('controller.user.isAuthor')))) { + return true; + } + }), + + userActionsAreVisible: Ember.computed.or('deleteUserActionIsVisible', 'rolesDropdownIsVisible') + }); export default SettingsUserView; \ No newline at end of file