2022-01-26 12:08:38 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Users
|
|
|
|
module GroupCalloutsHelper
|
|
|
|
INVITE_MEMBERS_BANNER = 'invite_members_banner'
|
2022-04-04 11:22:00 +05:30
|
|
|
APPROACHING_SEAT_COUNT_THRESHOLD = 'approaching_seat_count_threshold'
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
def show_invite_banner?(group)
|
|
|
|
Ability.allowed?(current_user, :admin_group, group) &&
|
|
|
|
!just_created? &&
|
|
|
|
!user_dismissed_for_group(INVITE_MEMBERS_BANNER, group) &&
|
|
|
|
!multiple_members?(group)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def user_dismissed_for_group(feature_name, group, ignore_dismissal_earlier_than = nil)
|
|
|
|
return false unless current_user
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
current_user.dismissed_callout_for_group?(
|
|
|
|
feature_name: feature_name,
|
|
|
|
group: group,
|
|
|
|
ignore_dismissal_earlier_than: ignore_dismissal_earlier_than
|
|
|
|
)
|
2022-01-26 12:08:38 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def just_created?
|
|
|
|
flash[:notice]&.include?('successfully created')
|
|
|
|
end
|
|
|
|
|
|
|
|
def multiple_members?(group)
|
|
|
|
group.member_count > 1 || group.members_with_parents.count > 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|