Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6c1ed00a
Commit
6c1ed00a
authored
Jul 11, 2016
by
Jack Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Award tooltips refer to current user as "You"
parent
1fc17a8a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
25 deletions
+25
-25
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+8
-8
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+2
-2
features/steps/project/issues/award_emoji.rb
features/steps/project/issues/award_emoji.rb
+1
-1
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+4
-4
spec/javascripts/awards_handler_spec.js
spec/javascripts/awards_handler_spec.js
+10
-10
No files found.
app/assets/javascripts/awards_handler.js
View file @
6c1ed00a
...
...
@@ -131,7 +131,7 @@
counter
=
$emojiButton
.
find
(
'
.js-counter
'
);
counter
.
text
(
parseInt
(
counter
.
text
())
+
1
);
$emojiButton
.
addClass
(
'
active
'
);
this
.
add
Me
ToUserList
(
votesBlock
,
emoji
);
this
.
add
You
ToUserList
(
votesBlock
,
emoji
);
return
this
.
animateEmoji
(
$emojiButton
);
}
}
else
{
...
...
@@ -177,11 +177,11 @@
counterNumber
=
parseInt
(
counter
.
text
(),
10
);
if
(
counterNumber
>
1
)
{
counter
.
text
(
counterNumber
-
1
);
this
.
remove
Me
FromUserList
(
$emojiButton
,
emoji
);
this
.
remove
You
FromUserList
(
$emojiButton
,
emoji
);
}
else
if
(
emoji
===
'
thumbsup
'
||
emoji
===
'
thumbsdown
'
)
{
$emojiButton
.
tooltip
(
'
destroy
'
);
counter
.
text
(
'
0
'
);
this
.
remove
Me
FromUserList
(
$emojiButton
,
emoji
);
this
.
remove
You
FromUserList
(
$emojiButton
,
emoji
);
if
(
$emojiButton
.
parents
(
'
.note
'
).
length
)
{
this
.
removeEmoji
(
$emojiButton
);
}
...
...
@@ -214,17 +214,17 @@
}
};
AwardsHandler
.
prototype
.
remove
Me
FromUserList
=
function
(
$emojiButton
,
emoji
)
{
AwardsHandler
.
prototype
.
remove
You
FromUserList
=
function
(
$emojiButton
,
emoji
)
{
var
authors
,
awardBlock
,
newAuthors
,
originalTitle
;
awardBlock
=
$emojiButton
;
originalTitle
=
this
.
getAwardTooltip
(
awardBlock
);
authors
=
originalTitle
.
split
(
FROM_SENTENCE_REGEX
);
authors
.
splice
(
authors
.
indexOf
(
'
me
'
),
1
);
authors
.
splice
(
authors
.
indexOf
(
'
You
'
),
1
);
awardBlock
.
closest
(
'
.js-emoji-btn
'
).
removeData
(
'
original-title
'
).
attr
(
'
data-original-title
'
,
this
.
toSentence
(
authors
));
return
this
.
resetTooltip
(
awardBlock
);
};
AwardsHandler
.
prototype
.
add
Me
ToUserList
=
function
(
votesBlock
,
emoji
)
{
AwardsHandler
.
prototype
.
add
You
ToUserList
=
function
(
votesBlock
,
emoji
)
{
var
awardBlock
,
origTitle
,
users
;
awardBlock
=
this
.
findEmojiIcon
(
votesBlock
,
emoji
).
parent
();
origTitle
=
this
.
getAwardTooltip
(
awardBlock
);
...
...
@@ -232,7 +232,7 @@
if
(
origTitle
)
{
users
=
origTitle
.
trim
().
split
(
FROM_SENTENCE_REGEX
);
}
users
.
unshift
(
'
me
'
);
users
.
unshift
(
'
You
'
);
awardBlock
.
attr
(
'
title
'
,
this
.
toSentence
(
users
));
return
this
.
resetTooltip
(
awardBlock
);
};
...
...
@@ -249,7 +249,7 @@
AwardsHandler
.
prototype
.
createEmoji_
=
function
(
votesBlock
,
emoji
)
{
var
$emojiButton
,
buttonHtml
,
emojiCssClass
;
emojiCssClass
=
this
.
resolveNameToCssClass
(
emoji
);
buttonHtml
=
"
<button class='btn award-control js-emoji-btn has-tooltip active' title='
me
' data-placement='bottom'> <div class='icon emoji-icon
"
+
emojiCssClass
+
"
' data-emoji='
"
+
emoji
+
"
'></div> <span class='award-control-text js-counter'>1</span> </button>
"
;
buttonHtml
=
"
<button class='btn award-control js-emoji-btn has-tooltip active' title='
You
' data-placement='bottom'> <div class='icon emoji-icon
"
+
emojiCssClass
+
"
' data-emoji='
"
+
emoji
+
"
'></div> <span class='award-control-text js-counter'>1</span> </button>
"
;
$emojiButton
=
$
(
buttonHtml
);
$emojiButton
.
insertBefore
(
votesBlock
.
find
(
'
.js-award-holder
'
)).
find
(
'
.emoji-icon
'
).
data
(
'
emoji
'
,
emoji
);
this
.
animateEmoji
(
$emojiButton
);
...
...
app/helpers/issues_helper.rb
View file @
6c1ed00a
...
...
@@ -115,11 +115,11 @@ module IssuesHelper
def
award_user_list
(
awards
,
current_user
)
names
=
awards
.
map
do
|
award
|
award
.
user
==
current_user
?
'
me
'
:
award
.
user
.
name
award
.
user
==
current_user
?
'
You
'
:
award
.
user
.
name
end
# Take first 9 OR current user + first 9
current_user_name
=
names
.
delete
(
'
me
'
)
current_user_name
=
names
.
delete
(
'
You
'
)
names
=
names
.
first
(
9
).
insert
(
0
,
current_user_name
).
compact
names
<<
"
#{
awards
.
size
-
names
.
size
}
more."
if
awards
.
size
>
names
.
size
...
...
features/steps/project/issues/award_emoji.rb
View file @
6c1ed00a
...
...
@@ -48,7 +48,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
page
.
within
'.awards'
do
expect
(
page
).
to
have_selector
'.js-emoji-btn'
expect
(
page
.
find
(
'.js-emoji-btn.active .js-counter'
)).
to
have_content
'1'
expect
(
page
).
to
have_css
(
".js-emoji-btn.active[data-original-title='
me
']"
)
expect
(
page
).
to
have_css
(
".js-emoji-btn.active[data-original-title='
You
']"
)
end
end
...
...
spec/helpers/issues_helper_spec.rb
View file @
6c1ed00a
...
...
@@ -69,8 +69,8 @@ describe IssuesHelper do
expect
(
award_user_list
(
awards
.
first
(
9
),
nil
)).
to
eq
(
awards
.
first
(
9
).
map
{
|
a
|
a
.
user
.
name
}.
to_sentence
)
end
it
"displays the current user's name as '
me
'"
do
expect
(
award_user_list
(
awards
.
first
(
1
),
awards
[
0
].
user
)).
to
eq
(
'
me
'
)
it
"displays the current user's name as '
You
'"
do
expect
(
award_user_list
(
awards
.
first
(
1
),
awards
[
0
].
user
)).
to
eq
(
'
You
'
)
end
it
"truncates lists of larger than 9 users"
do
...
...
@@ -79,12 +79,12 @@ describe IssuesHelper do
it
"displays the current user in front of 0-9 other users"
do
expect
(
award_user_list
(
awards
,
awards
[
0
].
user
)).
to
eq
(
"
me
, "
+
awards
[
1
..
9
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
to
eq
(
"
You
, "
+
awards
[
1
..
9
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
end
it
"displays the current user in front regardless of position in the list"
do
expect
(
award_user_list
(
awards
,
awards
[
12
].
user
)).
to
eq
(
"
me
, "
+
awards
[
0
..
8
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
to
eq
(
"
You
, "
+
awards
[
0
..
8
].
map
{
|
a
|
a
.
user
.
name
}.
join
(
', '
)
+
", and 5 more."
)
end
end
...
...
spec/javascripts/awards_handler_spec.js
View file @
6c1ed00a
...
...
@@ -143,8 +143,8 @@
return
expect
(
$votesBlock
.
find
(
'
[data-emoji=fire]
'
).
length
).
toBe
(
0
);
});
});
describe
(
'
::add
Me
ToUserList
'
,
function
()
{
it
(
'
should prepend "
me
" to the award tooltip
'
,
function
()
{
describe
(
'
::add
You
ToUserList
'
,
function
()
{
it
(
'
should prepend "
You
" to the award tooltip
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
...
...
@@ -152,9 +152,9 @@
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam, jerry, max, and andy
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
me
, sam, jerry, max, and andy
'
);
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
You
, sam, jerry, max, and andy
'
);
});
return
it
(
'
handles the special case where "
me
" is not cleanly comma seperated
'
,
function
()
{
return
it
(
'
handles the special case where "
You
" is not cleanly comma seperated
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
...
...
@@ -162,27 +162,27 @@
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
sam
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
me
and sam
'
);
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
You
and sam
'
);
});
});
describe
(
'
::remove
Me
ToUserList
'
,
function
()
{
it
(
'
removes "
me
" from the front of the tooltip
'
,
function
()
{
describe
(
'
::remove
You
ToUserList
'
,
function
()
{
it
(
'
removes "
You
" from the front of the tooltip
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
me
, sam, jerry, max, and andy
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
You
, sam, jerry, max, and andy
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
return
expect
(
$thumbsUpEmoji
.
data
(
"
original-title
"
)).
toBe
(
'
sam, jerry, max, and andy
'
);
});
return
it
(
'
handles the special case where "
me
" is not cleanly comma seperated
'
,
function
()
{
return
it
(
'
handles the special case where "
You
" is not cleanly comma seperated
'
,
function
()
{
var
$thumbsUpEmoji
,
$votesBlock
,
awardUrl
;
awardUrl
=
awardsHandler
.
getAwardUrl
();
$votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
$thumbsUpEmoji
=
$votesBlock
.
find
(
'
[data-emoji=thumbsup]
'
).
parent
();
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
me
and sam
'
);
$thumbsUpEmoji
.
attr
(
'
data-title
'
,
'
You
and sam
'
);
$thumbsUpEmoji
.
addClass
(
'
active
'
);
awardsHandler
.
addAward
(
$votesBlock
,
awardUrl
,
'
thumbsup
'
,
false
);
$thumbsUpEmoji
.
tooltip
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment