From 14b17ed3920446467e574234405571eaa68d83df Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 14 Dec 2023 11:10:53 +0000 Subject: [PATCH] Simplify layout views This removes the base view and replaces it with the application view as it doesn't do anything extra. --- app/controllers/application_controller.rb | 3 +- .../assessor_interface/base_controller.rb | 2 - .../eligibility_interface/base_controller.rb | 2 - app/controllers/errors_controller.rb | 1 - app/controllers/performance_controller.rb | 2 + app/controllers/static_controller.rb | 2 - .../teacher_interface/base_controller.rb | 2 - app/views/layouts/application.html.erb | 92 ++++++++++++++++++- app/views/layouts/base.html.erb | 89 ------------------ app/views/layouts/full_from_desktop.html.erb | 2 +- app/views/layouts/two_thirds.html.erb | 2 +- .../autoload/page_objects/performance.rb | 2 +- 12 files changed, 95 insertions(+), 106 deletions(-) delete mode 100644 app/views/layouts/base.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5c851d9a75..3438b15992 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,9 @@ class ApplicationController < ActionController::Base include DfE::Analytics::Requests include Pundit::Authorization - default_form_builder GOVUKDesignSystemFormBuilder::FormBuilder append_view_path Rails.root.join("app/components") + default_form_builder GOVUKDesignSystemFormBuilder::FormBuilder + layout "two_thirds" before_action :authenticate, unless: -> { FeatureFlags::FeatureFlag.active?(:service_open) } diff --git a/app/controllers/assessor_interface/base_controller.rb b/app/controllers/assessor_interface/base_controller.rb index a260b767fd..d138d4862c 100644 --- a/app/controllers/assessor_interface/base_controller.rb +++ b/app/controllers/assessor_interface/base_controller.rb @@ -4,7 +4,5 @@ class AssessorInterface::BaseController < ApplicationController include AssessorCurrentNamespace include StaffAuthenticatable - layout "two_thirds" - after_action :verify_authorized end diff --git a/app/controllers/eligibility_interface/base_controller.rb b/app/controllers/eligibility_interface/base_controller.rb index 8927846939..49c983527a 100644 --- a/app/controllers/eligibility_interface/base_controller.rb +++ b/app/controllers/eligibility_interface/base_controller.rb @@ -2,8 +2,6 @@ module EligibilityInterface class BaseController < ApplicationController include EligibilityCurrentNamespace - layout "two_thirds" - before_action :load_region after_action :save_eligibility_check_id diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index d392372b71..ef1cb2f1f7 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -2,7 +2,6 @@ class ErrorsController < ApplicationController include EligibilityCurrentNamespace skip_before_action :verify_authenticity_token - layout "two_thirds" def forbidden render "forbidden", formats: :html, status: :forbidden diff --git a/app/controllers/performance_controller.rb b/app/controllers/performance_controller.rb index e70bd9b721..bd6b7fe962 100644 --- a/app/controllers/performance_controller.rb +++ b/app/controllers/performance_controller.rb @@ -20,5 +20,7 @@ def index stats.live_service_usage @time_to_complete_data = stats.time_to_complete @usage_by_country_count, @usage_by_country_data = stats.usage_by_country + + render layout: "full_from_desktop" end end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 148514938e..40603a0176 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -2,6 +2,4 @@ class StaticController < ApplicationController include EligibilityCurrentNamespace - - layout "two_thirds" end diff --git a/app/controllers/teacher_interface/base_controller.rb b/app/controllers/teacher_interface/base_controller.rb index 7410b3c5e6..c5163739d4 100644 --- a/app/controllers/teacher_interface/base_controller.rb +++ b/app/controllers/teacher_interface/base_controller.rb @@ -3,8 +3,6 @@ class TeacherInterface::BaseController < ApplicationController include TeacherCurrentNamespace - layout "two_thirds" - before_action :authenticate_teacher! def load_application_form diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a5e665ad5f..d1426b0fa8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,89 @@ -<% content_for :content do %> - <%= yield %> -<% end %> + + + + + <%= [yield(:page_title).presence, t(current_namespace, scope: %i[service name])].compact.join(' - ') %> -<%= render template: 'layouts/base' %> + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %> + <%= tag :meta, property: 'og:image', content: asset_path('images/govuk-opengraph-image.png') %> + <%= tag :meta, name: 'theme-color', content: '#0b0c0c' %> + <%= favicon_link_tag asset_path('images/favicon.ico') %> + <%= favicon_link_tag asset_path('images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c" %> + <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png' %> + <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-152x152.png'), rel: 'apple-touch-icon', type: 'image/png', size: '152x152' %> + <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-167x167.png'), rel: 'apple-touch-icon', type: 'image/png', size: '167x167' %> + <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-180x180.png'), rel: 'apple-touch-icon', type: 'image/png', size: '180x180' %> + + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application", defer: true %> + + + + <%= javascript_tag nonce: true do -%> + document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled'); + <% end -%> + + <%= govuk_skip_link %> + + <%= render partial: "shared/header" %> + +
+
+

