Commit 0c8a27f8 authored by Doug Stull's avatar Doug Stull Committed by Tetiana Chupryna

Take more declarative approach with membership actions

- clearer code and less re-branching.
parent fc686e6c
...@@ -140,39 +140,15 @@ module MembershipActions ...@@ -140,39 +140,15 @@ module MembershipActions
end end
def root_params_key def root_params_key
case membershipable raise NotImplementedError
when Namespace
:group_member
when Project
:project_member
else
raise "Unknown membershipable type: #{membershipable}!"
end
end end
def members_page_url def members_page_url
case membershipable raise NotImplementedError
when Namespace
polymorphic_url([membershipable, :members])
when Project
project_project_members_path(membershipable)
else
raise "Unknown membershipable type: #{membershipable}!"
end
end end
def source_type def source_type
@source_type ||= raise NotImplementedError
begin
case membershipable
when Namespace
_("group")
when Project
_("project")
else
raise "Unknown membershipable type: #{membershipable}!"
end
end
end end
def plain_source_type def plain_source_type
......
...@@ -82,6 +82,18 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -82,6 +82,18 @@ class Groups::GroupMembersController < Groups::ApplicationController
def plain_source_type def plain_source_type
'group' 'group'
end end
def source_type
_("group")
end
def members_page_url
polymorphic_url([group, :members])
end
def root_params_key
:group_member
end
end end
Groups::GroupMembersController.prepend_mod_with('Groups::GroupMembersController') Groups::GroupMembersController.prepend_mod_with('Groups::GroupMembersController')
...@@ -66,6 +66,18 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -66,6 +66,18 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def plain_source_type def plain_source_type
'project' 'project'
end end
def source_type
_("project")
end
def members_page_url
project_project_members_path(project)
end
def root_params_key
:project_member
end
end end
Projects::ProjectMembersController.prepend_mod_with('Projects::ProjectMembersController') Projects::ProjectMembersController.prepend_mod_with('Projects::ProjectMembersController')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment