From ae912979dc2bd1c81db7a3e0e1da75ceb22691e5 Mon Sep 17 00:00:00 2001 From: syed-ali-tw Date: Mon, 30 Sep 2024 12:07:04 +0100 Subject: [PATCH] Revert "Move metadata functionality to new design system" This reverts commit 6c49914564231a149a98c490f4ffa19eee67d752. --- app/assets/stylesheets/application.scss | 1 - app/controllers/artefacts_controller.rb | 11 +---- app/controllers/editions_controller.rb | 9 ++-- app/helpers/tabbed_nav_helper.rb | 14 +----- .../secondary_nav_tabs/_metadata.html.erb | 44 ------------------- .../_temp_nav_text.html.erb | 1 - app/views/editions/show.html.erb | 4 -- test/functional/editions_controller_test.rb | 21 +-------- test/integration/edition_edit_test.rb | 37 +++------------- 9 files changed, 17 insertions(+), 125 deletions(-) delete mode 100644 app/views/editions/secondary_nav_tabs/_metadata.html.erb delete mode 100644 app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index c24594d38..d403b16d5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -23,7 +23,6 @@ $govuk-page-width: 1140px; @import 'govuk_publishing_components/components/lead-paragraph'; @import 'govuk_publishing_components/components/notice'; @import 'govuk_publishing_components/components/previous-and-next-navigation'; -@import 'govuk_publishing_components/components/radio'; @import 'govuk_publishing_components/components/search'; @import 'govuk_publishing_components/components/secondary-navigation'; @import 'govuk_publishing_components/components/select'; diff --git a/app/controllers/artefacts_controller.rb b/app/controllers/artefacts_controller.rb index cd369cf76..f4ca8f26f 100644 --- a/app/controllers/artefacts_controller.rb +++ b/app/controllers/artefacts_controller.rb @@ -18,11 +18,10 @@ def update artefact = Artefact.find(updatable_params[:id]) if artefact.update_as(current_user, updatable_params) UpdateWorker.perform_async(artefact.latest_edition_id) - show_success_message + flash[:notice] = "Metadata updated" else flash[:danger] = artefact.errors.full_messages.join("\n") end - redirect_to metadata_artefact_path(artefact) end @@ -30,14 +29,6 @@ def update private - def show_success_message - if FeatureConstraint.new("design_system_edit") - flash[:success] = "Metadata has successfully updated".html_safe - else - flash[:notice] = "Metadata updated" - end - end - def formats Artefact::FORMATS_BY_DEFAULT_OWNING_APP["publisher"] - Artefact::RETIRED_FORMATS end diff --git a/app/controllers/editions_controller.rb b/app/controllers/editions_controller.rb index d89e13cca..ddbb55dd5 100644 --- a/app/controllers/editions_controller.rb +++ b/app/controllers/editions_controller.rb @@ -1,5 +1,7 @@ +require "edition_duplicator" +require "edition_progressor" + class EditionsController < InheritedResources::Base - include TabbedNavHelper layout "design_system" defaults resource_class: Edition, collection_name: "editions", instance_name: "resource" @@ -11,11 +13,12 @@ def index def show @artefact = @resource.artefact - render action: "show" end - alias_method :metadata, :show + def metadata + render action: "show" + end def history render action: "show" diff --git a/app/helpers/tabbed_nav_helper.rb b/app/helpers/tabbed_nav_helper.rb index 13d95b6e8..e733afd7d 100644 --- a/app/helpers/tabbed_nav_helper.rb +++ b/app/helpers/tabbed_nav_helper.rb @@ -1,8 +1,9 @@ module TabbedNavHelper def edition_nav_items(edition) nav_items = [] + items = %w[edit tagging metadata history admin related_external_links unpublish] - all_tab_names.each do |item| + items.each do |item| nav_items << standard_nav_items(item, edition) end @@ -28,15 +29,4 @@ def edit_nav_item(label, href, current) }, ] end - - def current_tab_name - current_tab = (request.path.split("/") & all_tab_names).first - current_tab == "metadata" ? "metadata" : "temp_nav_text" - end - -private - - def all_tab_names - %w[edit tagging metadata history admin related_external_links unpublish] - end end diff --git a/app/views/editions/secondary_nav_tabs/_metadata.html.erb b/app/views/editions/secondary_nav_tabs/_metadata.html.erb deleted file mode 100644 index 01f29bab9..000000000 --- a/app/views/editions/secondary_nav_tabs/_metadata.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<%= render "govuk_publishing_components/components/heading", { - text: "Metadata", - heading_level: 2, - margin_bottom: 5, -} %> - -<% if Edition::PUBLISHING_API_DRAFT_STATES.include? publication.state %> - <%= form_for(@artefact, :html => { :class => "artefact", :id => "edit_artefact" }) do |f| %> - <%= f.hidden_field :id, value: @artefact.id %> - - <%= render "govuk_publishing_components/components/input", { - label: { - text: "Slug", - }, - hint: "If you change the slug of a published page, the old slug will automatically redirect to the new one.", - name: "artefact[slug]", - value: publication.slug, - heading_level: 2, - heading_size: "m", - } %> - - <%= render "govuk_publishing_components/components/radio", { - heading: "Language", - name: "artefact[language]", - inline: true, - items: [ - { - value: "en", - text: "English", - checked: publication.artefact.language == "en" ? true : false, - }, - { - value: "cy", - text: "Welsh", - checked: publication.artefact.language == "cy" ? true : false, - }, - ], - } %> - <%= render "govuk_publishing_components/components/button", { - text: "Update", - } %> - <% end %> -<% else %> -<% end %> diff --git a/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb b/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb deleted file mode 100644 index 58e0b9c8a..000000000 --- a/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb +++ /dev/null @@ -1 +0,0 @@ -