+ + + + <% if HostingEnvironment.production? %> + This is a new service - <%= link_to "your feedback will help us to improve it", yield(:feedback_url).presence || t("service.form.feedback") %>. + <% else %> + This is a ‘<%= HostingEnvironment.phase %>’ version of the service. + <% end %> + +

+
+
+ +
+ <%= govuk_back_link(href: yield(:back_link_url)) unless yield(:back_link_url).blank? %> +
+ <%= render(FlashMessage::Component.new(flash: flash)) %> + <%= content_for?(:content) ? yield(:content) : yield %> +
+
+ + <%= govuk_footer( + meta_items_title: 'Footer links', + meta_items: { + 'Accessibility': '/accessibility', + 'Cookies': '/cookies', + 'Privacy': '/privacy' + } ) do |footer| %> + <% footer.with_navigation do %> + <% if current_teacher %> + + <% end %> + <% end %> + <% end %> + + diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb deleted file mode 100644 index d1426b0fa8..0000000000 --- a/app/views/layouts/base.html.erb +++ /dev/null @@ -1,89 +0,0 @@ - - - - - <%= [yield(:page_title).presence, t(current_namespace, scope: %i[service name])].compact.join(' - ') %> - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %> - <%= tag :meta, property: 'og:image', content: asset_path('images/govuk-opengraph-image.png') %> - <%= tag :meta, name: 'theme-color', content: '#0b0c0c' %> - <%= favicon_link_tag asset_path('images/favicon.ico') %> - <%= favicon_link_tag asset_path('images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c" %> - <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png' %> - <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-152x152.png'), rel: 'apple-touch-icon', type: 'image/png', size: '152x152' %> - <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-167x167.png'), rel: 'apple-touch-icon', type: 'image/png', size: '167x167' %> - <%= favicon_link_tag asset_path('images/govuk-apple-touch-icon-180x180.png'), rel: 'apple-touch-icon', type: 'image/png', size: '180x180' %> - - <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag "application", defer: true %> - - - - <%= javascript_tag nonce: true do -%> - document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled'); - <% end -%> - - <%= govuk_skip_link %> - - <%= render partial: "shared/header" %> - -
-
-

- - - - <% if HostingEnvironment.production? %> - This is a new service - <%= link_to "your feedback will help us to improve it", yield(:feedback_url).presence || t("service.form.feedback") %>. - <% else %> - This is a ‘<%= HostingEnvironment.phase %>’ version of the service. - <% end %> - -

-
-
- -
- <%= govuk_back_link(href: yield(:back_link_url)) unless yield(:back_link_url).blank? %> -
- <%= render(FlashMessage::Component.new(flash: flash)) %> - <%= content_for?(:content) ? yield(:content) : yield %> -
-
- - <%= govuk_footer( - meta_items_title: 'Footer links', - meta_items: { - 'Accessibility': '/accessibility', - 'Cookies': '/cookies', - 'Privacy': '/privacy' - } ) do |footer| %> - <% footer.with_navigation do %> - <% if current_teacher %> - - <% end %> - <% end %> - <% end %> - - diff --git a/app/views/layouts/full_from_desktop.html.erb b/app/views/layouts/full_from_desktop.html.erb index 08ed4ca592..e148ccb5a1 100644 --- a/app/views/layouts/full_from_desktop.html.erb +++ b/app/views/layouts/full_from_desktop.html.erb @@ -6,4 +6,4 @@ <% end %> -<%= render template: 'layouts/base' %> +<%= render template: "layouts/application" %> diff --git a/app/views/layouts/two_thirds.html.erb b/app/views/layouts/two_thirds.html.erb index 167aa779d1..3587a3d05b 100644 --- a/app/views/layouts/two_thirds.html.erb +++ b/app/views/layouts/two_thirds.html.erb @@ -6,4 +6,4 @@ <% end %> -<%= render template: 'layouts/base' %> +<%= render template: "layouts/application" %> diff --git a/spec/support/autoload/page_objects/performance.rb b/spec/support/autoload/page_objects/performance.rb index 87b6dd2577..20709de8ac 100644 --- a/spec/support/autoload/page_objects/performance.rb +++ b/spec/support/autoload/page_objects/performance.rb @@ -2,7 +2,7 @@ module PageObjects class Performance < SitePrism::Page set_url "/performance{?since_launch*}" - section :live_service_usage, "main > div:nth-of-type(2)" do + section :live_service_usage, "main > div > div > div:nth-of-type(2)" do elements :stats, "div > div" element :table, "table"