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:
Javi Martín
2022-02-18 16:59:38 +01:00
parent ecd34ca6ce
commit 168575d606
8 changed files with 14 additions and 34 deletions

View File

@@ -126,12 +126,6 @@
} }
} }
.reply .participation-not-allowed {
padding-right: $line-height / 2;
padding-top: $line-height / 6;
text-align: right;
}
// 02. New participation // 02. New participation
// --------------------- // ---------------------

View File

@@ -5,9 +5,8 @@
<span class="in-favor"> <span class="in-favor">
<%= button_to vote_comment_path(comment, value: "yes"), <%= button_to vote_comment_path(comment, value: "yes"),
method: "post", method: "post",
remote: true, remote: can?(:vote, comment),
title: t("votes.agree"), title: t("votes.agree") do %>
disabled: !can?(:vote, comment) do %>
<span class="show-for-sr"><%= t("votes.agree") %></span> <span class="show-for-sr"><%= t("votes.agree") %></span>
<% end %> <% end %>
<%= comment.total_likes %> <%= comment.total_likes %>
@@ -16,19 +15,10 @@
<span class="against"> <span class="against">
<%= button_to vote_comment_path(comment, value: "no"), <%= button_to vote_comment_path(comment, value: "no"),
method: "post", method: "post",
remote: true, remote: can?(:vote, comment),
title: t("votes.disagree"), title: t("votes.disagree") do %>
disabled: !can?(:vote, comment) do %>
<span class="show-for-sr"><%= t("votes.disagree") %></span> <span class="show-for-sr"><%= t("votes.disagree") %></span>
<% end %> <% end %>
<%= comment.total_dislikes %> <%= comment.total_dislikes %>
</span> </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> </div>

View File

@@ -1,6 +1,6 @@
class Comments::VotesComponent < ApplicationComponent class Comments::VotesComponent < ApplicationComponent
attr_reader :comment attr_reader :comment
delegate :current_user, :can?, :link_to_signin, :link_to_signup, to: :helpers delegate :can?, to: :helpers
def initialize(comment) def initialize(comment)
@comment = comment @comment = comment

View File

@@ -1,5 +1,5 @@
class CommentsController < ApplicationController 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 :load_commentable, only: :create
before_action :verify_resident_for_commentable!, only: :create before_action :verify_resident_for_commentable!, only: :create
before_action :verify_comments_open!, only: [:create, :vote] before_action :verify_comments_open!, only: [:create, :vote]

View File

@@ -849,7 +849,6 @@ en:
agree: I agree agree: I agree
agree_label: "I agree with %{title}" agree_label: "I agree with %{title}"
anonymous: Too many anonymous votes to admit vote %{verify_account}. anonymous: Too many anonymous votes to admit vote %{verify_account}.
comment_unauthenticated: You must %{signin} or %{signup} to vote.
disagree: I disagree disagree: I disagree
disagree_label: "I don't agree with %{title}" disagree_label: "I don't agree with %{title}"
organizations: Organizations are not permitted to vote organizations: Organizations are not permitted to vote

View File

@@ -849,7 +849,6 @@ es:
agree: Estoy de acuerdo agree: Estoy de acuerdo
agree_label: "Estoy de acuerdo con %{title}" agree_label: "Estoy de acuerdo con %{title}"
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}. 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: No estoy de acuerdo
disagree_label: "No estoy de acuerdo con %{title}" disagree_label: "No estoy de acuerdo con %{title}"
organizations: Las organizaciones no pueden votar. organizations: Las organizaciones no pueden votar.

View File

@@ -4,12 +4,6 @@ module Votes
expect(page).to have_selector(".in-favor", obscured: true) expect(page).to have_selector(".in-favor", obscured: true)
end 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 def expect_message_to_many_anonymous_votes
expect(page).to have_content "Too many anonymous votes to admit vote" expect(page).to have_content "Too many anonymous votes to admit vote"
expect(page).to have_button "I agree", obscured: true expect(page).to have_button "I agree", obscured: true

View File

@@ -278,10 +278,12 @@ describe "Votes" do
comment = create(:comment, commentable: debate) comment = create(:comment, commentable: debate)
visit comment_path(comment) visit comment_path(comment)
within("#comment_#{comment.id}") do within("#comment_#{comment.id}") do
find("div.votes").hover click_button "I agree"
expect_message_you_need_to_sign_in_to_vote_comments
end end
expect(page).to have_current_path new_user_session_path
end end
scenario "Not logged user trying to vote comments in proposals" do scenario "Not logged user trying to vote comments in proposals" do
@@ -289,10 +291,12 @@ describe "Votes" do
comment = create(:comment, commentable: proposal) comment = create(:comment, commentable: proposal)
visit comment_path(comment) visit comment_path(comment)
within("#comment_#{comment.id}_reply") do within("#comment_#{comment.id}_reply") do
find("div.votes").hover click_button "I agree"
expect_message_you_need_to_sign_in_to_vote_comments
end end
expect(page).to have_current_path new_user_session_path
end end
scenario "Anonymous user trying to vote debates" do scenario "Anonymous user trying to vote debates" do