Work in progress

diff --git a/app/views/editions/show.html.erb b/app/views/editions/show.html.erb index 3335165bc..2f0c0fedb 100644 --- a/app/views/editions/show.html.erb +++ b/app/views/editions/show.html.erb @@ -26,8 +26,4 @@
<%= render partial: "secondary_navigation" %>
- -
- <%= render partial: "secondary_nav_tabs/#{current_tab_name}", :locals => { :publication => @resource } %> -
diff --git a/test/functional/editions_controller_test.rb b/test/functional/editions_controller_test.rb index acb752939..6fee5ee07 100644 --- a/test/functional/editions_controller_test.rb +++ b/test/functional/editions_controller_test.rb @@ -26,14 +26,14 @@ class EditionsControllerTest < ActionController::TestCase context "#show" do setup do - artefact = FactoryBot.create( + artefact2 = FactoryBot.create( :artefact, slug: "test2", kind: "guide", name: "test", owning_app: "publisher", ) - @guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact.id) + @guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact2.id) end should "requesting a publication that doesn't exist returns a 404" do @@ -47,21 +47,4 @@ class EditionsControllerTest < ActionController::TestCase assert_not_nil assigns(:resource) end end - - context "#metadata" do - setup do - artefact = FactoryBot.create( - :artefact, - slug: "test2", - kind: "guide", - name: "test", - owning_app: "publisher", - ) - @guide = GuideEdition.create!(title: "test", slug: "test2", panopticon_id: artefact.id) - end - - should "alias to show method" do - assert EditionsController.new.method(:metadata).super_method.name.eql?(:show) - end - end end diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index 443147b3f..ee5a529dc 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -6,11 +6,12 @@ class EditionEditTest < IntegrationTest test_strategy = Flipflop::FeatureSet.current.test! test_strategy.switch!(:design_system_edit, true) stub_linkables - edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft") - visit edition_path(edition) end should "show document summary and title" do + edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft") + visit edition_path(edition) + assert page.has_title?("Edit page title") row = find_all(".govuk-summary-list__row") @@ -23,6 +24,9 @@ class EditionEditTest < IntegrationTest end should "show all the tabs for the edit" do + edition = FactoryBot.create(:guide_edition, title: "Edit page title", state: "draft") + visit edition_path(edition) + assert page.has_text?("Edit") assert page.has_text?("Tagging") assert page.has_text?("Metadata") @@ -31,33 +35,4 @@ class EditionEditTest < IntegrationTest assert page.has_text?("Related external links") assert page.has_text?("Unpublish") end - - context "#metadata" do - setup do - click_link("Metadata") - end - - should "'Metadata' header and an update button" do - within :css, ".gem-c-heading" do - assert page.has_text?("Metadata") - end - assert page.has_button?("Update") - end - - should "show slug input box prefilled" do - assert page.has_text?("Slug") - assert page.has_text?("If you change the slug of a published page, the old slug will automatically redirect to the new one.") - assert page.has_field?("artefact[slug]", with: /slug/) - end - - should "update and show success message" do - fill_in "artefact[slug]", with: "changed-slug" - choose("Welsh") - click_button("Update") - - assert find(".gem-c-radio input[value='cy']").checked? - assert page.has_text?("Metadata has successfully updated") - assert page.has_field?("artefact[slug]", with: "changed-slug") - end - end end