BigW Consortium Gitlab

groups_helper.rb 1.03 KB
Newer Older
1
module GroupsHelper
2 3 4 5
  def remove_user_from_group_message(group, member)
    if member.user
      "Are you sure you want to remove \"#{member.user.name}\" from \"#{group.name}\"?"
    else
6
      "Are you sure you want to revoke the invitation for \"#{member.invite_email}\" to join \"#{group.name}\"?"
7
    end
8 9 10 11
  end

  def leave_group_message(group)
    "Are you sure you want to leave \"#{group}\" group?"
12
  end
13

14 15 16 17 18 19 20
  def should_user_see_group_roles?(user, group)
    if user
      user.is_admin? || group.members.exists?(user_id: user.id)
    else
      false
    end
  end
Dmitriy Zaporozhets committed
21

22 23 24 25 26 27 28 29
  def group_icon(group)
    if group.is_a?(String)
      group = Group.find_by(path: group)
    end

    if group && group.avatar.present?
      group.avatar.url
    else
30
      'no_group_avatar.png'
31 32
    end
  end
33

34 35 36 37
  def group_title(group, name = nil, url = nil)
    full_title = link_to(simple_sanitize(group.name), group_path(group))
    full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name

38
    content_tag :span do
39
      full_title
40 41
    end
  end
42
end