Browse Source

CLDC-2862: first attempt at creating maintenance page

pull/2006/head
Sam Seed 3 years ago
parent
commit
1f304a8539
  1. 9
      app/controllers/application_controller.rb
  2. 7
      app/controllers/maintenance_controller.rb
  3. 4
      app/services/feature_toggle.rb
  4. 12
      app/views/layouts/application.html.erb
  5. 11
      app/views/maintenance/service_unavailable.html.erb
  6. 1
      config/routes.rb

9
app/controllers/application_controller.rb

@ -3,8 +3,17 @@ class ApplicationController < ActionController::Base
rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized
before_action :check_maintenance
before_action :set_paper_trail_whodunnit before_action :set_paper_trail_whodunnit
def check_maintenance
if FeatureToggle.maintenance_mode_enabled? && request.fullpath.split("?")[0].delete("/") != "service-unavailable"
redirect_to service_unavailable_path
elsif !FeatureToggle.maintenance_mode_enabled? && request.fullpath.split("?")[0].delete("/") == "service-unavailable"
redirect_back(fallback_location: root_path)
end
end
def render_not_found def render_not_found
render "errors/not_found", status: :not_found render "errors/not_found", status: :not_found
end end

7
app/controllers/maintenance_controller.rb

@ -0,0 +1,7 @@
class MaintenanceController < ApplicationController
def service_unavailable
if current_user
sign_out
end
end
end

4
app/services/feature_toggle.rb

@ -37,4 +37,8 @@ class FeatureToggle
def self.duplicate_summary_enabled? def self.duplicate_summary_enabled?
!Rails.env.production? !Rails.env.production?
end end
def self.maintenance_mode_enabled?
true
end
end end

12
app/views/layouts/application.html.erb

@ -91,11 +91,13 @@
navigation_classes: "govuk-header__navigation--end", navigation_classes: "govuk-header__navigation--end",
) do |component| ) do |component|
component.product_name(name: t("service_name")) component.product_name(name: t("service_name"))
if current_user.nil? if !FeatureToggle.maintenance_mode_enabled?
component.navigation_item(text: "Sign in", href: user_session_path) if current_user.nil?
else component.navigation_item(text: "Sign in", href: user_session_path)
component.navigation_item(text: "Your account", href: account_path) else
component.navigation_item(text: "Sign out", href: destroy_user_session_path) component.navigation_item(text: "Your account", href: account_path)
component.navigation_item(text: "Sign out", href: destroy_user_session_path)
end
end end
end %> end %>

11
app/views/maintenance/service_unavailable.html.erb

@ -0,0 +1,11 @@
<h1 class="govuk-heading-l govuk-!-width-two-thirds">
Sorry, the service is unavailable
</h1>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<p class="govuk-body">You will be able to use the service later from TIME on DAY.</p>
<p class="govuk-body">We saved your answers.</p>
<p class="govuk-body"><%= govuk_link_to "Contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %> if you need assistance in the meantime.</p>
</div>
</div>

1
config/routes.rb

@ -35,6 +35,7 @@ Rails.application.routes.draw do
get "/accessibility-statement", to: "content#accessibility_statement" get "/accessibility-statement", to: "content#accessibility_statement"
get "/privacy-notice", to: "content#privacy_notice" get "/privacy-notice", to: "content#privacy_notice"
get "/data-sharing-agreement", to: "content#data_sharing_agreement" get "/data-sharing-agreement", to: "content#data_sharing_agreement"
get "/service-unavailable", to: "maintenance#service_unavailable"
get "/download-23-24-lettings-form", to: "start#download_23_24_lettings_form" get "/download-23-24-lettings-form", to: "start#download_23_24_lettings_form"
get "/download-22-23-lettings-form", to: "start#download_22_23_lettings_form" get "/download-22-23-lettings-form", to: "start#download_22_23_lettings_form"

Loading…
Cancel
Save