diff options
author | Rémy Coutable <remy@rymai.me> | 2018-02-16 14:00:25 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-02-27 18:02:22 +0300 |
commit | e82f629be4b9c91e2611095cd4296e487ed137ef (patch) | |
tree | fc8cb097f0b8e37c2e6fe785cf114a621e1f6b35 /app | |
parent | bf41063679b25371b2e64542f2f469b38502edf6 (diff) |
Move the #update action from Project/Member controllers to the MembershipActions concern
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/membership_actions.rb | 12 | ||||
-rw-r--r-- | app/controllers/groups/group_members_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 8 | ||||
-rw-r--r-- | app/views/groups/group_members/update.js.haml | 4 | ||||
-rw-r--r-- | app/views/projects/project_members/update.js.haml | 4 | ||||
-rw-r--r-- | app/views/shared/members/update.js.haml | 4 |
6 files changed, 16 insertions, 24 deletions
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index a6f1509b451..82fdb797d2a 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -14,6 +14,18 @@ module MembershipActions end end + def update + member = membershipable.members_and_requesters.find(params[:id]) + @member = Members::UpdateService + .new(membershipable, current_user, member_params) + .execute(member) + .present(current_user: current_user) + + respond_to do |format| + format.js { render 'shared/members/update' } + end + end + def destroy member = membershipable.members_and_requesters.find(params[:id]) Members::DestroyService.new(membershipable, current_user, params) diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 1efd07835e2..23ade14edfd 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -27,14 +27,6 @@ class Groups::GroupMembersController < Groups::ApplicationController @group_member = @group.group_members.new end - def update - member = @group.members_and_requesters.find(params[:id]) - @group_member = Members::UpdateService - .new(@group, current_user, member_params) - .execute(member) - .present(current_user: current_user) - end - def resend_invite redirect_path = group_group_members_path(@group) diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 06388055d52..006d5df767c 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -26,14 +26,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController @project_member = @project.project_members.new end - def update - member = @project.members_and_requesters.find(params[:id]) - @project_member = Members::UpdateService - .new(@project, current_user, member_params) - .execute(member) - .present(current_user: current_user) - end - def resend_invite redirect_path = project_project_members_path(@project) diff --git a/app/views/groups/group_members/update.js.haml b/app/views/groups/group_members/update.js.haml deleted file mode 100644 index 9d05bff6c4e..00000000000 --- a/app/views/groups/group_members/update.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - var $listItem = $('#{escape_javascript(render('shared/members/member', member: @group_member))}'); - $("##{dom_id(@group_member)} .list-item-name").replaceWith($listItem.find('.list-item-name')); - gl.utils.localTimeAgo($('.js-timeago'), $("##{dom_id(@group_member)}")); diff --git a/app/views/projects/project_members/update.js.haml b/app/views/projects/project_members/update.js.haml deleted file mode 100644 index d15f4310ff5..00000000000 --- a/app/views/projects/project_members/update.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - var $listItem = $('#{escape_javascript(render('shared/members/member', member: @project_member))}'); - $("##{dom_id(@project_member)} .list-item-name").replaceWith($listItem.find('.list-item-name')); - gl.utils.localTimeAgo($('.js-timeago'), $("##{dom_id(@project_member)}")); diff --git a/app/views/shared/members/update.js.haml b/app/views/shared/members/update.js.haml new file mode 100644 index 00000000000..597d984d0eb --- /dev/null +++ b/app/views/shared/members/update.js.haml @@ -0,0 +1,4 @@ +:plain + var $listItem = $('#{escape_javascript(render('shared/members/member', member: @member))}'); + $("##{dom_id(@member)} .list-item-name").replaceWith($listItem.find('.list-item-name')); + gl.utils.localTimeAgo($('.js-timeago'), $("##{dom_id(@member)}")); |