From 1f304a8539a58ff1a2b702d3df47ba8a6e30ce82 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Wed, 25 Oct 2023 15:31:30 +0100 Subject: [PATCH] CLDC-2862: first attempt at creating maintenance page --- app/controllers/application_controller.rb | 9 +++++++++ app/controllers/maintenance_controller.rb | 7 +++++++ app/services/feature_toggle.rb | 4 ++++ app/views/layouts/application.html.erb | 12 +++++++----- app/views/maintenance/service_unavailable.html.erb | 11 +++++++++++ config/routes.rb | 1 + 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 app/controllers/maintenance_controller.rb create mode 100644 app/views/maintenance/service_unavailable.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ff085e6dc..48f94ee77 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,8 +3,17 @@ class ApplicationController < ActionController::Base rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized + before_action :check_maintenance 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 render "errors/not_found", status: :not_found end diff --git a/app/controllers/maintenance_controller.rb b/app/controllers/maintenance_controller.rb new file mode 100644 index 000000000..bb6ae1f80 --- /dev/null +++ b/app/controllers/maintenance_controller.rb @@ -0,0 +1,7 @@ +class MaintenanceController < ApplicationController + def service_unavailable + if current_user + sign_out + end + end +end diff --git a/app/services/feature_toggle.rb b/app/services/feature_toggle.rb index 379f51905..b2a8f918f 100644 --- a/app/services/feature_toggle.rb +++ b/app/services/feature_toggle.rb @@ -37,4 +37,8 @@ class FeatureToggle def self.duplicate_summary_enabled? !Rails.env.production? end + + def self.maintenance_mode_enabled? + true + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ead90793a..d033b16e0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -91,11 +91,13 @@ navigation_classes: "govuk-header__navigation--end", ) do |component| component.product_name(name: t("service_name")) - if current_user.nil? - component.navigation_item(text: "Sign in", href: user_session_path) - else - component.navigation_item(text: "Your account", href: account_path) - component.navigation_item(text: "Sign out", href: destroy_user_session_path) + if !FeatureToggle.maintenance_mode_enabled? + if current_user.nil? + component.navigation_item(text: "Sign in", href: user_session_path) + else + component.navigation_item(text: "Your account", href: account_path) + component.navigation_item(text: "Sign out", href: destroy_user_session_path) + end end end %> diff --git a/app/views/maintenance/service_unavailable.html.erb b/app/views/maintenance/service_unavailable.html.erb new file mode 100644 index 000000000..2963d05e9 --- /dev/null +++ b/app/views/maintenance/service_unavailable.html.erb @@ -0,0 +1,11 @@ +

+ Sorry, the service is unavailable +

+ +
+
+

You will be able to use the service later from TIME on DAY.

+

We saved your answers.

+

<%= govuk_link_to "Contact the helpdesk", "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11" %> if you need assistance in the meantime.

+
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 621ee820c..498e7d9a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,7 @@ Rails.application.routes.draw do get "/accessibility-statement", to: "content#accessibility_statement" get "/privacy-notice", to: "content#privacy_notice" 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-22-23-lettings-form", to: "start#download_22_23_lettings_form"