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 | |
parent | 79c80de99d511d084cff072bd90192ffe8ba4cda (diff) |
Created group_icon and group_icon_url
Tests for these new helper methods
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/groups_helper.rb | 29 | ||||
-rw-r--r-- | app/models/concerns/avatarable.rb | 2 | ||||
-rw-r--r-- | app/serializers/group_entity.rb | 2 | ||||
-rw-r--r-- | app/views/admin/groups/_group.html.haml | 2 | ||||
-rw-r--r-- | app/views/admin/groups/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/groups/_home_panel.html.haml | 2 | ||||
-rw-r--r-- | app/views/groups/edit.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_group.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/groups/_group.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/members/_group.html.haml | 2 | ||||
-rw-r--r-- | app/views/users/_groups.html.haml | 2 |
11 files changed, 34 insertions, 15 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 "" diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb index f8c0327e190..ddaa15e6a0d 100644 --- a/app/models/concerns/avatarable.rb +++ b/app/models/concerns/avatarable.rb @@ -16,7 +16,7 @@ module Avatarable [host, avatar.url].join else - avatar.url + [host, avatar.url].join end end end diff --git a/app/serializers/group_entity.rb b/app/serializers/group_entity.rb index 7c872a3e986..6d8466da902 100644 --- a/app/serializers/group_entity.rb +++ b/app/serializers/group_entity.rb @@ -45,6 +45,6 @@ class GroupEntity < Grape::Entity end expose :avatar_url do |group| - group_icon(group) + group_icon_url(group) end end diff --git a/app/views/admin/groups/_group.html.haml b/app/views/admin/groups/_group.html.haml index e3a77dfdf10..47cc2d4d27e 100644 --- a/app/views/admin/groups/_group.html.haml +++ b/app/views/admin/groups/_group.html.haml @@ -20,7 +20,7 @@ = visibility_level_icon(group.visibility_level, fw: false) .avatar-container.s40 - = image_tag group_icon(group), class: "avatar s40 hidden-xs" + = group_icon(group, class: "avatar s40 hidden-xs") .title = link_to [:admin, group], class: 'group-name' do = group.full_name diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 3e02f7b1e16..2545cecc721 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -16,7 +16,7 @@ %ul.well-list %li .avatar-container.s60 - = image_tag group_icon(@group), class: "avatar s60" + = group_icon(@group, class: "avatar s60") %li %span.light Name: %strong= @group.name diff --git a/app/views/groups/_home_panel.html.haml b/app/views/groups/_home_panel.html.haml index 181c7bee702..a0760c2073b 100644 --- a/app/views/groups/_home_panel.html.haml +++ b/app/views/groups/_home_panel.html.haml @@ -1,7 +1,7 @@ .group-home-panel.text-center %div{ class: container_class } .avatar-container.s70.group-avatar - = image_tag group_icon(@group), class: "avatar s70 avatar-tile" + = group_icon(@group, class: "avatar s70 avatar-tile") %h1.group-title = @group.name %span.visibility-icon.has-tooltip{ data: { container: 'body' }, title: visibility_icon_description(@group) } diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 15606dd30fd..16038ef2f79 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -10,7 +10,7 @@ .form-group .col-sm-offset-2.col-sm-10 .avatar-container.s160 - = image_tag group_icon(@group), alt: '', class: 'avatar group-avatar s160' + = group_icon(@group, alt: '', class: 'avatar group-avatar s160') %p.light - if @group.avatar? You can change your group avatar here diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml index 8cba495f7e4..0bf318b0b66 100644 --- a/app/views/layouts/nav/sidebar/_group.html.haml +++ b/app/views/layouts/nav/sidebar/_group.html.haml @@ -6,7 +6,7 @@ .context-header = link_to group_path(@group), title: @group.name do .avatar-container.s40.group-avatar - = image_tag group_icon(@group), class: "avatar s40 avatar-tile" + = group_icon(@group, class: "avatar s40 avatar-tile") .sidebar-context-title = @group.name %ul.sidebar-top-level-items diff --git a/app/views/shared/groups/_group.html.haml b/app/views/shared/groups/_group.html.haml index b361ec86ced..63f62eb476e 100644 --- a/app/views/shared/groups/_group.html.haml +++ b/app/views/shared/groups/_group.html.haml @@ -28,7 +28,7 @@ .avatar-container.s40 = link_to group do - = image_tag group_icon(group), class: "avatar s40 hidden-xs" + = group_icon(group, class: "avatar s40 hidden-xs") .title = link_to group_name, group, class: 'group-name' diff --git a/app/views/shared/members/_group.html.haml b/app/views/shared/members/_group.html.haml index bcdad3c153a..5868c52566d 100644 --- a/app/views/shared/members/_group.html.haml +++ b/app/views/shared/members/_group.html.haml @@ -4,7 +4,7 @@ - dom_id = "group_member_#{group_link.id}" %li.member.group_member{ id: dom_id } %span.list-item-name - = image_tag group_icon(group), class: "avatar s40", alt: '' + = group_icon(group, class: "avatar s40", alt: '') %strong = link_to group.full_name, group_path(group) .cgray diff --git a/app/views/users/_groups.html.haml b/app/views/users/_groups.html.haml index eff6c80d144..55799e10a46 100644 --- a/app/views/users/_groups.html.haml +++ b/app/views/users/_groups.html.haml @@ -2,4 +2,4 @@ - groups.each do |group| = link_to group, class: 'profile-groups-avatars inline', title: group.name do .avatar-container.s40 - = image_tag group_icon(group), class: 'avatar group-avatar s40' + = group_icon(group, class: 'avatar group-avatar s40') |