diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-06-09 23:21:50 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-06-09 23:21:50 +0000 |
commit | cea3cf177c68bb1fa9326d4e88631b7737ae8a98 (patch) | |
tree | 7c98808bc4188586063232bff9b024731eb25df8 | |
parent | e328eab0da46f1a5d4fbf2289911ce8f4093cfb6 (diff) | |
parent | 94826d9abe13a20aae0868a096a03d2a4e706d82 (diff) | |
download | gitlab-ce-cea3cf177c68bb1fa9326d4e88631b7737ae8a98.tar.gz |
Merge branch 'award-emoji-fixes' into 'master'
Award emoji fixes
Fixes #18357 #18325 and #18424
See merge request !4550
-rw-r--r-- | app/assets/javascripts/application.js.coffee | 1 | ||||
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 16 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 2 | ||||
-rw-r--r-- | app/views/award_emoji/_awards_block.html.haml | 3 | ||||
-rw-r--r-- | lib/gitlab/gon_helper.rb | 1 | ||||
-rw-r--r-- | spec/javascripts/awards_handler_spec.js.coffee | 13 |
6 files changed, 17 insertions, 19 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 7609236c13d..b28327ce12d 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -271,5 +271,6 @@ $ -> .on "resize", (e) -> fitSidebarForSize() + gl.awardsHandler = new AwardsHandler() checkInitialSidebarSize() new Aside() diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index efa8f6cd010..136db8ee14d 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -65,7 +65,7 @@ class @AwardsHandler $addBtn.removeClass 'is-loading' $menu = $('.emoji-menu') @positionMenu($menu, $addBtn) - @renderFrequentlyUsedBlock() + @renderFrequentlyUsedBlock() unless @frequentEmojiBlockRendered setTimeout => $menu.addClass 'is-visible' @@ -100,7 +100,7 @@ class @AwardsHandler $menu.css(css) - addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes, callback) -> + addAward: (votesBlock, awardUrl, emoji, checkMutuality = true, callback) -> emoji = @normilizeEmojiName emoji @@ -111,7 +111,7 @@ class @AwardsHandler $('.emoji-menu').removeClass 'is-visible' - addAwardToEmojiBar: (votesBlock, emoji, checkForMutuality = yes) -> + addAwardToEmojiBar: (votesBlock, emoji, checkForMutuality = true) -> @checkMutuality votesBlock, emoji if checkForMutuality @addEmojiToFrequentlyUsedList emoji @@ -153,7 +153,7 @@ class @AwardsHandler if isAlreadyVoted @showEmojiLoader $emojiButton - @addAward votesBlock, awardUrl, mutualVote, no, -> + @addAward votesBlock, awardUrl, mutualVote, false, -> $emojiButton.removeClass 'is-loading' @@ -282,7 +282,7 @@ class @AwardsHandler @createEmojiMenu @getAwardMenuUrl(), => @createEmoji_ votesBlock, emoji - getAwardMenuUrl: -> return gl.awardMenuUrl + getAwardMenuUrl: -> return gon.award_menu_url resolveNameToCssClass: (emoji) -> @@ -336,13 +336,15 @@ class @AwardsHandler if $.cookie 'frequently_used_emojis' frequentlyUsedEmojis = @getFrequentlyUsedEmojis() - ul = $("<ul class='clearfix emoji-menu-list'>") + ul = $("<ul class='clearfix emoji-menu-list frequent-emojis'>") for emoji in frequentlyUsedEmojis $(".emoji-menu-content [data-emoji='#{emoji}']").closest('li').clone().appendTo(ul) $('input.emoji-search').after(ul).after($('<h5>').text('Frequently used')) + @frequentEmojiBlockRendered = true + setupSearch: -> @@ -365,4 +367,4 @@ class @AwardsHandler searchEmojis: (term) -> - $(".emoji-menu-content [data-emoji*='#{term}']").closest('li').clone() + $(".emoji-menu-list:not(.frequent-emojis) [data-emoji*='#{term}']").closest('li').clone() diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index 5d6ac6e757e..29ac0f70b30 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -23,7 +23,6 @@ class Dispatcher new Issue() shortcut_handler = new ShortcutsIssuable() new ZenMode() - gl.awardsHandler = new AwardsHandler() when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show' new Milestone() when 'dashboard:todos:index' @@ -54,7 +53,6 @@ class Dispatcher new Diff() shortcut_handler = new ShortcutsIssuable(true) new ZenMode() - gl.awardsHandler = new AwardsHandler() when "projects:merge_requests:diffs" new Diff() new ZenMode() diff --git a/app/views/award_emoji/_awards_block.html.haml b/app/views/award_emoji/_awards_block.html.haml index 84fd146a26b..02efcecc889 100644 --- a/app/views/award_emoji/_awards_block.html.haml +++ b/app/views/award_emoji/_awards_block.html.haml @@ -7,9 +7,6 @@ = awards.count - if current_user - :javascript - gl.awardMenuUrl = "#{emojis_path}" - .award-menu-holder.js-award-holder %button.btn.award-control.js-add-award{ type: "button" } = icon('smile-o', class: "award-control-icon award-control-icon-normal") diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index ab900b641c4..f751a3a12fd 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -8,6 +8,7 @@ module Gitlab gon.relative_url_root = Gitlab.config.gitlab.relative_url_root gon.shortcuts_path = help_shortcuts_path gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class + gon.award_menu_url = emojis_path if current_user gon.current_user_id = current_user.id diff --git a/spec/javascripts/awards_handler_spec.js.coffee b/spec/javascripts/awards_handler_spec.js.coffee index 0bd6d696387..ba191199dc7 100644 --- a/spec/javascripts/awards_handler_spec.js.coffee +++ b/spec/javascripts/awards_handler_spec.js.coffee @@ -3,10 +3,11 @@ #= require jquery.cookie #= require ./fixtures/emoji_menu -awardsHandler = null -window.gl or= {} -gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' } -gl.awardMenuUrl = '/emojis' +awardsHandler = null +window.gl or= {} +window.gon or= {} +gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' } +gon.award_menu_url = '/emojis' lazyAssert = (done, assertFn) -> @@ -25,9 +26,7 @@ describe 'AwardsHandler', -> fixture.load 'awards_handler.html' awardsHandler = new AwardsHandler spyOn(awardsHandler, 'postEmoji').and.callFake (url, emoji, cb) => cb() - spyOn(jQuery, 'get').and.callFake (req, cb) -> - expect(req).toBe '/emojis' - cb window.emojiMenu + spyOn(jQuery, 'get').and.callFake (req, cb) -> cb window.emojiMenu describe '::showEmojiMenu', -> |