This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #765 from psu-stewardship/sul-accessibility
Making the single-use links more accessible, ref #738
- Loading branch information
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
app/views/curation_concerns/file_sets/_show_actions.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,19 @@ | ||
<div class="form-actions"> | ||
<% if Sufia.config.analytics %> | ||
<%= link_to "Analytics", @presenter.stats_path, id: 'stats', class: 'btn btn-default' %> | ||
<% end %> | ||
<% if Sufia.config.citations %> | ||
<%= link_to "Citations", sufia.citations_work_path(@presenter), id: 'citations', class: 'btn btn-default' %> | ||
<% end %> | ||
<% if @presenter.editor? %> | ||
<%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, @presenter]), | ||
class: 'btn btn-default' %> | ||
<%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, @presenter], | ||
class: 'btn btn-danger', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, | ||
method: :delete %> | ||
<%# Overrides Sufia to remove single-use links button %> | ||
<% end %> | ||
|
||
<%= render 'social_media' %> | ||
</div> | ||
|
22 changes: 22 additions & 0 deletions
22
app/views/curation_concerns/file_sets/_single_use_link_rows.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,22 @@ | ||
<%# Overrides Sufia to provide better accessibility %> | ||
<% single_use_links.each do |presenter| %> | ||
<tr scope="row"> | ||
<td> | ||
<%= t('sufia.single_use_links.expiration_message', link: presenter.short_key, | ||
time: presenter.human_readable_expiration) %> | ||
|
||
<button class="btn btn-xs btn-default copy-single-use-link" | ||
data-clipboard-text="<%= curation_concerns.send(presenter.url_helper, presenter.downloadKey) %>" | ||
data-toggle="tooltip" data-placement="bottom" | ||
title="<%= t('curation_concerns.single_use_links.copy.tooltip') %>" | ||
aria-label="<%= t('sufia.single_use_links.accessibility.copy', link: presenter.short_key) %>"> | ||
<%= t('curation_concerns.single_use_links.copy.button', link: presenter.short_key) %> | ||
</button> | ||
|
||
<%= link_to t('curation_concerns.single_use_links.delete'), | ||
curation_concerns.delete_single_use_link_path(params[:id], presenter), | ||
class: 'btn btn-xs btn-danger delete-single-use-link', | ||
aria: { label: t('sufia.single_use_links.accessibility.delete', link: presenter.short_key) } %> | ||
</td> | ||
</tr> | ||
<% end %> |
23 changes: 23 additions & 0 deletions
23
app/views/curation_concerns/file_sets/_single_use_links.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,23 @@ | ||
<%# Overrides Sufia to provide better accessibility %> | ||
<h3><%= t('curation_concerns.single_use_links.title') %></h3> | ||
|
||
<table class="table table-striped table-condensed <%= dom_class(presenter) %> single-use-links" aria-live="assertive"> | ||
<caption> | ||
Listing of current single-use links to this file | ||
</caption> | ||
<tbody data-url="<%= curation_concerns.generated_single_use_links_path(presenter) %>"> | ||
<% if presenter.single_use_links.present? %> | ||
<%= render 'single_use_link_rows', single_use_links: presenter.single_use_links %> | ||
<% else %> | ||
<tr class="sr-only" scope="row"> | ||
<td><%= t('sufia.single_use_links.accessibility.no_links') %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<div class="form_actions"> | ||
<%= link_to t('sufia.single_use_links.button'), | ||
curation_concerns.generate_download_single_use_link_path(presenter), | ||
class: 'btn btn-default generate-single-use-link' %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
FactoryGirl.define do | ||
factory :single_use_link do | ||
itemId 'fs-id' | ||
path '/downloads/1234' | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
spec/views/curations_concerns/file_sets/_single_use_links.html.erb_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,35 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
describe "curation_concerns/file_sets/_single_use_links.html.erb" do | ||
let(:user) { create(:user) } | ||
let(:solr_doc) { SolrDocument.new(build(:file_set, id: "1234").to_solr) } | ||
let(:ability) { Ability.new(user) } | ||
let(:presenter) { FileSetPresenter.new(solr_doc, ability) } | ||
|
||
context "when no links are present" do | ||
before { render "curation_concerns/file_sets/single_use_links", presenter: presenter } | ||
it "renders accessible text" do | ||
expect(rendered).to have_content("No links present. To create a new link, click Create Single-Use Link") | ||
end | ||
end | ||
|
||
context "when links are present" do | ||
let(:sul_presenter) { CurationConcerns::SingleUseLinkPresenter.new(create(:single_use_link)) } | ||
let(:page) { Capybara::Node::Simple.new(rendered) } | ||
let(:copy_button) { page.find('button.copy-single-use-link')['aria-label'] } | ||
let(:delete_link) { page.find('a.delete-single-use-link')['aria-label'] } | ||
|
||
before do | ||
controller.params = { id: "fs-id" } | ||
allow(presenter).to receive(:single_use_links).and_return([sul_presenter]) | ||
render "curation_concerns/file_sets/single_use_links", presenter: presenter | ||
end | ||
|
||
it "renders accessible actions" do | ||
expect(page).to have_content("Link id #{sul_presenter.short_key} expires in 23 hours") | ||
expect(copy_button).to eq("Copy link id #{sul_presenter.short_key} to clipboard") | ||
expect(delete_link).to eq("Delete link id #{sul_presenter.short_key}") | ||
end | ||
end | ||
end |