Skip to content

Commit

Permalink
Simplify layout views
Browse files Browse the repository at this point in the history
This removes the base view and replaces it with the application view as
it doesn't do anything extra.
  • Loading branch information
thomasleese committed Jan 10, 2024
1 parent d40fc04 commit 14b17ed
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 106 deletions.
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/assessor_interface/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ class AssessorInterface::BaseController < ApplicationController
include AssessorCurrentNamespace
include StaffAuthenticatable

layout "two_thirds"

after_action :verify_authorized
end
2 changes: 0 additions & 2 deletions app/controllers/eligibility_interface/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module EligibilityInterface
class BaseController < ApplicationController
include EligibilityCurrentNamespace

layout "two_thirds"

before_action :load_region
after_action :save_eligibility_check_id

Expand Down
1 change: 0 additions & 1 deletion app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/performance_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions app/controllers/static_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

class StaticController < ApplicationController
include EligibilityCurrentNamespace

layout "two_thirds"
end
2 changes: 0 additions & 2 deletions app/controllers/teacher_interface/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
class TeacherInterface::BaseController < ApplicationController
include TeacherCurrentNamespace

layout "two_thirds"

before_action :authenticate_teacher!

def load_application_form
Expand Down
92 changes: 88 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,89 @@
<% content_for :content do %>
<%= yield %>
<% end %>
<!DOCTYPE html>
<html lang="en" class="govuk-template">
<head>
<meta charset="utf-8">
<title><%= [yield(:page_title).presence, t(current_namespace, scope: %i[service name])].compact.join(' - ') %></title>

<%= 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 %>
</head>

<body class="govuk-template__body">
<%= 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" %>

<div class="govuk-width-container">
<div class="govuk-phase-banner">
<p class="govuk-phase-banner__content">
<strong class="govuk-tag govuk-phase-banner__content__tag app-environment-tag--<%= HostingEnvironment.name %>">
<%= HostingEnvironment.phase %>
</strong>

<span class="govuk-phase-banner__text">
<% 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 %>
</span>
</p>
</div>
</div>

<div class="govuk-width-container">
<%= govuk_back_link(href: yield(:back_link_url)) unless yield(:back_link_url).blank? %>
<main class="govuk-main-wrapper" id="main-content" role="main">
<%= render(FlashMessage::Component.new(flash: flash)) %>
<%= content_for?(:content) ? yield(:content) : yield %>
</main>
</div>

<%= govuk_footer(
meta_items_title: 'Footer links',
meta_items: {
'Accessibility': '/accessibility',
'Cookies': '/cookies',
'Privacy': '/privacy'
} ) do |footer| %>
<% footer.with_navigation do %>
<% if current_teacher %>
<div class="govuk-footer__section">
<h3 style="margin-left: 100px">Get help</h3>
<p>
If you’re having difficulty completing your application form, contact:
<%= govuk_link_to t("service.email.enquiries"), "mailto:#{t("service.email.enquiries")}" %>
for support.
</p>
<p>
So that we can help you quickly, please include as much detail as possible
about the problem you‘re experiencing, for example:
</p>
<ul class="govuk-list govuk-list--bullet">
<li>any important details (such as application reference numbers etc)</li>
<li>screenshots that illustrate your problem</li>
</ul>
<p>We’ll aim to respond to you within 2 working days.</p>
</div>
<% end %>
<% end %>
<% end %>
</body>
</html>
89 changes: 0 additions & 89 deletions app/views/layouts/base.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/layouts/full_from_desktop.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
</div>
<% end %>

<%= render template: 'layouts/base' %>
<%= render template: "layouts/application" %>
2 changes: 1 addition & 1 deletion app/views/layouts/two_thirds.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
</div>
<% end %>

<%= render template: 'layouts/base' %>
<%= render template: "layouts/application" %>
2 changes: 1 addition & 1 deletion spec/support/autoload/page_objects/performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 14b17ed

Please sign in to comment.