From c626558d36c3e50de7abc332fd7bf55c7829cbd6 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 9 Jul 2016 00:50:04 +0530 Subject: [PATCH] UX: group pages should not show Messages tab to unauthorised users (#4318) --- .../discourse/controllers/group.js.es6 | 18 +++++++++++------- .../javascripts/discourse/templates/group.hbs | 2 +- app/serializers/basic_group_serializer.rb | 9 +++++++++ .../admin/groups_controller_spec.rb | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/group.js.es6 b/app/assets/javascripts/discourse/controllers/group.js.es6 index 819047536ab..ac16e4342e0 100644 --- a/app/assets/javascripts/discourse/controllers/group.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group.js.es6 @@ -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')); + } }); diff --git a/app/assets/javascripts/discourse/templates/group.hbs b/app/assets/javascripts/discourse/templates/group.hbs index 6ad3e0ca3be..416b356f405 100644 --- a/app/assets/javascripts/discourse/templates/group.hbs +++ b/app/assets/javascripts/discourse/templates/group.hbs @@ -2,7 +2,7 @@