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:
authorRémy Coutable <remy@rymai.me>2016-07-20 20:14:46 +0300
committerRémy Coutable <remy@rymai.me>2016-07-20 20:14:46 +0300
commitb4717017e7ad601eaa1d53c9238a242c7fdf0daa (patch)
tree5caea8f9c8452bc18cc2c60f1ded32167351a829 /app/helpers
parentcf6de7dae95570c95e8e0590770d62d32a371bf6 (diff)
parent6558586f15f493968129b78544d76486cd2a6cd4 (diff)
Merge branch 'add-link-to-commit-avatar' into 'master'
Add link to profile to commit avatar ## What does this MR do? - links to user profiles to the avatars on commits page - tooltips to the avatars on commits page side effect: - links to user profiles to the avatars on pipelines page - tooltips to the avatars on pipelines page - tooltips to the avatars on activity page - mailto links to the avatars on activity page for non-registered users ## Are there points in the code the reviewer needs to double check? Nope. ## Why was this MR needed? There were no links nor Zeldas. ## What are the relevant issue numbers? fixes #19644 See merge request !5163
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/avatars_helper.rb30
-rw-r--r--app/helpers/commits_helper.rb10
2 files changed, 30 insertions, 10 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
new file mode 100644
index 00000000000..6ff40c6b461
--- /dev/null
+++ b/app/helpers/avatars_helper.rb
@@ -0,0 +1,30 @@
+module AvatarsHelper
+
+ def author_avatar(commit_or_event, options = {})
+ user_avatar(options.merge({
+ user: commit_or_event.author,
+ user_name: commit_or_event.author_name,
+ user_email: commit_or_event.author_email,
+ }))
+ end
+
+ private
+
+ def user_avatar(options = {})
+ avatar_size = options[:size] || 16
+ user_name = options[:user].try(:name) || options[:user_name]
+ avatar = image_tag(
+ avatar_icon(options[:user] || options[:user_email], avatar_size),
+ class: "avatar has-tooltip hidden-xs s#{avatar_size}",
+ alt: "#{user_name}'s avatar",
+ title: user_name
+ )
+
+ if options[:user]
+ link_to(avatar, user_path(options[:user]))
+ elsif options[:user_email]
+ mail_to(options[:user_email], avatar)
+ end
+ end
+
+end
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 474041eccbb..052ce56809e 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -16,16 +16,6 @@ module CommitsHelper
commit_person_link(commit, options.merge(source: :committer))
end
- def commit_author_avatar(commit, options = {})
- options = options.merge(source: :author)
- user = commit.send(options[:source])
-
- source_email = clean(commit.send "#{options[:source]}_email".to_sym)
- person_email = user.try(:email) || source_email
-
- image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]} hidden-xs", width: options[:size], alt: "")
- end
-
def image_diff_class(diff)
if diff.deleted_file
"deleted"