Merge branch 'award-emoji-fixes' into 'master'
Award emoji fixes Fixes #18357 #18325 and #18424 See merge request !4550
This commit is contained in:
commit
cea3cf177c
6 changed files with 17 additions and 19 deletions
|
@ -271,5 +271,6 @@ $ ->
|
||||||
.on "resize", (e) ->
|
.on "resize", (e) ->
|
||||||
fitSidebarForSize()
|
fitSidebarForSize()
|
||||||
|
|
||||||
|
gl.awardsHandler = new AwardsHandler()
|
||||||
checkInitialSidebarSize()
|
checkInitialSidebarSize()
|
||||||
new Aside()
|
new Aside()
|
||||||
|
|
|
@ -65,7 +65,7 @@ class @AwardsHandler
|
||||||
$addBtn.removeClass 'is-loading'
|
$addBtn.removeClass 'is-loading'
|
||||||
$menu = $('.emoji-menu')
|
$menu = $('.emoji-menu')
|
||||||
@positionMenu($menu, $addBtn)
|
@positionMenu($menu, $addBtn)
|
||||||
@renderFrequentlyUsedBlock()
|
@renderFrequentlyUsedBlock() unless @frequentEmojiBlockRendered
|
||||||
|
|
||||||
setTimeout =>
|
setTimeout =>
|
||||||
$menu.addClass 'is-visible'
|
$menu.addClass 'is-visible'
|
||||||
|
@ -100,7 +100,7 @@ class @AwardsHandler
|
||||||
$menu.css(css)
|
$menu.css(css)
|
||||||
|
|
||||||
|
|
||||||
addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes, callback) ->
|
addAward: (votesBlock, awardUrl, emoji, checkMutuality = true, callback) ->
|
||||||
|
|
||||||
emoji = @normilizeEmojiName emoji
|
emoji = @normilizeEmojiName emoji
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class @AwardsHandler
|
||||||
$('.emoji-menu').removeClass 'is-visible'
|
$('.emoji-menu').removeClass 'is-visible'
|
||||||
|
|
||||||
|
|
||||||
addAwardToEmojiBar: (votesBlock, emoji, checkForMutuality = yes) ->
|
addAwardToEmojiBar: (votesBlock, emoji, checkForMutuality = true) ->
|
||||||
|
|
||||||
@checkMutuality votesBlock, emoji if checkForMutuality
|
@checkMutuality votesBlock, emoji if checkForMutuality
|
||||||
@addEmojiToFrequentlyUsedList emoji
|
@addEmojiToFrequentlyUsedList emoji
|
||||||
|
@ -153,7 +153,7 @@ class @AwardsHandler
|
||||||
|
|
||||||
if isAlreadyVoted
|
if isAlreadyVoted
|
||||||
@showEmojiLoader $emojiButton
|
@showEmojiLoader $emojiButton
|
||||||
@addAward votesBlock, awardUrl, mutualVote, no, ->
|
@addAward votesBlock, awardUrl, mutualVote, false, ->
|
||||||
$emojiButton.removeClass 'is-loading'
|
$emojiButton.removeClass 'is-loading'
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ class @AwardsHandler
|
||||||
@createEmojiMenu @getAwardMenuUrl(), => @createEmoji_ votesBlock, emoji
|
@createEmojiMenu @getAwardMenuUrl(), => @createEmoji_ votesBlock, emoji
|
||||||
|
|
||||||
|
|
||||||
getAwardMenuUrl: -> return gl.awardMenuUrl
|
getAwardMenuUrl: -> return gon.award_menu_url
|
||||||
|
|
||||||
|
|
||||||
resolveNameToCssClass: (emoji) ->
|
resolveNameToCssClass: (emoji) ->
|
||||||
|
@ -336,13 +336,15 @@ class @AwardsHandler
|
||||||
if $.cookie 'frequently_used_emojis'
|
if $.cookie 'frequently_used_emojis'
|
||||||
frequentlyUsedEmojis = @getFrequentlyUsedEmojis()
|
frequentlyUsedEmojis = @getFrequentlyUsedEmojis()
|
||||||
|
|
||||||
ul = $("<ul class='clearfix emoji-menu-list'>")
|
ul = $("<ul class='clearfix emoji-menu-list frequent-emojis'>")
|
||||||
|
|
||||||
for emoji in frequentlyUsedEmojis
|
for emoji in frequentlyUsedEmojis
|
||||||
$(".emoji-menu-content [data-emoji='#{emoji}']").closest('li').clone().appendTo(ul)
|
$(".emoji-menu-content [data-emoji='#{emoji}']").closest('li').clone().appendTo(ul)
|
||||||
|
|
||||||
$('input.emoji-search').after(ul).after($('<h5>').text('Frequently used'))
|
$('input.emoji-search').after(ul).after($('<h5>').text('Frequently used'))
|
||||||
|
|
||||||
|
@frequentEmojiBlockRendered = true
|
||||||
|
|
||||||
|
|
||||||
setupSearch: ->
|
setupSearch: ->
|
||||||
|
|
||||||
|
@ -365,4 +367,4 @@ class @AwardsHandler
|
||||||
|
|
||||||
searchEmojis: (term) ->
|
searchEmojis: (term) ->
|
||||||
|
|
||||||
$(".emoji-menu-content [data-emoji*='#{term}']").closest('li').clone()
|
$(".emoji-menu-list:not(.frequent-emojis) [data-emoji*='#{term}']").closest('li').clone()
|
||||||
|
|
|
@ -23,7 +23,6 @@ class Dispatcher
|
||||||
new Issue()
|
new Issue()
|
||||||
shortcut_handler = new ShortcutsIssuable()
|
shortcut_handler = new ShortcutsIssuable()
|
||||||
new ZenMode()
|
new ZenMode()
|
||||||
gl.awardsHandler = new AwardsHandler()
|
|
||||||
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
|
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
|
||||||
new Milestone()
|
new Milestone()
|
||||||
when 'dashboard:todos:index'
|
when 'dashboard:todos:index'
|
||||||
|
@ -54,7 +53,6 @@ class Dispatcher
|
||||||
new Diff()
|
new Diff()
|
||||||
shortcut_handler = new ShortcutsIssuable(true)
|
shortcut_handler = new ShortcutsIssuable(true)
|
||||||
new ZenMode()
|
new ZenMode()
|
||||||
gl.awardsHandler = new AwardsHandler()
|
|
||||||
when "projects:merge_requests:diffs"
|
when "projects:merge_requests:diffs"
|
||||||
new Diff()
|
new Diff()
|
||||||
new ZenMode()
|
new ZenMode()
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
= awards.count
|
= awards.count
|
||||||
|
|
||||||
- if current_user
|
- if current_user
|
||||||
:javascript
|
|
||||||
gl.awardMenuUrl = "#{emojis_path}"
|
|
||||||
|
|
||||||
.award-menu-holder.js-award-holder
|
.award-menu-holder.js-award-holder
|
||||||
%button.btn.award-control.js-add-award{ type: "button" }
|
%button.btn.award-control.js-add-award{ type: "button" }
|
||||||
= icon('smile-o', class: "award-control-icon award-control-icon-normal")
|
= icon('smile-o', class: "award-control-icon award-control-icon-normal")
|
||||||
|
|
|
@ -8,6 +8,7 @@ module Gitlab
|
||||||
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
|
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
|
||||||
gon.shortcuts_path = help_shortcuts_path
|
gon.shortcuts_path = help_shortcuts_path
|
||||||
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
|
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
|
||||||
|
gon.award_menu_url = emojis_path
|
||||||
|
|
||||||
if current_user
|
if current_user
|
||||||
gon.current_user_id = current_user.id
|
gon.current_user_id = current_user.id
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
awardsHandler = null
|
awardsHandler = null
|
||||||
window.gl or= {}
|
window.gl or= {}
|
||||||
|
window.gon or= {}
|
||||||
gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' }
|
gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' }
|
||||||
gl.awardMenuUrl = '/emojis'
|
gon.award_menu_url = '/emojis'
|
||||||
|
|
||||||
|
|
||||||
lazyAssert = (done, assertFn) ->
|
lazyAssert = (done, assertFn) ->
|
||||||
|
@ -25,9 +26,7 @@ describe 'AwardsHandler', ->
|
||||||
fixture.load 'awards_handler.html'
|
fixture.load 'awards_handler.html'
|
||||||
awardsHandler = new AwardsHandler
|
awardsHandler = new AwardsHandler
|
||||||
spyOn(awardsHandler, 'postEmoji').and.callFake (url, emoji, cb) => cb()
|
spyOn(awardsHandler, 'postEmoji').and.callFake (url, emoji, cb) => cb()
|
||||||
spyOn(jQuery, 'get').and.callFake (req, cb) ->
|
spyOn(jQuery, 'get').and.callFake (req, cb) -> cb window.emojiMenu
|
||||||
expect(req).toBe '/emojis'
|
|
||||||
cb window.emojiMenu
|
|
||||||
|
|
||||||
|
|
||||||
describe '::showEmojiMenu', ->
|
describe '::showEmojiMenu', ->
|
||||||
|
|
Loading…
Reference in a new issue