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 @@
padding: 5px 6px;
outline: 0;
&:hover,
&.disabled {
cursor: default;
&:hover,
&:focus,
&:active {
background-color: $white-light;
border-color: $border-color;
box-shadow: none;
}
}
&.active,
&:hover,
&:active {
background-color: $row-hover;
border-color: $row-hover-border;
......
......@@ -128,8 +128,10 @@ module IssuesHelper
names.to_sentence
end
def award_active_class(awards, current_user)
if current_user && awards.find { |a| a.user_id == current_user.id }
def award_state_class(awards, current_user)
if !current_user
"disabled"
elsif current_user && awards.find { |a| a.user_id == current_user.id }
"active"
else
""
......
......@@ -2,8 +2,7 @@
.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|
%button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button",
disabled: !current_user,
class: (award_active_class(awards, current_user)),
class: (award_state_class(awards, current_user)),
data: { placement: "bottom", title: award_user_list(awards, current_user) } }
= emoji_icon(emoji, sprite: false)
%span.award-control-text.js-counter
......
......@@ -76,7 +76,7 @@ describe 'Awards Emoji', feature: true do
end
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
......
......@@ -98,15 +98,15 @@ describe IssuesHelper do
end
end
describe '#award_active_class' do
describe '#award_state_class' do
let!(:upvote) { create(:award_emoji) }
it "returns empty string for unauthenticated user" do
expect(award_active_class(AwardEmoji.all, nil)).to eq("")
it "returns disabled string for unauthenticated user" do
expect(award_state_class(AwardEmoji.all, nil)).to eq("disabled")
end
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
......
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