BigW Consortium Gitlab

groups_helper.rb 1.56 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
  def group_icon(group)
    if group.is_a?(String)
8
      group = Group.find_by_full_path(group)
9 10
    end

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

14
  def group_title(group, name = nil, url = nil)
15
    @has_group_title = true
16 17
    full_title = ''

18
    group.ancestors.each do |parent|
19 20
      full_title += link_to(simple_sanitize(parent.name), group_path(parent), class: 'group-path hidable')
      full_title += '<span class="hidable"> / </span>'.html_safe
21 22
    end

23 24
    full_title += link_to(simple_sanitize(group.name), group_path(group), class: 'group-path')
    full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path') if name
25

26
    content_tag :span, class: 'group-title' do
27
      full_title.html_safe
28 29
    end
  end
30

31 32 33 34 35 36 37
  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
38

39 40
    size = group.projects.size

41 42
    if lfs_status == size
      'for all projects'
43
    else
44
      "for #{lfs_status} out of #{pluralize(size, 'project')}"
45 46 47 48
    end
  end

  def group_lfs_status(group)
49 50 51
    status = group.lfs_enabled? ? 'enabled' : 'disabled'

    content_tag(:span, class: "lfs-#{status}") do
52
      "#{status.humanize} #{projects_lfs_status(group)}"
53
    end
54
  end
55 56 57 58

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