FIX: Incorrect membership action buttons shown for non logged in users.
This commit is contained in:
parent
3c4920d234
commit
a481bf048f
|
@ -4,12 +4,12 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
|
|||
export default Ember.Component.extend({
|
||||
@computed("model.public")
|
||||
canJoinGroup(publicGroup) {
|
||||
return !!(this.currentUser) && publicGroup;
|
||||
return publicGroup;
|
||||
},
|
||||
|
||||
@computed('model.allow_membership_requests', 'model.alias_level')
|
||||
canRequestMembership(allowMembershipRequests, aliasLevel) {
|
||||
return !!(this.currentUser) && allowMembershipRequests && aliasLevel === 99;
|
||||
return allowMembershipRequests && aliasLevel === 99;
|
||||
},
|
||||
|
||||
@computed("model.is_group_user", "model.id", "groupUserIds")
|
||||
|
@ -21,11 +21,29 @@ export default Ember.Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@computed
|
||||
joinGroupAction() {
|
||||
return this.currentUser ? 'joinGroup' : 'showLogin';
|
||||
},
|
||||
|
||||
@computed
|
||||
requestMembershipAction() {
|
||||
return this.currentUser ? 'requestMembership' : 'showLogin';
|
||||
},
|
||||
|
||||
actions: {
|
||||
showLogin() {
|
||||
this.sendAction('showLogin');
|
||||
},
|
||||
|
||||
joinGroup() {
|
||||
this.set('updatingMembership', true);
|
||||
const model = this.get('model');
|
||||
|
||||
if (!!(this.currentUser)) {
|
||||
|
||||
}
|
||||
|
||||
model.addMembers(this.currentUser.get('username')).then(() => {
|
||||
model.set('is_group_user', true);
|
||||
}).catch(popupAjaxError).finally(() => {
|
||||
|
|
|
@ -11,6 +11,10 @@ export default Ember.Controller.extend({
|
|||
actions: {
|
||||
loadMore() {
|
||||
this.get('groups').loadMore();
|
||||
},
|
||||
|
||||
showLogin() {
|
||||
return this.get('application').send('appRouteAction', 'showLogin');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
label="groups.leave"
|
||||
disabled=updatingMembership}}
|
||||
{{else}}
|
||||
{{d-button action="joinGroup"
|
||||
{{d-button action=joinGroupAction
|
||||
class="group-index-join"
|
||||
icon="plus"
|
||||
label="groups.join"
|
||||
|
@ -22,7 +22,7 @@
|
|||
disabled=true}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{d-button action="requestMembership"
|
||||
{{d-button action=requestMembershipAction
|
||||
class="group-index-request"
|
||||
icon="envelope"
|
||||
label="groups.request"}}
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
{{#group-membership-button model=group
|
||||
createNewMessageViaParams='createNewMessageViaParams'
|
||||
showMembershipStatus=true
|
||||
groupUserIds=groups.extras.group_user_ids}}
|
||||
groupUserIds=groups.extras.group_user_ids
|
||||
showLogin='showLogin'}}
|
||||
|
||||
{{d-button icon="ban"
|
||||
label=(if group.automatic 'groups.automatic_group' 'groups.closed_group')
|
||||
|
|
|
@ -6,7 +6,9 @@ test("Browsing Groups", () => {
|
|||
visit("/groups");
|
||||
|
||||
andThen(() => {
|
||||
equal(count('.groups-table-row'), 18, 'it displays visible groups');
|
||||
equal(count('.groups-table-row'), 2, 'it displays visible groups');
|
||||
equal(find('.group-index-join').length, 1, 'it show button to join group');
|
||||
equal(find('.group-index-request').length, 1, 'it show button to request for group membership');
|
||||
});
|
||||
|
||||
click("a[href='/groups/discourse/members']");
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue