2013-01-07 18:48:57 +00:00
|
|
|
module GroupsHelper
|
2016-03-01 15:22:29 +00:00
|
|
|
def can_change_group_visibility_level?(group)
|
|
|
|
can?(current_user, :change_visibility_level, group)
|
|
|
|
end
|
|
|
|
|
2015-03-12 20:56:53 +00:00
|
|
|
def group_icon(group)
|
|
|
|
if group.is_a?(String)
|
|
|
|
group = Group.find_by(path: group)
|
|
|
|
end
|
|
|
|
|
2016-03-03 19:52:38 +00:00
|
|
|
if group && group.avatar.present?
|
2015-03-12 20:56:53 +00:00
|
|
|
group.avatar.url
|
|
|
|
else
|
2016-05-31 12:02:12 +00:00
|
|
|
image_path('no_group_avatar.png')
|
2015-03-12 20:56:53 +00:00
|
|
|
end
|
|
|
|
end
|
2015-09-07 11:18:11 +00:00
|
|
|
|
2015-09-17 10:16:24 +00:00
|
|
|
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
|
|
|
|
|
2015-09-07 11:18:11 +00:00
|
|
|
content_tag :span do
|
2015-09-17 10:16:24 +00:00
|
|
|
full_title
|
2015-09-07 11:18:11 +00:00
|
|
|
end
|
|
|
|
end
|
2016-09-01 23:49:48 +00:00
|
|
|
|
2016-09-06 16:48:00 +00:00
|
|
|
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
|
2016-09-05 20:40:49 +00:00
|
|
|
|
2016-09-05 18:14:49 +00:00
|
|
|
size = group.projects.size
|
|
|
|
|
2016-09-06 16:48:00 +00:00
|
|
|
if lfs_status == size
|
|
|
|
'for all projects'
|
2016-09-05 18:14:49 +00:00
|
|
|
else
|
2016-09-06 16:48:00 +00:00
|
|
|
"for #{lfs_status} out of #{pluralize(size, 'project')}"
|
2016-09-05 18:14:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_lfs_status(group)
|
2016-09-05 20:40:49 +00:00
|
|
|
status = group.lfs_enabled? ? 'enabled' : 'disabled'
|
|
|
|
|
|
|
|
content_tag(:span, class: "lfs-#{status}") do
|
2016-09-06 16:48:00 +00:00
|
|
|
"#{status.humanize} #{projects_lfs_status(group)}"
|
2016-09-05 18:14:49 +00:00
|
|
|
end
|
2016-09-01 23:49:48 +00:00
|
|
|
end
|
2016-11-05 17:28:29 +00:00
|
|
|
|
|
|
|
def group_issues(group)
|
|
|
|
IssuesFinder.new(current_user, group_id: group.id).execute
|
|
|
|
end
|
2013-01-07 18:48:57 +00:00
|
|
|
end
|