-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add account permissions hint for screen reader users #4902
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.permissions-list { | ||
list-style-type: none; | ||
margin-bottom: 0; | ||
margin-left: 0; | ||
|
||
li { | ||
font-size: $small-font-size; | ||
margin-bottom: $line-height / 2; | ||
|
||
&::before { | ||
font-size: 0.9em; | ||
margin-#{$global-right}: 0.2em; | ||
} | ||
|
||
&.permission-allowed { | ||
@include has-fa-icon(check, solid); | ||
|
||
&::before { | ||
color: $check; | ||
} | ||
} | ||
|
||
&.permission-denied { | ||
@include has-fa-icon(times, solid); | ||
|
||
&::before { | ||
color: $delete; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/components/account/permissions_list_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<ul class="permissions-list"> | ||
<% permissions.each do |text, allowed| %> | ||
<li class="<%= allowed_class(allowed) %>"> | ||
<% unless allowed %> | ||
<span class="show-for-sr"><%= t("verification.verification_needed") %></span> | ||
<% end %> | ||
|
||
<%= text %> | ||
</li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Account::PermissionsListComponent < ApplicationComponent | ||
attr_reader :user | ||
|
||
def initialize(user) | ||
@user = user | ||
end | ||
|
||
private | ||
|
||
def permissions | ||
{ | ||
t("verification.user_permission_debates") => true, | ||
t("verification.user_permission_proposal") => true, | ||
t("verification.user_permission_support_proposal") => user.level_two_or_three_verified?, | ||
t("verification.user_permission_votes") => user.level_three_verified? | ||
} | ||
end | ||
|
||
def allowed_class(allowed) | ||
if allowed | ||
"permission-allowed" | ||
else | ||
"permission-denied" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
<%# # Parameters: | ||
# message: A string explaining the permissions | ||
# permissions: An array of symbols containing the permissions | ||
# (can be :debates, :proposal, :support_proposal, :votes) %> | ||
<div class="user-permissions"> | ||
|
||
<p><%= message %></p> | ||
|
||
<ul> | ||
<% [:debates, :proposal, :support_proposal, :votes].each do |permission| %> | ||
<li> | ||
<span class="<%= permissions.include?(permission) ? "icon-check" : "icon-x" %>"></span> | ||
<%= t("verification.user_permission_#{permission}") %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<%= render Account::PermissionsListComponent.new(user) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spec/components/account/permissions_list_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "rails_helper" | ||
|
||
describe Account::PermissionsListComponent do | ||
it "adds different classes for actions that can and cannot be performed" do | ||
render_inline Account::PermissionsListComponent.new(User.new) | ||
|
||
expect(page).to have_css "li.permission-allowed", text: "Participate in debates" | ||
expect(page).to have_css "li.permission-denied", text: "Support proposals" | ||
end | ||
|
||
it "adds a hint when an action cannot be performed" do | ||
render_inline Account::PermissionsListComponent.new(User.new) | ||
|
||
expect(page).to have_css "li", exact_text: "Additional verification needed Support proposals", normalize_ws: true | ||
expect(page).to have_css "li", exact_text: "Participate in debates", normalize_ws: true | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LineLength: Line is too long. [117/110] (https://rubystyle.guide#max-line-length)