UX: group pages should not show Messages tab to unauthorised users (#4318)

This commit is contained in:
Arpit Jalan 2016-07-09 00:50:04 +05:30 committed by GitHub
parent f7c303c82e
commit c626558d36
4 changed files with 22 additions and 8 deletions

View File

@ -16,6 +16,13 @@ var Tab = Em.Object.extend({
export default Ember.Controller.extend({
counts: null,
showing: 'members',
tabs: [
Tab.create({ name: 'members', active: true, 'location': 'group.index' }),
Tab.create({ name: 'posts' }),
Tab.create({ name: 'topics' }),
Tab.create({ name: 'mentions' }),
Tab.create({ name: 'messages', requiresMembership: true })
],
@observes('counts')
countsChanged() {
@ -34,11 +41,8 @@ export default Ember.Controller.extend({
});
},
tabs: [
Tab.create({ name: 'members', active: true, 'location': 'group.index' }),
Tab.create({ name: 'posts' }),
Tab.create({ name: 'topics' }),
Tab.create({ name: 'mentions' }),
Tab.create({ name: 'messages' }),
]
@computed('model.is_member')
getTabs(isMember) {
return this.get('tabs').filter(t => isMember || !t.get('requiresMembership'));
}
});

View File

@ -2,7 +2,7 @@
<div class="wrapper">
<section class='user-navigation'>
<ul class='action-list nav-stacked'>
{{#each tabs as |tab|}}
{{#each getTabs as |tab|}}
<li class="{{if tab.active 'active'}}">
{{#link-to tab.location model title=tab.message}}
{{tab.message}}

View File

@ -13,6 +13,7 @@ class BasicGroupSerializer < ApplicationSerializer
:incoming_email,
:notification_level,
:has_messages,
:is_member,
:mentionable
def include_incoming_email?
@ -32,4 +33,12 @@ class BasicGroupSerializer < ApplicationSerializer
object.mentionable?(scope.user, object.id)
end
def is_member
scope.is_admin? || GroupUser.where(group_id: object.id, user_id: scope.user.id).present?
end
def include_is_member?
scope.authenticated?
end
end

View File

@ -34,6 +34,7 @@ describe Admin::GroupsController do
"incoming_email"=>nil,
"notification_level"=>2,
"has_messages"=>false,
"is_member"=>true,
"mentionable"=>false
}])
end