diff --git a/app/controllers/my-services/get-index.controller.js b/app/controllers/my-services/get-index.controller.js index 81e990dc6f..a3327f6081 100644 --- a/app/controllers/my-services/get-index.controller.js +++ b/app/controllers/my-services/get-index.controller.js @@ -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 => @@ -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 && @@ -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) { diff --git a/app/views/services/_maintenance_banner.njk b/app/views/services/_maintenance_banner.njk new file mode 100644 index 0000000000..844af30e00 --- /dev/null +++ b/app/views/services/_maintenance_banner.njk @@ -0,0 +1,19 @@ +{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner %} + +{% if display_maintenance_banner %} +
+ {% set html %} +

+ GOV.UK Pay will be unavailable for three 4-hour windows between 14 November and 28 November 2023. + Read more about this downtime. +

+ {% endset %} + + {{ govukNotificationBanner({ + html: html, + attributes: { + id: 'my-services-notification-banner' + } + }) }} +
+{% endif %} diff --git a/app/views/services/index.njk b/app/views/services/index.njk index e5eb2ee230..a1379f4c71 100644 --- a/app/views/services/index.njk +++ b/app/views/services/index.njk @@ -8,6 +8,8 @@ {% block beforeContent %}{% endblock %} {% block mainContent %} + {% include "./_maintenance_banner.njk" %} +
{% if new_service_name %} {% set html %} diff --git a/test/cypress/integration/my-services/my-services.cy.js b/test/cypress/integration/my-services/my-services.cy.js index 208181d7b9..61b3fb6476 100644 --- a/test/cypress/integration/my-services/my-services.cy.js +++ b/test/cypress/integration/my-services/my-services.cy.js @@ -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') + }) +}) diff --git a/test/cypress/test.env b/test/cypress/test.env index 3884f22750..976b370aea 100644 --- a/test/cypress/test.env +++ b/test/cypress/test.env @@ -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 \ No newline at end of file