Skip to content
Snippets Groups Projects
Commit dbe0d0fb authored by Sam Rose's avatar Sam Rose
Browse files

Disable award emoji button but display tooltip

parent 8dc2163c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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;
Loading
Loading
Loading
Loading
@@ -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
""
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment