diff --git a/app/components/admin/edition_images/uploaded_images_component.html.erb b/app/components/admin/edition_images/uploaded_images_component.html.erb index ba0d9838f22..adacdb4b3e7 100644 --- a/app/components/admin/edition_images/uploaded_images_component.html.erb +++ b/app/components/admin/edition_images/uploaded_images_component.html.erb @@ -21,6 +21,7 @@ <% if lead_image %>
Caption: <%= lead_image[:caption] %>
@@ -66,6 +67,7 @@Caption: <%= image[:caption] %>
diff --git a/app/components/admin/edition_images/uploaded_images_component.rb b/app/components/admin/edition_images/uploaded_images_component.rb index 62cdacde269..c21e366ed26 100644 --- a/app/components/admin/edition_images/uploaded_images_component.rb +++ b/app/components/admin/edition_images/uploaded_images_component.rb @@ -49,6 +49,10 @@ def lead_image_guidance private + def all_image_asset_variants_uploaded?(image) + image.image_data.all_asset_variants_uploaded? if image.image_data.present? + end + def image_to_hash(image, index) { url: image.url, @@ -57,6 +61,7 @@ def image_to_hash(image, index) alt_text: image.alt_text.presence || "None", markdown: unique_names? ? "[Image: #{image.filename}]" : "!!#{index}", links: links_for_image(image), + all_image_asset_variants_uploaded: all_image_asset_variants_uploaded?(image), } end diff --git a/test/components/admin/edition_images/uploaded_images_component_test.rb b/test/components/admin/edition_images/uploaded_images_component_test.rb index 97d46bbd51d..3bbc27b18f5 100644 --- a/test/components/admin/edition_images/uploaded_images_component_test.rb +++ b/test/components/admin/edition_images/uploaded_images_component_test.rb @@ -44,4 +44,20 @@ class Admin::EditionImages::UploadedImagesComponentTest < ViewComponent::TestCas assert_selector "input[value='!!1']" assert_selector "input[value='!!2']" end + + test "shows \"Processing\" label where image assets (variants) are still uploading" do + lead_image_data_with_no_assets = build(:image_data, use_non_legacy_endpoints: true) + regular_image_data_with_no_assets = build(:image_data, use_non_legacy_endpoints: true) + regular_image_data_with_assets = build(:image_data_with_assets) + images = [ + build_stubbed(:image, image_data: lead_image_data_with_no_assets), + build_stubbed(:image, image_data: regular_image_data_with_no_assets), + build_stubbed(:image, image_data: regular_image_data_with_assets), + ] + edition = build_stubbed(:draft_publication, images:) + + render_inline(Admin::EditionImages::UploadedImagesComponent.new(edition:)) + + assert_text "Processing", count: 2 + end end