Commit db7a063d authored by Fatih Acet's avatar Fatih Acet

Merge branch '26168-emoji-reactions-missing-tooltip-when-not-logged-in' into 'master'

Disable award emoji button but display tooltip

Closes #26168

See merge request !8382
parents 4d253c35 dbe0d0fb
...@@ -97,8 +97,20 @@ ...@@ -97,8 +97,20 @@
padding: 5px 6px; padding: 5px 6px;
outline: 0; outline: 0;
&.disabled {
cursor: default;
&:hover, &:hover,
&:focus,
&:active {
background-color: $white-light;
border-color: $border-color;
box-shadow: none;
}
}
&.active, &.active,
&:hover,
&:active { &:active {
background-color: $row-hover; background-color: $row-hover;
border-color: $row-hover-border; border-color: $row-hover-border;
......
...@@ -128,8 +128,10 @@ module IssuesHelper ...@@ -128,8 +128,10 @@ module IssuesHelper
names.to_sentence names.to_sentence
end end
def award_active_class(awards, current_user) def award_state_class(awards, current_user)
if current_user && awards.find { |a| a.user_id == current_user.id } if !current_user
"disabled"
elsif current_user && awards.find { |a| a.user_id == current_user.id }
"active" "active"
else else
"" ""
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
.awards.js-awards-block{ class: ("hidden" if !inline && grouped_emojis.empty?), data: { award_url: toggle_award_url(awardable) } } .awards.js-awards-block{ class: ("hidden" if !inline && grouped_emojis.empty?), data: { award_url: toggle_award_url(awardable) } }
- awards_sort(grouped_emojis).each do |emoji, awards| - awards_sort(grouped_emojis).each do |emoji, awards|
%button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button", %button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button",
disabled: !current_user, class: (award_state_class(awards, current_user)),
class: (award_active_class(awards, current_user)),
data: { placement: "bottom", title: award_user_list(awards, current_user) } } data: { placement: "bottom", title: award_user_list(awards, current_user) } }
= emoji_icon(emoji, sprite: false) = emoji_icon(emoji, sprite: false)
%span.award-control-text.js-counter %span.award-control-text.js-counter
......
...@@ -76,7 +76,7 @@ describe 'Awards Emoji', feature: true do ...@@ -76,7 +76,7 @@ describe 'Awards Emoji', feature: true do
end end
it 'has disabled emoji button' do it 'has disabled emoji button' do
expect(first('.award-control')[:disabled]).to be(true) expect(first('.award-control')[:class]).to have_text('disabled')
end end
end end
......
...@@ -98,15 +98,15 @@ describe IssuesHelper do ...@@ -98,15 +98,15 @@ describe IssuesHelper do
end end
end end
describe '#award_active_class' do describe '#award_state_class' do
let!(:upvote) { create(:award_emoji) } let!(:upvote) { create(:award_emoji) }
it "returns empty string for unauthenticated user" do it "returns disabled string for unauthenticated user" do
expect(award_active_class(AwardEmoji.all, nil)).to eq("") expect(award_state_class(AwardEmoji.all, nil)).to eq("disabled")
end end
it "returns active string for author" do it "returns active string for author" do
expect(award_active_class(AwardEmoji.all, upvote.user)).to eq("active") expect(award_state_class(AwardEmoji.all, upvote.user)).to eq("active")
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment