diff options
author | Rémy Coutable <remy@rymai.me> | 2016-06-02 19:05:06 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-06-14 14:18:14 +0300 |
commit | 515205d3c1c6655302ed0ae44cc5954dead7ae79 (patch) | |
tree | 5ac24884eb0e6faf56e1e460260303fbdb14b9cf /app/controllers/groups/group_members_controller.rb | |
parent | 6d103a2f4764441b1650ba6d790732056c9a8516 (diff) |
UI and copywriting improvements
+ Move 'Edit Project/Group' out of membership-related partial
+ Show the access request buttons only to logged-in users
+ Put the request access buttons out of in a more visible button
+ Improve the copy in the #remove_member_message helper
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/controllers/groups/group_members_controller.rb')
-rw-r--r-- | app/controllers/groups/group_members_controller.rb | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index a37129062f9..d0f2e2949f0 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -1,5 +1,5 @@ class Groups::GroupMembersController < Groups::ApplicationController - include AccessRequestActions + include MembershipActions # Authorize before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access] @@ -38,7 +38,7 @@ class Groups::GroupMembersController < Groups::ApplicationController return render_403 unless can?(current_user, :destroy_group_member, @group_member) - @group_member.request? ? @group_member.decline_request : @group_member.destroy + @group_member.destroy respond_to do |format| format.html { redirect_to group_group_members_path(@group), notice: 'User was successfully removed from group.' } @@ -60,46 +60,16 @@ class Groups::GroupMembersController < Groups::ApplicationController end end - def leave - @group_member = - @group.group_members.find_by(user_id: current_user.id) || - @group.group_members.find_by(created_by_id: current_user.id) - - if can?(current_user, :destroy_group_member, @group_member) - notice = - if @group_member.request? - 'You withdrawn your access request to the group.' - else - "You left #{@group.name} group." - end - @group_member.destroy - - redirect_to dashboard_groups_path, notice: notice - else - if @group.last_owner?(current_user) - redirect_to(dashboard_groups_path, alert: "You can not leave #{group.name} group because you're the last owner. Transfer or delete the group.") - else - return render_403 - end - end - end - protected def member_params params.require(:group_member).permit(:access_level, :user_id) end - # AccessRequestActions concern - def access_requestable_resource - @group - end - - def access_requestable_resource_path - group_path(@group) - end + # MembershipActions concern + alias_method :membershipable, :group - def access_requestable_resource_members_path - group_group_members_path(@group) + def cannot_leave? + @group.last_owner?(current_user) end end |