From f570f6a7b1c9375b1c5c20de0aafb31c9a0c4fdb Mon Sep 17 00:00:00 2001 From: Krishna Bottla <40598480+kbottla@users.noreply.github.com> Date: Wed, 1 Nov 2023 07:47:47 +0000 Subject: [PATCH] PP-11755 Add maintenance banner - Added banner on my-services page for upcoming maintenance windows --- .../my-services/get-index.controller.js | 11 ++++++++++- app/views/services/_maintenance_banner.njk | 19 +++++++++++++++++++ app/views/services/index.njk | 2 ++ .../integration/my-services/my-services.cy.js | 16 ++++++++++++++++ test/cypress/test.env | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/views/services/_maintenance_banner.njk 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 %} +