<% end %>
<% end %>
diff --git a/app/components/model_component.rb b/app/components/model_component.rb
index 7b5bd9fca..ea251cd24 100644
--- a/app/components/model_component.rb
+++ b/app/components/model_component.rb
@@ -8,8 +8,4 @@ def initialize(viewer:)
attr_reader :viewer
delegate :purl_object, to: :viewer
-
- def viewable_content?
- viewer.three_dimensional_files.any?
- end
end
diff --git a/app/components/pdf_component.html.erb b/app/components/pdf_component.html.erb
index 93eaa0f22..ce722ff5a 100644
--- a/app/components/pdf_component.html.erb
+++ b/app/components/pdf_component.html.erb
@@ -8,21 +8,19 @@
<% end %>
<% component.with_authorization_messages do %>
- <%= render CompanionWindows::AuthorizationMessagesComponent.new(available: viewer.available?) %>
+ <%= render CompanionWindows::AuthorizationMessagesComponent.new %>
<% end %>
<% component.with_body do %>
-
>
+
<%= render LockedStatusComponent.new %>
- <% if viewer.available? %>
-
-
- <% end %>
+
+
<% end %>
diff --git a/app/components/restricted_message_component.html.erb b/app/components/restricted_message_component.html.erb
new file mode 100644
index 000000000..fa4600fe8
--- /dev/null
+++ b/app/components/restricted_message_component.html.erb
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/app/components/restricted_message_component.rb b/app/components/restricted_message_component.rb
new file mode 100644
index 000000000..374d7c9e3
--- /dev/null
+++ b/app/components/restricted_message_component.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class RestrictedMessageComponent < ViewComponent::Base
+end
diff --git a/app/javascript/controllers/file_auth_controller.js b/app/javascript/controllers/file_auth_controller.js
index ca2be4247..b85b113e4 100644
--- a/app/javascript/controllers/file_auth_controller.js
+++ b/app/javascript/controllers/file_auth_controller.js
@@ -136,10 +136,9 @@ export default class extends Controller {
.then((result) => this.renderViewer(result))
.catch((authResponse) => {
- // Intercept the response and check for location restriction before trying to log in, because
- // logging in won't help the fact that we're not in an authorized location.
- if (this.isLocationRestricted(authResponse))
- return this.authDenied(authResponse, accessService)
+ // Intercept the response and check for files that can't be accessed before trying to log in, because
+ // logging in won't help the fact that we're not in an authorized location/file is no download/embargoed (without stanford login).
+ if (authResponse.status == '403') return this.authDenied(authResponse, accessService)
// Check if non-expired token already exists in local storage,
// and if it exists, query probe service with it
@@ -258,12 +257,4 @@ export default class extends Controller {
const event = new CustomEvent('auth-denied', { detail: { accessService, authResponse } } )
window.dispatchEvent(event)
}
-
- // Checks the result of the probe auth request to see if access is restricted to location
- // This code depends on the text returned by probe service, so changes to the heading
- // should be reflected here as well.
- isLocationRestricted(json) {
- return json.status == '401' && 'heading' in json && 'en' in json.heading && json.heading.en.length
- && json.heading.en[0].startsWith('Access is restricted to the')
- }
}
diff --git a/app/javascript/controllers/iiif_auth_restriction_controller.js b/app/javascript/controllers/iiif_auth_restriction_controller.js
index b3f67cc0c..be9f2477d 100644
--- a/app/javascript/controllers/iiif_auth_restriction_controller.js
+++ b/app/javascript/controllers/iiif_auth_restriction_controller.js
@@ -2,7 +2,7 @@ import { Controller } from "@hotwired/stimulus"
// Display auth controls for the file_auth_controller.js
export default class extends Controller {
- static targets = ["locationRestriction", "locationRestrictionMessage", "messagePanel", "loginPanel",
+ static targets = ["restrictedContainer", "restrictedMessage", "restrictedIcon", "messagePanel", "loginPanel",
"loginButton", "loginMessage"]
// Bound to auth-denied CustomEvents
@@ -11,20 +11,21 @@ export default class extends Controller {
this.resetMessages()
const detail = event.detail
- this.locationRestrictionTarget.hidden = false
- this.locationRestrictionMessageTarget.innerHTML = this.#retrieveAuthResponseMessage(detail.authResponse)
+ this.restrictedContainerTarget.hidden = false
+ this.restrictedMessageTarget.innerHTML = this.#retrieveAuthResponseMessage(detail.authResponse)
+ this.restrictedIconTarget.innerHTML = detail.authResponse['icon']
}
resetMessages() {
this.hideLoginPrompt()
this.hideMessagePanel()
- this.clearLocationRestriction()
+ this.clearRestrictedMessage()
}
// Called when switching to a new file
- clearLocationRestriction() {
- this.locationRestrictionTarget.hidden = true
+ clearRestrictedMessage() {
+ this.restrictedContainerTarget.hidden = true
}
// Allow the user to dismiss the message
diff --git a/app/viewers/embed/viewer/document_viewer.rb b/app/viewers/embed/viewer/document_viewer.rb
index da4409068..649373f62 100644
--- a/app/viewers/embed/viewer/document_viewer.rb
+++ b/app/viewers/embed/viewer/document_viewer.rb
@@ -27,13 +27,6 @@ def fullscreen?
true
end
- # This indicates if the first PDF is downloadable (though it could be stanford only)
- # as well as location restricted. Authorization for other documents will be
- # checked as the user clicks on items in the content side bar.
- def available?
- !document_resource_files.first&.no_download?
- end
-
private
def document_resource_files
diff --git a/spec/components/companion_windows/content_list_component_spec.rb b/spec/components/companion_windows/content_list_component_spec.rb
index 7d77ab3e4..decf2fbb2 100644
--- a/spec/components/companion_windows/content_list_component_spec.rb
+++ b/spec/components/companion_windows/content_list_component_spec.rb
@@ -40,8 +40,8 @@
end
describe '#resource_files_collection' do
- it 'returns a list of all purl objects that do not have no_download? returning true' do
- expect(component.resource_files_collection).to eq([download_file])
+ it 'returns a list of all purl objects' do
+ expect(component.resource_files_collection).to eq([no_download_file, download_file])
end
end
end
diff --git a/spec/components/pdf_component_spec.rb b/spec/components/pdf_component_spec.rb
index 494921da6..58c3fd8b9 100644
--- a/spec/components/pdf_component_spec.rb
+++ b/spec/components/pdf_component_spec.rb
@@ -26,7 +26,7 @@
end
it 'includes access restriction method section' do
- expect(page).to have_css('div[data-iiif-auth-restriction-target="locationRestriction"]', visible: :all)
+ expect(page).to have_css('div[data-iiif-auth-restriction-target="restrictedContainer"]', visible: :all)
end
context 'when hide_title is passed' do
diff --git a/spec/components/location_restriction_component_spec.rb b/spec/components/restricted_message_component_spec.rb
similarity index 74%
rename from spec/components/location_restriction_component_spec.rb
rename to spec/components/restricted_message_component_spec.rb
index a1df3bac7..e04e961bc 100644
--- a/spec/components/location_restriction_component_spec.rb
+++ b/spec/components/restricted_message_component_spec.rb
@@ -2,17 +2,17 @@
require 'rails_helper'
-RSpec.describe LocationRestrictionComponent, type: :component do
+RSpec.describe RestrictedMessageComponent, type: :component do
before do
render_inline(described_class.new)
end
# The location restriction banner is hidden so search with visible: :all
it 'renders banner target for the file auth controller' do
- expect(page).to have_css('div[data-iiif-auth-restriction-target="locationRestriction"]', visible: :all)
+ expect(page).to have_css('div[data-iiif-auth-restriction-target="restrictedContainer"]', visible: :all)
end
it 'renders message target for the file auth controller' do
- expect(page).to have_css('p[data-iiif-auth-restriction-target="locationRestrictionMessage"]', visible: :all)
+ expect(page).to have_css('p[data-iiif-auth-restriction-target="restrictedMessage"]', visible: :all)
end
end
diff --git a/spec/features/document_viewer_spec.rb b/spec/features/document_viewer_spec.rb
index 78ed97a19..c5de414d6 100644
--- a/spec/features/document_viewer_spec.rb
+++ b/spec/features/document_viewer_spec.rb
@@ -15,12 +15,4 @@
expect(page).to have_css('.sul-embed-pdf')
end
end
-
- context 'when no download' do
- let(:purl) { build(:purl, :document_no_download) }
-
- it 'renders the PDF viewer for documents with restriction message' do
- expect(page).to have_content('This item cannot be accessed online')
- end
- end
end
diff --git a/spec/lib/embed/viewer/document_viewer_spec.rb b/spec/lib/embed/viewer/document_viewer_spec.rb
index 94303fd5e..432833889 100644
--- a/spec/lib/embed/viewer/document_viewer_spec.rb
+++ b/spec/lib/embed/viewer/document_viewer_spec.rb
@@ -32,48 +32,4 @@
expect(pdf_viewer.pdf_files.last).to match(%r{/file/druid:abc123/doc-xyz321\.pdf})
end
end
-
- describe '#available?' do
- context 'when the first file in the documents is location restricted and downloadable' do
- let(:purl) do
- instance_double(
- Embed::Purl,
- contents: [
- instance_double(Embed::Purl::Resource, type: 'document', files: [instance_double(Embed::Purl::ResourceFile, title: 'doc-abc123.pdf', location_restricted?: true, no_download?: false)])
- ],
- druid: 'abc123'
- )
- end
-
- it { expect(pdf_viewer.available?).to be true }
- end
-
- context 'when the first file in the document is not location restricted and downloadable' do
- let(:purl) do
- instance_double(
- Embed::Purl,
- contents: [
- instance_double(Embed::Purl::Resource, type: 'document', files: [instance_double(Embed::Purl::ResourceFile, title: 'doc-abc123.pdf', location_restricted?: false, no_download?: false)])
- ],
- druid: 'abc123'
- )
- end
-
- it { expect(pdf_viewer.available?).to be true }
- end
-
- context 'when the first file in the document is not downloadable' do
- let(:purl) do
- instance_double(
- Embed::Purl,
- contents: [
- instance_double(Embed::Purl::Resource, type: 'document', files: [instance_double(Embed::Purl::ResourceFile, title: 'doc-abc123.pdf', location_restricted?: false, no_download?: true)])
- ],
- druid: 'abc123'
- )
- end
-
- it { expect(pdf_viewer.available?).to be false }
- end
- end
end