diff --git a/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/application.scss b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/application.scss index 08a3e85d331..c8df72e4071 100644 --- a/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/application.scss +++ b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/application.scss @@ -4,3 +4,4 @@ @import "components/timeline-component"; @import "views/content_block_manager_header"; +@import "views/content_block_manager_show"; diff --git a/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/components/_timeline-component.scss b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/components/_timeline-component.scss index eb80a5490aa..2bc7c9959e2 100644 --- a/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/components/_timeline-component.scss +++ b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/components/_timeline-component.scss @@ -62,7 +62,8 @@ .timeline__latest { @include govuk-font($size: 19, $weight: bold); - background: #ffdd00; + color: govuk-colour("white"); + background: govuk-colour("blue"); padding: 0.25rem 0.5rem; font-size: 1rem !important; line-height: 1.25 !important; diff --git a/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/views/_content_block_manager_show.scss b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/views/_content_block_manager_show.scss new file mode 100644 index 00000000000..f4f245034d8 --- /dev/null +++ b/lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/views/_content_block_manager_show.scss @@ -0,0 +1,8 @@ +.support-request-wrapper { + display: flex; + + .govuk-button--secondary { + margin-left: auto; + margin-top: govuk-spacing(6); + } +} diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/summary_card_component.rb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/summary_card_component.rb index 6c63b6b2ba3..de938b094ed 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/summary_card_component.rb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/summary_card_component.rb @@ -16,7 +16,7 @@ def items title_item, *details_items, organisation_item, - last_updated_item, + status_item, (instructions_item if content_block_document.latest_edition.instructions_to_publishers.present?), embed_code_item, ].compact diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.html.erb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.html.erb index 1d6c1f76b37..d4c7c0b204d 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.html.erb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.html.erb @@ -1,4 +1,4 @@ -

Previous updates

+

Change history

<% items.each_with_index do |item, i| %> diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.rb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.rb index b1a10c5cd9c..540a81a5565 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.rb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/document_timeline_component.rb @@ -12,7 +12,7 @@ def items content_block_versions.reject { |version| version.state.nil? }.map do |version| { title: title(version), - byline: User.find_by_id(version.whodunnit)&.name || "unknown user", + byline: User.find_by_id(version.whodunnit)&.then { |user| helpers.linked_author(user, { class: "govuk-link" }) } || "unknown user", date: time_html(version.created_at), } end diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.html.erb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.html.erb index 81a9c4b8007..39f348e9655 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.html.erb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/host_editions_table_component.html.erb @@ -13,7 +13,7 @@ it out for now--> sort_direction: sort_direction("title"), }, { - text: "Document Type", + text: "Type", href: sort_link("document_type"), sort_direction: sort_direction("document_type"), }, @@ -23,17 +23,17 @@ it out for now--> sort_direction: sort_direction("instances"), }, { - text: "Unique pageviews", + text: "Views (30 days)", href: sort_link("unique_pageviews"), sort_direction: sort_direction("unique_pageviews"), }, { - text: "Publishing organisation", + text: "Lead organisation", href: sort_link("primary_publishing_organisation_title"), sort_direction: sort_direction("primary_publishing_organisation_title"), }, { - text: "Updated", + text: "Last updated", href: sort_link("last_edited_at"), sort_direction: sort_direction("last_edited_at"), }, diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/summary_list_component.rb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/summary_list_component.rb index 9c55345740c..5d2638b6660 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/summary_list_component.rb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/show/summary_list_component.rb @@ -14,10 +14,8 @@ def items *details_items, organisation_item, instructions_item, - last_updated_item, + status_item, embed_code_item, - state_item, - scheduled_item, ].compact end @@ -69,31 +67,26 @@ def details_items end end - def last_updated_item - { - field: "Last updated", - value: last_updated_value, - } + def status_item + if content_block_document.latest_edition.state == "scheduled" + { + field: "Status", + value: scheduled_value, + } + else + { + field: "Status", + value: last_updated_value, + } + end end def last_updated_value - "#{time_ago_in_words(content_block_document.latest_edition.updated_at)} ago by #{content_block_document.latest_edition.creator.name}" + "Published #{time_ago_in_words(content_block_document.latest_edition.updated_at)} ago by #{content_block_document.latest_edition.creator.name}" end - def state_item - { - field: "State", - value: content_block_document.latest_edition.state.titleize, - } - end - - def scheduled_item - if content_block_document.latest_edition.state == "scheduled" - { - field: "Scheduled for publication at", - value: I18n.l(content_block_document.latest_edition.scheduled_publication, format: :long_ordinal), - } - end + def scheduled_value + "Scheduled for publication at #{I18n.l(content_block_document.latest_edition.scheduled_publication, format: :long_ordinal)}" end def edit_action diff --git a/lib/engines/content_block_manager/app/views/content_block_manager/content_block/documents/show.html.erb b/lib/engines/content_block_manager/app/views/content_block_manager/content_block/documents/show.html.erb index 094081d4962..a610fb564cf 100644 --- a/lib/engines/content_block_manager/app/views/content_block_manager/content_block/documents/show.html.erb +++ b/lib/engines/content_block_manager/app/views/content_block_manager/content_block/documents/show.html.erb @@ -1,10 +1,19 @@ -<% content_for :context, product_name %> -<% content_for :title, "Manage #{add_indefinite_article @content_block_document.block_type.humanize}" %> +<% content_for :context, "View #{@content_block_document.block_type.humanize.downcase}" %> +<% content_for :title, @content_block_document.title %> <% content_for :back_link do %> <%= render "govuk_publishing_components/components/back_link", { href: content_block_manager.content_block_manager_content_block_documents_path, } %> <% end %> +<% content_for :title_side do %> +
+ <%= render "govuk_publishing_components/components/button", { + text: "Raise a support request", + href: support_url, + secondary_solid: true, + } %> +
+<% end %> <%= render( @@ -29,7 +38,7 @@
<%= render( ContentBlockManager::ContentBlock::Document::Show::HostEditionsTableComponent.new( - caption: "Content appears in", + caption: "List of locations", host_content_items: @host_content_items, current_page: @page, order: @order, diff --git a/lib/engines/content_block_manager/features/step_definitions/content_block_manager_steps.rb b/lib/engines/content_block_manager/features/step_definitions/content_block_manager_steps.rb index c89f15cdca3..6b7a9d51c21 100644 --- a/lib/engines/content_block_manager/features/step_definitions/content_block_manager_steps.rb +++ b/lib/engines/content_block_manager/features/step_definitions/content_block_manager_steps.rb @@ -308,7 +308,7 @@ end Then("I should see the details for the email address content block") do - assert_text "Manage an Email address" + assert_text "View email address" should_show_summary_list_for_email_address_content_block( @content_block.document.title, @@ -367,7 +367,7 @@ def should_show_summary_list_for_email_address_content_block(document_title, ema expect(page).to have_selector(".govuk-summary-list__key", text: "Instructions to publishers") expect(page).to have_selector(".govuk-summary-list__value", text: instructions_to_publishers) end - expect(page).to have_selector(".govuk-summary-list__key", text: "Last updated") + expect(page).to have_selector(".govuk-summary-list__key", text: "Status") expect(page).to have_selector(".govuk-summary-list__value", text: @user.name) end @@ -465,7 +465,7 @@ def should_show_edit_form_for_email_address_content_block(document_title, email_ end Then(/^I should see the dependent content listed$/) do - assert_text "Content appears in" + assert_text "List of locations" @dependent_content.each do |item| assert_text item["title"] @@ -625,12 +625,12 @@ def should_show_edit_form_for_email_address_content_block(document_title, email_ Then("published state of the object is shown") do visit content_block_manager.content_block_manager_content_block_document_path(@content_block.document) - expect(page).to have_selector(".govuk-summary-list__key", text: "State") + expect(page).to have_selector(".govuk-summary-list__key", text: "Status") expect(page).to have_selector(".govuk-summary-list__value", text: "Published") end Then("I should see the scheduled date on the object") do - expect(page).to have_selector(".govuk-summary-list__key", text: "Scheduled for publication at") + expect(page).to have_selector(".govuk-summary-list__key", text: "Status") expect(page).to have_selector(".govuk-summary-list__value", text: I18n.l(@future_date, format: :long_ordinal).squish) end diff --git a/lib/engines/content_block_manager/test/components/content_block/document/index/summary_card_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/index/summary_card_component_test.rb index 94ca744bbcb..b5053aa3f7e 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/index/summary_card_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/index/summary_card_component_test.rb @@ -47,8 +47,8 @@ class ContentBlockManager::ContentBlock::Document::Index::SummaryCardComponentTe assert_no_selector ".govuk-summary-list__key", text: "Instructions to publishers" assert_no_selector ".govuk-summary-list__value", text: "None" - assert_selector ".govuk-summary-list__key", text: "Last updated" - assert_selector ".govuk-summary-list__value", text: "1 day ago by #{content_block_edition.creator.name}" + assert_selector ".govuk-summary-list__key", text: "Status" + assert_selector ".govuk-summary-list__value", text: "Published 1 day ago by #{content_block_edition.creator.name}" assert_selector ".govuk-summary-list__row[data-module='copy-embed-code']", text: "Embed code" assert_selector ".govuk-summary-list__row[data-embed-code='#{content_block_document.embed_code}']", text: "Embed code" diff --git a/lib/engines/content_block_manager/test/components/content_block/document/show/document_timeline_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/show/document_timeline_component_test.rb index f71a3876963..8e23cbe7fcb 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/show/document_timeline_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/show/document_timeline_component_test.rb @@ -1,6 +1,10 @@ require "test_helper" class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineComponentTest < ViewComponent::TestCase + include Rails.application.routes.url_helpers + include ActionView::Helpers::UrlHelper + include ApplicationHelper + test "renders a timeline component with events in correct order" do @user = create(:user) @version_1 = create( @@ -28,12 +32,12 @@ class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineCompone assert_selector ".timeline__item", count: 2 assert_equal "Email address scheduled", page.all(".timeline__title")[0].text - assert_equal "by #{@user.name}", page.all(".timeline__byline")[0].text + assert_equal "by #{linked_author(@user, { class: 'govuk-link' })}", page.all(".timeline__byline")[0].native.inner_html assert_equal I18n.l(@version_3.created_at, format: :long_ordinal), page.all("time[datetime='#{@version_3.created_at.iso8601}']")[1].text assert_equal "Email address published", page.all(".timeline__title")[1].text - assert_equal "by #{@user.name}", page.all(".timeline__byline")[1].text + assert_equal "by #{linked_author(@user, { class: 'govuk-link' })}", page.all(".timeline__byline")[1].native.inner_html assert_equal I18n.l(@version_2.created_at, format: :long_ordinal), page.all("time[datetime='#{@version_2.created_at.iso8601}']")[1].text end diff --git a/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb index 82884197dd8..27e075ce0c2 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/show/host_editions_table_component_test.rb @@ -221,13 +221,13 @@ def self.it_returns_unknown_user ) assert_selector "a.app-table__sort-link[href*='order=title']", text: "Title" - assert_selector "a.app-table__sort-link[href*='order=document_type']", text: "Document Type" + assert_selector "a.app-table__sort-link[href*='order=document_type']", text: "Type" assert_selector "a.app-table__sort-link[href*='order=instances']", text: "Instances" - assert_selector "a.app-table__sort-link[href*='order=unique_pageviews']", text: "Unique pageviews" - assert_selector "a.app-table__sort-link[href*='order=primary_publishing_organisation_title']", text: "Publishing organisation" - assert_selector "a.app-table__sort-link[href*='order=last_edited_at']", text: "Updated" + assert_selector "a.app-table__sort-link[href*='order=unique_pageviews']", text: "Views (30 days)" + assert_selector "a.app-table__sort-link[href*='order=primary_publishing_organisation_title']", text: "Lead organisation" + assert_selector "a.app-table__sort-link[href*='order=last_edited_at']", text: "Last updated" - assert_selector ".govuk-table__header--active a", text: "Unique pageviews" + assert_selector ".govuk-table__header--active a", text: "Views (30 days)" end %w[title document_type unique_pageviews primary_publishing_organisation_title last_edited_at instances].each do |order| diff --git a/lib/engines/content_block_manager/test/components/content_block/document/show/summary_list_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/show/summary_list_component_test.rb index ff64b6614f7..4d3b8775b32 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/show/summary_list_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/show/summary_list_component_test.rb @@ -21,7 +21,7 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes it "renders a published content block correctly" do render_inline(ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent.new(content_block_document:)) - assert_selector ".govuk-summary-list__row", count: 9 + assert_selector ".govuk-summary-list__row", count: 8 assert_selector ".govuk-summary-list__actions", count: 1 assert_selector ".govuk-summary-list__key", text: "Email address details" @@ -39,8 +39,8 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes assert_selector ".govuk-summary-list__key", text: "Lead organisation" assert_selector ".govuk-summary-list__value", text: "Department for Example" - assert_selector ".govuk-summary-list__key", text: "Last updated" - assert_selector ".govuk-summary-list__value", text: "1 day ago by #{content_block_edition.creator.name}" + assert_selector ".govuk-summary-list__key", text: "Status" + assert_selector ".govuk-summary-list__value", text: "Published 1 day ago by #{content_block_edition.creator.name}" assert_selector ".govuk-summary-list__key", text: "Instructions to publishers" assert_selector ".govuk-summary-list__value", text: "None" @@ -49,9 +49,6 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes assert_selector ".govuk-summary-list__row[data-embed-code='#{content_block_document.embed_code}']", text: "Embed code" assert_selector ".govuk-summary-list__key", text: "Embed code" assert_selector ".govuk-summary-list__value", text: content_block_document.embed_code - - assert_selector ".govuk-summary-list__key", text: "State" - assert_selector ".govuk-summary-list__value", text: content_block_edition.state.titleize end it "renders a scheduled content block correctly" do @@ -59,10 +56,10 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes render_inline(ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent.new(content_block_document:)) - assert_selector ".govuk-summary-list__row", count: 10 + assert_selector ".govuk-summary-list__row", count: 8 - assert_selector ".govuk-summary-list__key", text: "Scheduled for publication at" - assert_selector ".govuk-summary-list__value", text: I18n.l(content_block_edition.scheduled_publication, format: :long_ordinal) + assert_selector ".govuk-summary-list__key", text: "Status" + assert_selector ".govuk-summary-list__value", text: "Scheduled for publication at #{I18n.l(content_block_edition.scheduled_publication, format: :long_ordinal)}" end describe "when there are instructions to publishers" do