-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We've used this banner before for scheduled maintenance so it makes sense to make it even more generic and quicker to use. Here we add it to every page when the appropriate environment variable is set to true and add the content to the locales to make identifying and update quick and painless.
- Loading branch information
Showing
8 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="govuk-notification-banner" id="information-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner"> | ||
<div class="govuk-notification-banner__header"> | ||
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title"> | ||
Important | ||
</h2> | ||
</div> | ||
<div class="govuk-notification-banner__content"> | ||
<h3 class="govuk-notification-banner__heading"> | ||
<%= t("information_banner.title") %> | ||
</h3> | ||
<%= t("information_banner.body.html") %> | ||
</div> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
en: | ||
information_banner: | ||
title: Upcoming scheduled maintenance | ||
body: | ||
html: | ||
<p>We will carry out maintenance on Complete from 5pm to 6pm on Friday 5 April 2024.</p> | ||
<p>Project changes will not be saved during the maintenance.</p> | ||
<p>Make sure you save your changes before the work starts.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |