summaryrefslogtreecommitdiff
path: root/app/helpers/groups_helper.rb
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-10-02 13:35:01 +0200
committerTim Zallmann <tzallmann@gitlab.com>2017-10-04 14:27:09 +0200
commit892b02e890be539a95e6b52feb14f5d188513700 (patch)
tree661aa31f1b090a134af39ab08a038017c2a0fbf3 /app/helpers/groups_helper.rb
parent79c80de99d511d084cff072bd90192ffe8ba4cda (diff)
downloadgitlab-ce-892b02e890be539a95e6b52feb14f5d188513700.tar.gz
Created group_icon and group_icon_url
Tests for these new helper methods
Diffstat (limited to 'app/helpers/groups_helper.rb')
-rw-r--r--app/helpers/groups_helper.rb29
1 files changed, 24 insertions, 5 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 091d98a2c94..60ac4c63e62 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -1,4 +1,8 @@
+require 'uri'
+
module GroupsHelper
+ include Gitlab::CurrentSettings
+
def can_change_group_visibility_level?(group)
can?(current_user, :change_visibility_level, group)
end
@@ -7,12 +11,28 @@ module GroupsHelper
can?(current_user, :change_share_with_group_lock, group)
end
- def group_icon(group)
+ # = project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile')
+ # = image_tag group_icon(@group), alt: '', class: 'avatar group-avatar s160'
+ def group_icon(group, options = {})
+ img_path = group_icon_url(group, options)
+ image_tag img_path, options
+ end
+
+ def group_icon_url(group, options = {})
if group.is_a?(String)
group = Group.find_by_full_path(group)
end
- group.try(:avatar_url, use_asset_path: false) || ActionController::Base.helpers.image_path('no_group_avatar.png')
+ if group.avatar_url
+ if group.private?
+ options[:use_original_source] = true
+ group.avatar_url(use_asset_path: false)
+ else
+ group.avatar_url
+ end
+ else # No Avatar Icon
+ ActionController::Base.helpers.image_path('no_group_avatar.png')
+ end
end
def group_title(group, name = nil, url = nil)
@@ -90,10 +110,9 @@ module GroupsHelper
output =
if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
if group.private?
- puts "GROUP IS PRIVATE : " + group_icon(group)
- image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15, use_original_source: true)
+ group_icon(group, class: "avatar-tile", width: 15, height: 15, use_original_source: true)
else
- image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15)
+ group_icon(group, class: "avatar-tile", width: 15, height: 15)
end
else
""