debian-mirror-gitlab/app/helpers/award_emoji_helper.rb

21 lines
733 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
module AwardEmojiHelper
def toggle_award_url(awardable)
2017-08-17 22:00:37 +05:30
return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
2016-11-03 12:29:30 +05:30
if awardable.is_a?(Note)
2017-08-17 22:00:37 +05:30
# We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (4.5x)
if awardable.for_personal_snippet?
2020-01-01 13:55:28 +05:30
gitlab_toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
2017-08-17 22:00:37 +05:30
else
2017-09-10 17:25:29 +05:30
toggle_award_emoji_project_note_path(@project, awardable.id)
2017-08-17 22:00:37 +05:30
end
2016-09-29 09:46:39 +05:30
else
2016-11-03 12:29:30 +05:30
url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
2016-09-29 09:46:39 +05:30
end
end
end
2019-12-04 20:38:33 +05:30
AwardEmojiHelper.prepend_if_ee('EE::AwardEmojiHelper')