diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-02 14:35:01 +0300 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-04 15:27:09 +0300 |
commit | 892b02e890be539a95e6b52feb14f5d188513700 (patch) | |
tree | 661aa31f1b090a134af39ab08a038017c2a0fbf3 /app/helpers | |
parent | 79c80de99d511d084cff072bd90192ffe8ba4cda (diff) |
Created group_icon and group_icon_url
Tests for these new helper methods
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/groups_helper.rb | 29 |
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 "" |