UX: group pages should not show Messages tab to unauthorised users (#4318)
This commit is contained in:
parent
f7c303c82e
commit
c626558d36
|
@ -16,6 +16,13 @@ var Tab = Em.Object.extend({
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
counts: null,
|
counts: null,
|
||||||
showing: 'members',
|
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')
|
@observes('counts')
|
||||||
countsChanged() {
|
countsChanged() {
|
||||||
|
@ -34,11 +41,8 @@ export default Ember.Controller.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
tabs: [
|
@computed('model.is_member')
|
||||||
Tab.create({ name: 'members', active: true, 'location': 'group.index' }),
|
getTabs(isMember) {
|
||||||
Tab.create({ name: 'posts' }),
|
return this.get('tabs').filter(t => isMember || !t.get('requiresMembership'));
|
||||||
Tab.create({ name: 'topics' }),
|
}
|
||||||
Tab.create({ name: 'mentions' }),
|
|
||||||
Tab.create({ name: 'messages' }),
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<section class='user-navigation'>
|
<section class='user-navigation'>
|
||||||
<ul class='action-list nav-stacked'>
|
<ul class='action-list nav-stacked'>
|
||||||
{{#each tabs as |tab|}}
|
{{#each getTabs as |tab|}}
|
||||||
<li class="{{if tab.active 'active'}}">
|
<li class="{{if tab.active 'active'}}">
|
||||||
{{#link-to tab.location model title=tab.message}}
|
{{#link-to tab.location model title=tab.message}}
|
||||||
{{tab.message}}
|
{{tab.message}}
|
||||||
|
|
|
@ -13,6 +13,7 @@ class BasicGroupSerializer < ApplicationSerializer
|
||||||
:incoming_email,
|
:incoming_email,
|
||||||
:notification_level,
|
:notification_level,
|
||||||
:has_messages,
|
:has_messages,
|
||||||
|
:is_member,
|
||||||
:mentionable
|
:mentionable
|
||||||
|
|
||||||
def include_incoming_email?
|
def include_incoming_email?
|
||||||
|
@ -32,4 +33,12 @@ class BasicGroupSerializer < ApplicationSerializer
|
||||||
object.mentionable?(scope.user, object.id)
|
object.mentionable?(scope.user, object.id)
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -34,6 +34,7 @@ describe Admin::GroupsController do
|
||||||
"incoming_email"=>nil,
|
"incoming_email"=>nil,
|
||||||
"notification_level"=>2,
|
"notification_level"=>2,
|
||||||
"has_messages"=>false,
|
"has_messages"=>false,
|
||||||
|
"is_member"=>true,
|
||||||
"mentionable"=>false
|
"mentionable"=>false
|
||||||
}])
|
}])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue