Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-09 15:07:19 +0300
committerAndreas Brandl <abrandl@gitlab.com>2018-02-13 20:04:51 +0300
commitc641dff09422522b7de651fc77292d89f137746b (patch)
treea45c9e54da8d0e4e08444dc323f0e2c21c0411a1 /app/helpers/avatars_helper.rb
parentd5ffcb81b6f9d0750fac75d1655dc8d77c07bc85 (diff)
Explicit use of avatar_icon_* calls depending on situation.
We want to drop the generic #avatar_icon helper that supports both an email and a user object being passed in. Instead, we want to explicitly use the #avatar_icon_for_user and #avatar_icon_for_email helpers depending on what we have at hand. This allows us to avoid unnecessary database queries (e.g. call User.find_by_any_email if we already have the user). In situations like here, this makes it less convenient to use.
Diffstat (limited to 'app/helpers/avatars_helper.rb')
-rw-r--r--app/helpers/avatars_helper.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index be11d453898..16e9fbfd3aa 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -11,7 +11,15 @@ module AvatarsHelper
def user_avatar_without_link(options = {})
avatar_size = options[:size] || 16
user_name = options[:user].try(:name) || options[:user_name]
- avatar_url = options[:url] || avatar_icon(options[:user] || options[:user_email], avatar_size)
+
+ avatar_url = if options[:url]
+ options[:url]
+ elsif options[:user]
+ avatar_icon_for_user(options[:user], avatar_size)
+ else
+ avatar_icon_for_email(options[:user_email], avatar_size)
+ end
+
has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip]
data_attributes = options[:data] || {}
css_class = %W[avatar s#{avatar_size}].push(*options[:css_class])