debian-mirror-gitlab/app/helpers/invite_members_helper.rb

43 lines
1.4 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module InviteMembersHelper
include Gitlab::Utils::StrongMemoize
2021-06-08 01:23:25 +05:30
def can_invite_members_for_project?(project)
Feature.enabled?(:invite_members_group_modal, project.group) && can_manage_project_members?(project)
2021-01-03 14:25:43 +05:30
end
2021-06-08 01:23:25 +05:30
def can_invite_group_for_project?(project)
2021-09-04 01:27:46 +05:30
Feature.enabled?(:invite_members_group_modal, project.group) && can_manage_project_members?(project) && project.allowed_to_share_with_group?
2021-03-11 19:13:27 +05:30
end
2021-01-03 14:25:43 +05:30
def directly_invite_members?
strong_memoize(:directly_invite_members) do
2021-04-17 20:07:23 +05:30
can_import_members?
2021-01-03 14:25:43 +05:30
end
end
2021-01-29 00:20:46 +05:30
def invite_group_members?(group)
experiment_enabled?(:invite_members_empty_group_version_a) && Ability.allowed?(current_user, :admin_group_member, group)
end
2021-03-08 18:12:59 +05:30
2021-06-08 01:23:25 +05:30
def invite_accepted_notice(member)
case member.source
when Project
_("You have been granted %{member_human_access} access to project %{name}.") %
{ member_human_access: member.human_access, name: member.source.name }
when Group
_("You have been granted %{member_human_access} access to group %{name}.") %
{ member_human_access: member.human_access, name: member.source.name }
end
end
2021-09-04 01:27:46 +05:30
def group_select_data(group)
if group.root_ancestor.namespace_settings.prevent_sharing_groups_outside_hierarchy
{ groups_filter: 'descendant_groups', parent_id: group.root_ancestor.id }
else
{}
2021-03-08 18:12:59 +05:30
end
end
2021-01-03 14:25:43 +05:30
end