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
end
def root_params_key
case membershipable
when Namespace
:group_member
when Project
:project_member
else
raise "Unknown membershipable type: #{membershipable}!"
end
raise NotImplementedError
end
def members_page_url
case membershipable
when Namespace
polymorphic_url([membershipable, :members])
when Project
project_project_members_path(membershipable)
else
raise "Unknown membershipable type: #{membershipable}!"
end
raise NotImplementedError
end
def source_type
@source_type ||=
begin
case membershipable
when Namespace
_("group")
when Project
_("project")
else
raise "Unknown membershipable type: #{membershipable}!"
end
end
raise NotImplementedError
end
def plain_source_type
......
......@@ -82,6 +82,18 @@ class Groups::GroupMembersController < Groups::ApplicationController
def plain_source_type
'group'
end
def source_type
_("group")
end
def members_page_url
polymorphic_url([group, :members])
end
def root_params_key
:group_member
end
end
Groups::GroupMembersController.prepend_mod_with('Groups::GroupMembersController')
......@@ -66,6 +66,18 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def plain_source_type
'project'
end
def source_type
_("project")
end
def members_page_url
project_project_members_path(project)
end
def root_params_key
:project_member
end
end
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