Remove "not allowed" when supporting comments
Hovering over the votes showed a "participation not allowed" message which was annoying when scrolling with the browser or simply moving the mouse around the page. Furthermore, it hid the information about the number of votes, links to show/collapse replies, ... We're planning to change the behavior of all the "participation not allowed" messages in order to show them on click instead of showing them on hover (just like it's done on touchscreens). In the case of comments, supports, however, there's very limited space in the part showing the number of supports for comments, so adding this message without breaking the layout is challenging. So, for now, we're simply redirecting unauthenticated users to the login page. If find an easy way to implement a better user interface in the future to display the "participation not allowed" message, we might change this behaviour.
This commit is contained in:
@@ -126,12 +126,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.reply .participation-not-allowed {
|
||||
padding-right: $line-height / 2;
|
||||
padding-top: $line-height / 6;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// 02. New participation
|
||||
// ---------------------
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
<span class="in-favor">
|
||||
<%= button_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
title: t("votes.agree"),
|
||||
disabled: !can?(:vote, comment) do %>
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.agree") do %>
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
@@ -16,19 +15,10 @@
|
||||
<span class="against">
|
||||
<%= button_to vote_comment_path(comment, value: "no"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
title: t("votes.disagree"),
|
||||
disabled: !can?(:vote, comment) do %>
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.disagree") do %>
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
|
||||
<% unless current_user %>
|
||||
<div tabindex="0">
|
||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||
<%= sanitize(t("votes.comment_unauthenticated", signin: link_to_signin, signup: link_to_signup)) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Comments::VotesComponent < ApplicationComponent
|
||||
attr_reader :comment
|
||||
delegate :current_user, :can?, :link_to_signin, :link_to_signup, to: :helpers
|
||||
delegate :can?, to: :helpers
|
||||
|
||||
def initialize(comment)
|
||||
@comment = comment
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CommentsController < ApplicationController
|
||||
before_action :authenticate_user!, only: [:create, :hide]
|
||||
before_action :authenticate_user!, only: [:create, :hide, :vote]
|
||||
before_action :load_commentable, only: :create
|
||||
before_action :verify_resident_for_commentable!, only: :create
|
||||
before_action :verify_comments_open!, only: [:create, :vote]
|
||||
|
||||
@@ -849,7 +849,6 @@ en:
|
||||
agree: I agree
|
||||
agree_label: "I agree with %{title}"
|
||||
anonymous: Too many anonymous votes to admit vote %{verify_account}.
|
||||
comment_unauthenticated: You must %{signin} or %{signup} to vote.
|
||||
disagree: I disagree
|
||||
disagree_label: "I don't agree with %{title}"
|
||||
organizations: Organizations are not permitted to vote
|
||||
|
||||
@@ -849,7 +849,6 @@ es:
|
||||
agree: Estoy de acuerdo
|
||||
agree_label: "Estoy de acuerdo con %{title}"
|
||||
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
|
||||
comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
|
||||
disagree: No estoy de acuerdo
|
||||
disagree_label: "No estoy de acuerdo con %{title}"
|
||||
organizations: Las organizaciones no pueden votar.
|
||||
|
||||
@@ -4,12 +4,6 @@ module Votes
|
||||
expect(page).to have_selector(".in-favor", obscured: true)
|
||||
end
|
||||
|
||||
def expect_message_you_need_to_sign_in_to_vote_comments
|
||||
within(".participation-not-allowed") do
|
||||
expect(page).to have_content "You must sign in or sign up to vote"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_message_to_many_anonymous_votes
|
||||
expect(page).to have_content "Too many anonymous votes to admit vote"
|
||||
expect(page).to have_button "I agree", obscured: true
|
||||
|
||||
@@ -278,10 +278,12 @@ describe "Votes" do
|
||||
comment = create(:comment, commentable: debate)
|
||||
|
||||
visit comment_path(comment)
|
||||
|
||||
within("#comment_#{comment.id}") do
|
||||
find("div.votes").hover
|
||||
expect_message_you_need_to_sign_in_to_vote_comments
|
||||
click_button "I agree"
|
||||
end
|
||||
|
||||
expect(page).to have_current_path new_user_session_path
|
||||
end
|
||||
|
||||
scenario "Not logged user trying to vote comments in proposals" do
|
||||
@@ -289,10 +291,12 @@ describe "Votes" do
|
||||
comment = create(:comment, commentable: proposal)
|
||||
|
||||
visit comment_path(comment)
|
||||
|
||||
within("#comment_#{comment.id}_reply") do
|
||||
find("div.votes").hover
|
||||
expect_message_you_need_to_sign_in_to_vote_comments
|
||||
click_button "I agree"
|
||||
end
|
||||
|
||||
expect(page).to have_current_path new_user_session_path
|
||||
end
|
||||
|
||||
scenario "Anonymous user trying to vote debates" do
|
||||
|
||||
Reference in New Issue
Block a user