From 79e6bb4a0c1a3d5bc1983aaba0244d230f6771ba Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 12 Nov 2024 16:15:04 +0000 Subject: [PATCH 1/5] Remove Slimmer Gem and config - TODO will be addressed in a later commit, for the moment just remove all slimmer calls --- Gemfile | 1 - Gemfile.lock | 8 -------- app/controllers/application_controller.rb | 4 ---- app/controllers/subscriptions_management_controller.rb | 5 ++--- spec/spec_helper.rb | 1 - 5 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 963bd79c..47f9dc23 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,6 @@ gem "govuk_publishing_components" gem "jwt" gem "plek" gem "ratelimit" -gem "slimmer" gem "sprockets-rails" gem "terser" diff --git a/Gemfile.lock b/Gemfile.lock index fd329a12..52d636ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -594,13 +594,6 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - slimmer (18.6.2) - json - nokogiri (~> 1.7) - null_logger - plek (>= 1.1.0) - rack (>= 3.0) - rest-client sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -660,7 +653,6 @@ DEPENDENCIES rspec-rails rubocop-govuk simplecov - slimmer sprockets-rails terser timecop diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index da1192ea..ba366b30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,6 @@ class ApplicationController < ActionController::Base include GovukPersonalisation::ControllerConcern - include Slimmer::Template - before_action :set_cache_control_header # Prevent CSRF attacks by raising an exception. @@ -48,8 +46,6 @@ def use_govuk_account_layout? false end - slimmer_template :gem_layout - private def set_cache_control_header diff --git a/app/controllers/subscriptions_management_controller.rb b/app/controllers/subscriptions_management_controller.rb index e38d4176..a68138dd 100644 --- a/app/controllers/subscriptions_management_controller.rb +++ b/app/controllers/subscriptions_management_controller.rb @@ -1,6 +1,4 @@ class SubscriptionsManagementController < ApplicationController - include Slimmer::Headers - include Slimmer::Template before_action :handle_one_login_hint, only: [:index] before_action :require_authentication before_action :get_subscription_details @@ -98,7 +96,8 @@ def confirmed_unsubscribe_all def use_govuk_account_layout? @use_govuk_account_layout ||= if authenticated_via_account? - set_slimmer_headers(template: "gem_layout_account_manager") + # TODO: HERE WE NEED THE ACCOUNT MANAGER LAYOUT + # set_slimmer_headers(template: "gem_layout_account_manager") true end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eb5afdd7..fe7c25c7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,6 @@ require File.expand_path("../config/environment", __dir__) require "rspec/rails" require "webmock/rspec" -require "slimmer/rspec" require "gds_api/test_helpers/account_api" require "gds_api/test_helpers/email_alert_api" From 6c1482bb65d01b14c68631f60d4977aae9ab6d7d Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 12 Nov 2024 16:16:51 +0000 Subject: [PATCH 2/5] Use component directly - for the moment, include all components/JS --- app/assets/javascripts/application.js | 3 +++ app/assets/stylesheets/application.scss | 2 ++ app/views/layouts/application.html.erb | 27 +++++-------------- .../govuk_publishing_components.rb | 1 + 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8641837b..5b136e2b 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,3 +1,6 @@ +//= require govuk_publishing_components/dependencies //= require govuk_publishing_components/lib //= require govuk_publishing_components/components/error-summary //= require govuk_publishing_components/components/radio +//= require govuk_publishing_components/components/feedback +//= require govuk_publishing_components/components/layout-super-navigation-header diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d4e4667a..9b8fa59c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,3 +2,5 @@ // for components and views on pages where they are needed. // https://github.com/alphagov/govuk_publishing_components/blob/main/docs/set-up-individual-component-css-loading.md + +@import "govuk_publishing_components/all_components"; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index df3e7be7..5846f962 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,23 +25,10 @@ <% end %> <% end %> - - - - <%= yield :title %> - GOV.UK - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - <% if content_for(:meta_description).present? %> - - <% end %> - <%= yield :head %> - - <%= - render_component_stylesheets - %> - - - <%= yield :body %> - <%= javascript_include_tag 'application', type: "module" %> - - +<%= render "govuk_publishing_components/components/layout_for_public", { + title: yield(:title), + show_explore_header: true, + } do %> + <%= yield :body %> + <%= javascript_include_tag 'application', type: "module" %> +<% end %> diff --git a/config/initializers/govuk_publishing_components.rb b/config/initializers/govuk_publishing_components.rb index 59f1a5fe..da70d52c 100644 --- a/config/initializers/govuk_publishing_components.rb +++ b/config/initializers/govuk_publishing_components.rb @@ -1,4 +1,5 @@ GovukPublishingComponents.configure do |c| c.component_guide_title = "Email Alert Frontend Component Guide" c.application_stylesheet = "application" + c.exclude_css_from_static = false end From 3671ba23237ea86f8d7c0893d1de6a121e7a6fc1 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 12 Nov 2024 22:50:42 +0000 Subject: [PATCH 3/5] Support account layout --- .../subscriptions_management_controller.rb | 14 ++-- app/views/layouts/account.html.erb | 67 +++++++++++++++++++ app/views/layouts/application.html.erb | 32 +++------ 3 files changed, 84 insertions(+), 29 deletions(-) create mode 100644 app/views/layouts/account.html.erb diff --git a/app/controllers/subscriptions_management_controller.rb b/app/controllers/subscriptions_management_controller.rb index a68138dd..2d574295 100644 --- a/app/controllers/subscriptions_management_controller.rb +++ b/app/controllers/subscriptions_management_controller.rb @@ -3,7 +3,8 @@ class SubscriptionsManagementController < ApplicationController before_action :require_authentication before_action :get_subscription_details before_action :set_back_url - before_action :use_govuk_account_layout? + + layout :choose_layout def index; end @@ -94,16 +95,15 @@ def confirmed_unsubscribe_all end def use_govuk_account_layout? - @use_govuk_account_layout ||= - if authenticated_via_account? - # TODO: HERE WE NEED THE ACCOUNT MANAGER LAYOUT - # set_slimmer_headers(template: "gem_layout_account_manager") - true - end + @use_govuk_account_layout ||= authenticated_via_account? end private + def choose_layout + use_govuk_account_layout? ? "account" : "application" + end + def handle_one_login_hint return unless params[:from] == "your-services" && !authenticated? diff --git a/app/views/layouts/account.html.erb b/app/views/layouts/account.html.erb new file mode 100644 index 00000000..89fb4147 --- /dev/null +++ b/app/views/layouts/account.html.erb @@ -0,0 +1,67 @@ +<% content_for :body do %> +
+ <% content_for :before_content do %> + <%= yield :back_link %> + <% end %> + <%= yield :before_content %> +
+ <%= yield %> +
+
+<% end %> + +<%= render "govuk_publishing_components/components/layout_for_public", { + title: yield(:title), + blue_bar: false, + omit_feedback_form: true, + omit_footer_border: true, + omit_global_banner: true, + omit_footer_navigation: true, + product_name: "GOV.UK email subscriptions", + show_account_layout: true, + show_cross_service_header: true, + show_explore_header: false, + omit_account_navigation: true, + one_login_navigation_items: { + one_login_home: { + href: GovukPersonalisation::Urls.one_login_your_services, + data: { + module: "explicit-cross-domain-links", + link_for: "accounts-signed-in", + }, + }, + one_login_sign_out: { + text: "Sign out", + href: GovukPersonalisation::Urls.sign_out, + data: { + module: "explicit-cross-domain-links", + link_for: "accounts-signed-in", + }, + }, + }, + footer_meta: { items: [ + { + href: "https://signin.account.gov.uk/accessibility-statement", + text: "Accessibility statement" + }, + { + href: "/help/cookies", + text: "Cookies" + }, + { + href: "https://signin.account.gov.uk/terms-and-conditions", + text: "Terms and conditions" + }, + { + href: "https://signin.account.gov.uk/privacy-statement", + text: "Privacy notice" + }, + { + href: "https://signin.account.gov.uk/support", + text: "Support" + }, + ]}, + } do %> + <%= yield :body %> + <%= javascript_include_tag 'application', type: "module" %> +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5846f962..25f13187 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,28 +1,16 @@ <% content_for :body do %> - <% if use_govuk_account_layout? %> -
- <% content_for :before_content do %> - <%= yield :back_link %> - <% end %> - <%= yield :before_content %> -
- <%= yield %> -
-
- <% else %> -
- <%= yield :back_link %> -
" role="main" id="content"> -
-
-
- <%= yield %> -
+
+ <%= yield :back_link %> +
" role="main" id="content"> +
+
+
+ <%= yield %>
-
-
- <% end %> +
+
+
<% end %> <%= render "govuk_publishing_components/components/layout_for_public", { From 5a1b1235db5dd2201bf87579987a58cdce719516 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 10 Dec 2024 13:55:01 +0000 Subject: [PATCH 4/5] Add govuk_web_banners gem --- Gemfile | 1 + Gemfile.lock | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Gemfile b/Gemfile index 47f9dc23..c57a7722 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem "gds-api-adapters" gem "govuk_app_config" gem "govuk_personalisation" gem "govuk_publishing_components" +gem "govuk_web_banners", git: "https://github.com/alphagov/govuk_web_banners", branch: "emergency-banner" gem "jwt" gem "plek" gem "ratelimit" diff --git a/Gemfile.lock b/Gemfile.lock index 52d636ea..f58a0ab2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,14 @@ +GIT + remote: https://github.com/alphagov/govuk_web_banners + revision: fa4bbf8cde0a639565b2c4e6f8c719f94edb22ec + branch: emergency-banner + specs: + govuk_web_banners (0.1.0) + govuk_app_config + govuk_publishing_components + rails (>= 7) + redis + GEM remote: https://rubygems.org/ specs: @@ -645,6 +656,7 @@ DEPENDENCIES govuk_publishing_components govuk_schemas govuk_test + govuk_web_banners! jwt plek pry-byebug From f3cadd20a32c34975ad4b662c306e4ab257ebd27 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 10 Dec 2024 13:55:39 +0000 Subject: [PATCH 5/5] Add emergency banner support in layouts --- app/views/layouts/account.html.erb | 1 + app/views/layouts/application.html.erb | 1 + config/initializers/govuk_web_banners.rb | 4 ++++ 3 files changed, 6 insertions(+) create mode 100644 config/initializers/govuk_web_banners.rb diff --git a/app/views/layouts/account.html.erb b/app/views/layouts/account.html.erb index 89fb4147..1eafacf3 100644 --- a/app/views/layouts/account.html.erb +++ b/app/views/layouts/account.html.erb @@ -13,6 +13,7 @@ <%= render "govuk_publishing_components/components/layout_for_public", { title: yield(:title), blue_bar: false, + emergency_banner: render("govuk_web_banners/emergency_banner"), omit_feedback_form: true, omit_footer_border: true, omit_global_banner: true, diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 25f13187..1d0e4779 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,6 +16,7 @@ <%= render "govuk_publishing_components/components/layout_for_public", { title: yield(:title), show_explore_header: true, + emergency_banner: render("govuk_web_banners/emergency_banner"), } do %> <%= yield :body %> <%= javascript_include_tag 'application', type: "module" %> diff --git a/config/initializers/govuk_web_banners.rb b/config/initializers/govuk_web_banners.rb new file mode 100644 index 00000000..cf28881a --- /dev/null +++ b/config/initializers/govuk_web_banners.rb @@ -0,0 +1,4 @@ +Rails.application.config.emergency_banner_redis_client = Redis.new( + url: ENV["EMERGENCY_BANNER_REDIS_URL"], + reconnect_attempts: [15, 30, 45, 60], +)