+ <%= render partial: "/shared/information_banner" if ENV["SHOW_INFORMATION_BANNER"].eql?("true") %> <%= render(NotificationBanner.new(flashes: flash)) %> <%= yield %> diff --git a/app/views/shared/_information_banner.html.erb b/app/views/shared/_information_banner.html.erb new file mode 100644 index 0000000000..347d2383be --- /dev/null +++ b/app/views/shared/_information_banner.html.erb @@ -0,0 +1,13 @@ +
+
+

+ Important +

+
+
+

+ <%= t("information_banner.title") %> +

+ <%= t("information_banner.body.html") %> +
+
diff --git a/app/views/shared/_maintenance_banner.html.erb b/app/views/shared/_maintenance_banner.html.erb deleted file mode 100644 index e14fc5af8d..0000000000 --- a/app/views/shared/_maintenance_banner.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -
-
-

- Important -

-
-
-

- Scheduled maintenance on Wednesday evening -

-

We will carry out maintenance on Complete from 5pm to 6pm on Wednesday 6 March.

-

Project changes will not be saved during the maintenance.

-

Make sure you save your changes before the work starts.

-
-
diff --git a/config/locales/information_banner.yml b/config/locales/information_banner.yml new file mode 100644 index 0000000000..7bbc82b262 --- /dev/null +++ b/config/locales/information_banner.yml @@ -0,0 +1,8 @@ +en: + information_banner: + title: Upcoming scheduled maintenance + body: + html: +

We will carry out maintenance on Complete from 5pm to 6pm on Friday 5 April 2024.

+

Project changes will not be saved during the maintenance.

+

Make sure you save your changes before the work starts.

diff --git a/doc/environment-variables.md b/doc/environment-variables.md index 3cfd573484..ac85a14b16 100644 --- a/doc/environment-variables.md +++ b/doc/environment-variables.md @@ -54,3 +54,8 @@ the `/healthcheck` endpoint to confirm the app is up & running. `APPLICATION_INSIGHTS_KEY` The instrumentation key for Microsoft Application Insights. + +`SHOW_INFORMATION_BANNER` + +Turns the [information banner](./information_banner.md) on across the +application. diff --git a/doc/information_banner.md b/doc/information_banner.md new file mode 100644 index 0000000000..81efe32fae --- /dev/null +++ b/doc/information_banner.md @@ -0,0 +1,18 @@ +# Information Banner + +We sometimes want to inform all users of something important, scheduled downtime +for example. + +To do so we have an Information banner that can be enabled and is then shown +across the application. + +To set the content of the banner: + +- locate the `config/locales/information_banner.yml` locale file +- update the `title` +- update the HTML used for the `body` +- commit, merge and deploy this change + +Then: + +- set the `SHOW_INFORMATION_BANNER` environment variable to `true` diff --git a/spec/features/information_banner_spec.rb b/spec/features/information_banner_spec.rb new file mode 100644 index 0000000000..207c3673f3 --- /dev/null +++ b/spec/features/information_banner_spec.rb @@ -0,0 +1,52 @@ +require "rails_helper" + +RSpec.feature "Users can see an information banner" do + let(:user) { create(:user, :regional_delivery_officer) } + + before do + sign_in_with_user(user) + end + + context "with the environment variable present and set to true" do + it "shows the banner on all pages" do + ClimateControl.modify SHOW_INFORMATION_BANNER: "true" do + visit in_progress_your_projects_path + + expect(page).to have_selector("#information-banner") + + visit all_in_progress_projects_path + + expect(page).to have_selector("#information-banner") + end + end + + it "shows the title and body" do + ClimateControl.modify SHOW_INFORMATION_BANNER: "true" do + visit in_progress_your_projects_path + + within("#information-banner") do + expect(page).to have_content(I18n.t("information_banner.title")) + expect(page.html).to include(I18n.t("information_banner.body.html")) + end + end + end + end + + context "with the environment variable present and set to false" do + it "does not show the banner" do + ClimateControl.modify SHOW_INFORMATION_BANNER: "false" do + visit in_progress_your_projects_path + + expect(page).not_to have_selector("#information-banner") + end + end + end + + context "without the environment variable set" do + it "does not show the banner" do + visit in_progress_your_projects_path + + expect(page).not_to have_selector("#information-banner") + end + end +end