From 7582afa84b00c8f3c0fb41ddd6e1e621823fdeea Mon Sep 17 00:00:00 2001 From: pezholio Date: Fri, 29 Nov 2024 16:38:41 +0000 Subject: [PATCH 1/2] Add a show_link_to_content_block_manager flag This will allow us to enable/disable the link to the Content Block Manager for user testing. It will be enabled by default in Staging/Integration. --- config/features.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/features.rb b/config/features.rb index 435093733..a95dbbc1a 100644 --- a/config/features.rb +++ b/config/features.rb @@ -20,4 +20,8 @@ feature :restrict_access_by_org, default: false, description: "Restrict access to editions based on the user's org and which org(s) own the edition" + + feature :show_link_to_content_block_manager, + default: %w[integration staging].include?(ENV["GOVUK_ENVIRONMENT"]), + description: "Shows link to Content Block Manager from Mainstream editor" end From 7400b3b52314f342e275e60be4932379abce2fc4 Mon Sep 17 00:00:00 2001 From: pezholio Date: Fri, 29 Nov 2024 16:39:18 +0000 Subject: [PATCH 2/2] Add content block guidance in the sidebar This is only added if the feature flag is set. --- .../_content_block_guidance.html.erb | 8 ++++++ app/views/legacy_editions/show.html.erb | 4 +++ test/integration/edition_edit_test.rb | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 app/views/legacy_editions/_content_block_guidance.html.erb diff --git a/app/views/legacy_editions/_content_block_guidance.html.erb b/app/views/legacy_editions/_content_block_guidance.html.erb new file mode 100644 index 000000000..af6e4afe5 --- /dev/null +++ b/app/views/legacy_editions/_content_block_guidance.html.erb @@ -0,0 +1,8 @@ +

Content block

+ +
+

+ To create, edit and use standardised content, go to the + <%= link_to "Content Block Manager (opens in new tab)", "#{Plek.external_url_for('whitehall-admin')}/content-block-manager", target: "_blank", rel: "noopener" %>. +

+
diff --git a/app/views/legacy_editions/show.html.erb b/app/views/legacy_editions/show.html.erb index 0aa1d214b..bb7ed19b6 100644 --- a/app/views/legacy_editions/show.html.erb +++ b/app/views/legacy_editions/show.html.erb @@ -41,6 +41,10 @@
<%= render "shared/govspeak_help" %>
+ + <% if Flipflop.show_link_to_content_block_manager? %> + <%= render "content_block_guidance" %> + <% end %> <% end %> diff --git a/test/integration/edition_edit_test.rb b/test/integration/edition_edit_test.rb index df6bf8602..d49732ac9 100644 --- a/test/integration/edition_edit_test.rb +++ b/test/integration/edition_edit_test.rb @@ -529,6 +529,32 @@ class EditionEditTest < IntegrationTest end end end + + context "content block guidance" do + context "when show_link_to_content_block_manager? is false" do + setup do + test_strategy = Flipflop::FeatureSet.current.test! + test_strategy.switch!(:show_link_to_content_block_manager, false) + visit_draft_edition + end + + should "not show the content block guidance" do + assert_not page.has_text?("Content block") + end + end + + context "when show_link_to_content_block_manager? is true" do + setup do + test_strategy = Flipflop::FeatureSet.current.test! + test_strategy.switch!(:show_link_to_content_block_manager, true) + visit_draft_edition + end + + should "show the content block guidance" do + assert page.has_text?("Content block") + end + end + end end private