Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-11755 Add maintenance banner #4152

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/controllers/my-services/get-index.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const serviceService = require('../../services/service.service')
const { filterGatewayAccountIds } = require('../../utils/permissions')
const getHeldPermissions = require('../../utils/get-held-permissions')
const { DEFAULT_SERVICE_NAME } = require('../../utils/constants')
const maintenanceBannerEndDate = process.env.MAINTENANCE_BANNER_END_DATE || '2023-11-28T08:00:00'

function hasStripeAccount (gatewayAccounts) {
return gatewayAccounts.some(gatewayAccount =>
Expand All @@ -27,6 +28,13 @@ function sortServicesByLiveThenName (a, b) {
return 0
}

function shouldShowMaintenanceBanner () {
const currentDateTime = new Date()
const endDateTime = new Date(maintenanceBannerEndDate)

return currentDateTime <= endDateTime
}

module.exports = async function getServiceList (req, res) {
const servicesRoles = lodash.get(req, 'user.serviceRoles', [])
const newServiceId = res.locals.flash && res.locals.flash.inviteSuccessServiceId &&
Expand Down Expand Up @@ -62,7 +70,8 @@ module.exports = async function getServiceList (req, res) {
services_singular: servicesData.length === 1,
env: process.env,
has_account_with_payouts: hasStripeAccount(aggregatedGatewayAccounts),
has_live_account: filterGatewayAccountIds(aggregatedGatewayAccounts, true).length
has_live_account: filterGatewayAccountIds(aggregatedGatewayAccounts, true).length,
display_maintenance_banner: shouldShowMaintenanceBanner()
}

if (newServiceId) {
Expand Down
19 changes: 19 additions & 0 deletions app/views/services/_maintenance_banner.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner %}

{% if display_maintenance_banner %}
<div class="govuk-grid-column-two-thirds">
{% set html %}
<p class="govuk-notification-banner__heading">
GOV.UK Pay will be unavailable for three 4-hour windows between 14 November and 28 November 2023.
<a class="govuk-notification-banner__link" href="https://docs.payments.service.gov.uk/support_contact_and_more_information/scheduled_maintenance/">Read more about this downtime</a>.
</p>
{% endset %}

{{ govukNotificationBanner({
html: html,
attributes: {
id: 'my-services-notification-banner'
}
}) }}
</div>
{% endif %}
2 changes: 2 additions & 0 deletions app/views/services/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
{% block beforeContent %}{% endblock %}

{% block mainContent %}
{% include "./_maintenance_banner.njk" %}

<div class="govuk-grid-column-two-thirds">
{% if new_service_name %}
{% set html %}
Expand Down
16 changes: 16 additions & 0 deletions test/cypress/integration/my-services/my-services.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,19 @@ describe('User has access to one or more live services', () => {
cy.contains('a', 'View transactions for all your services')
})
})

describe('My services notification banner', () => {
it('should display the maintenance banner', () => {
const userExternalId = 'authenticated-user-id'

cy.task('setupStubs', [
userStubs.getUserSuccess({ userExternalId, gatewayAccountId: '1' }),
gatewayAccountStubs.getGatewayAccountsSuccess({ gatewayAccountId: '1' })
])
cy.setEncryptedCookies(userExternalId, 1)
cy.visit('/my-services')
cy.get('#my-services-notification-banner').should('exist')

cy.get('.govuk-notification-banner__heading').contains('GOV.UK Pay will be unavailable for three 4-hour windows between 14 November and 28 November 2023')
})
})
1 change: 1 addition & 0 deletions test/cypress/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ GOCARDLESS_TEST_CLIENT_ID=testClientId
PAYOUTS_RELEASE_DATE=1590148800
ENABLE_STRIPE_ONBOARDING_TASK_LIST=true
ALLOW_ENABLING_DIGITAL_WALLETS_FOR_STRIPE_ACCOUNT=true
MAINTENANCE_BANNER_END_DATE=2024-01-15T00:00:00