From f61e42dc7e9a374c79d42a1d925795366114db58 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Fri, 17 Nov 2023 15:26:23 -0500 Subject: [PATCH] Display message when item is converting --- app/javascript/components/Ramp.jsx | 193 ++++++++++---------- app/models/iiif_canvas_presenter.rb | 10 + app/views/media_objects/_item_view.html.erb | 3 +- config/locales/en.yml | 1 + spec/models/iiif_canvas_presenter_spec.rb | 18 +- 5 files changed, 124 insertions(+), 101 deletions(-) diff --git a/app/javascript/components/Ramp.jsx b/app/javascript/components/Ramp.jsx index 57e3dbb3a4..d9d84f63d5 100644 --- a/app/javascript/components/Ramp.jsx +++ b/app/javascript/components/Ramp.jsx @@ -47,7 +47,6 @@ const Ramp = ({ share, timeline, playlist, - in_progress, cdl, has_files, has_transcripts @@ -122,110 +121,108 @@ const Ramp = ({ return ( - {!in_progress && - - { (cdl.enabled && !cdl.can_stream) - ? (
) - : ( - { master_files_count > 0 && - - -
- {
} -
-
- - { timeline.canCreate && - - } - { share.canShare && - - } - { playlist.canCreate && - - } - - { has_structure && - - - + + { (cdl.enabled && !cdl.can_stream) + ? (
) + : ( + { master_files_count > 0 && + + +
+ {
} +
+
+ + { timeline.canCreate && + } -
- - -
- - -
-
-
- - -
-
-
+ { share.canShare && + + } + { playlist.canCreate && + + } + + { has_structure && + + - - - - } - - ) - } - - } - + } +
+ + +
+ + +
+
+
+ + +
+
+
+ + + + + } + + ) + } + + { cdl.enabled &&
} - { (cdl.can_stream && master_files_count != 0 && !in_progress && has_transcripts) && + { (cdl.can_stream && master_files_count != 0 && has_transcripts) && <% end %>
-
+
<%= react_component("Ramp", { base_url: request.protocol+request.host_with_port, @@ -49,7 +49,6 @@ Unless required by applicable law or agreed to in writing, software distributed share: { canShare: (will_partial_list_render? :share), content: lending_enabled?(@media_object) ? (render('share') if can_stream) : render('share') }, timeline: { canCreate: (current_ability.can? :create, Timeline), content: lending_enabled?(@media_object) ? (render('timeline') if can_stream) : render('timeline') }, playlist: { canCreate: (current_ability.can? :create, Playlist), tab: render('add_to_playlist') }, - in_progress: in_progress, cdl: { enabled: lending_enabled?(@media_object), can_stream: can_stream, embed: render('embed_checkout'), destroy: render('destroy_checkout') }, has_files: @media_object.supplemental_files.present? || @media_object.sections_with_files.present?, has_transcripts: @media_object.sections_with_files(tag: 'transcript').present? diff --git a/config/locales/en.yml b/config/locales/en.yml index edd35fb42d..a6c6b535c8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -29,6 +29,7 @@ en: empty_share_link: "" empty_share_link_notice: "After processing has started the embedded link will be available." empty_share_section_permalink_notice: "After processing has started the section link will be available." + conversion_msg: "This item is still processing. Please check back later." cdl: checkout_message: "

Borrow this item to access media resources.

" not_available_message: "

This resource is currently checked out by another user.

This item is due to be returned on
.

" diff --git a/spec/models/iiif_canvas_presenter_spec.rb b/spec/models/iiif_canvas_presenter_spec.rb index 2c4099f997..46a7b8e665 100644 --- a/spec/models/iiif_canvas_presenter_spec.rb +++ b/spec/models/iiif_canvas_presenter_spec.rb @@ -158,7 +158,7 @@ end context 'when master file does not have derivatives' do - let(:master_file) { FactoryBot.build(:master_file, media_object: media_object) } + let(:master_file) { FactoryBot.build(:master_file, :completed_processing, media_object: media_object) } it 'has format' do expect(subject.format).to eq "text/plain" @@ -172,6 +172,22 @@ expect(subject.label).to eq I18n.t('errors.missing_derivatives_error') % [Settings.email.support, Settings.email.support] end end + + context 'when master file is processing' do + let(:master_file) { FactoryBot.build(:master_file, media_object: media_object) } + + it 'has format' do + expect(subject.format).to eq "text/plain" + end + + it 'has type' do + expect(subject.type).to eq "Text" + end + + it 'has label' do + expect(subject.label).to eq I18n.t('media_object.conversion_msg') + end + end end describe 'Supplemental file handling' do