BigW Consortium Gitlab

groups_helper.rb 1.22 KB
Newer Older
1
module GroupsHelper
2 3 4 5
  def can_change_group_visibility_level?(group)
    can?(current_user, :change_visibility_level, group)
  end

6 7 8 9 10
  def group_icon(group)
    if group.is_a?(String)
      group = Group.find_by(path: group)
    end

11
    group.try(:avatar_url) || image_path('no_group_avatar.png')
12
  end
13

14 15 16 17
  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

18
    content_tag :span do
19
      full_title
20 21
    end
  end
22

23 24 25 26 27 28 29
  def projects_lfs_status(group)
    lfs_status =
      if group.lfs_enabled?
        group.projects.select(&:lfs_enabled?).size
      else
        group.projects.reject(&:lfs_enabled?).size
      end
30

31 32
    size = group.projects.size

33 34
    if lfs_status == size
      'for all projects'
35
    else
36
      "for #{lfs_status} out of #{pluralize(size, 'project')}"
37 38 39 40
    end
  end

  def group_lfs_status(group)
41 42 43
    status = group.lfs_enabled? ? 'enabled' : 'disabled'

    content_tag(:span, class: "lfs-#{status}") do
44
      "#{status.humanize} #{projects_lfs_status(group)}"
45
    end
46
  end
47 48 49 50

  def group_issues(group)
    IssuesFinder.new(current_user, group_id: group.id).execute
  end
51
end