diff options
Diffstat (limited to 'lib/sidebars/groups')
-rw-r--r-- | lib/sidebars/groups/menus/invite_team_members_menu.rb | 46 | ||||
-rw-r--r-- | lib/sidebars/groups/panel.rb | 10 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/sidebars/groups/menus/invite_team_members_menu.rb b/lib/sidebars/groups/menus/invite_team_members_menu.rb new file mode 100644 index 00000000000..0779b696061 --- /dev/null +++ b/lib/sidebars/groups/menus/invite_team_members_menu.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Sidebars + module Groups + module Menus + class InviteTeamMembersMenu < ::Sidebars::Menu + override :title + def title + s_('InviteMember|Invite members') + end + + override :render? + def render? + can?(context.current_user, :admin_group_member, context.group) && all_valid_members.size <= 1 + end + + override :menu_partial + def menu_partial + 'groups/invite_members_side_nav_link' + end + + override :menu_partial_options + def menu_partial_options + { + group: context.group, + title: title, + sidebar_menu: self + } + end + + override :extra_nav_link_html_options + def extra_nav_link_html_options + { + 'data-test-id': 'side-nav-invite-members' + } + end + + private + + def all_valid_members + GroupMembersFinder.new(context.group, context.current_user).execute + end + end + end + end +end diff --git a/lib/sidebars/groups/panel.rb b/lib/sidebars/groups/panel.rb index 185e49938ef..463c2571b14 100644 --- a/lib/sidebars/groups/panel.rb +++ b/lib/sidebars/groups/panel.rb @@ -15,12 +15,22 @@ module Sidebars add_menu(Sidebars::Groups::Menus::PackagesRegistriesMenu.new(context)) add_menu(Sidebars::Groups::Menus::CustomerRelationsMenu.new(context)) add_menu(Sidebars::Groups::Menus::SettingsMenu.new(context)) + add_invite_members_menu end override :aria_label def aria_label context.group.subgroup? ? _('Subgroup navigation') : _('Group navigation') end + + private + + def add_invite_members_menu + experiment(:invite_members_in_side_nav, group: context.group) do |e| + e.control {} + e.candidate { add_menu(Sidebars::Groups::Menus::InviteTeamMembersMenu.new(context)) } + end + end end end end |