From ca08f874cc2ebe711015d0e57febfae433b1cd2a Mon Sep 17 00:00:00 2001
From: Sweety Mariam John <162119856+sweetymj@users.noreply.github.com>
Date: Wed, 10 Jul 2024 15:28:04 +0100
Subject: [PATCH 1/7] LNP-847-fixing-path-errors (#708)
---
assets/javascript/govukFrontendInit.js | 2 +-
server/views/pages/adjudication.html | 4 ++--
server/views/pages/adjudications.html | 4 ++--
server/views/pages/approvedVisitors.html | 4 ++--
server/views/pages/category.html | 4 ++--
server/views/pages/profile.html | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/assets/javascript/govukFrontendInit.js b/assets/javascript/govukFrontendInit.js
index 934918f1..92e38185 100644
--- a/assets/javascript/govukFrontendInit.js
+++ b/assets/javascript/govukFrontendInit.js
@@ -1,3 +1,3 @@
-import { initAll } from 'node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js';
+import { initAll } from '/public/govuk-frontend.min.js';
initAll();
diff --git a/server/views/pages/adjudication.html b/server/views/pages/adjudication.html
index e87def1b..bf71bb57 100644
--- a/server/views/pages/adjudication.html
+++ b/server/views/pages/adjudication.html
@@ -80,8 +80,8 @@
Date: Tue, 23 Jul 2024 18:49:24 +0300
Subject: [PATCH 2/7] =?UTF-8?q?LNP-864:=20=F0=9F=AA=84=20=20hide=20Chelmsf?=
=?UTF-8?q?ord.=20(#709)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* LNP-864: 🪄 hide Chelmsford.
* LNP-864: 🪄 hide Chelmsford more.
---
helm_deploy/prisoner-content-hub-frontend/values.yaml | 1 -
server/content/establishmentData.json | 6 ------
2 files changed, 7 deletions(-)
diff --git a/helm_deploy/prisoner-content-hub-frontend/values.yaml b/helm_deploy/prisoner-content-hub-frontend/values.yaml
index 900cf5e3..0206a872 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values.yaml
@@ -44,7 +44,6 @@ ingress:
prefixes:
- berwyn
- bullingdon
- - chelmsford
- cookhamwood
- erlestoke
- felthama
diff --git a/server/content/establishmentData.json b/server/content/establishmentData.json
index 1e4d97b3..bc92f50d 100644
--- a/server/content/establishmentData.json
+++ b/server/content/establishmentData.json
@@ -11,12 +11,6 @@
"youth": false,
"agencyId": "BNI"
},
- "2001": {
- "name": "chelmsford",
- "displayName": "HMP Chelmsford",
- "youth": false,
- "agencyId": "CDI"
- },
"959": {
"name": "cookhamwood",
"displayName": "HMP Cookham Wood",
From 62c6af0ad46a09a0d132116e94ea5e5e4dd792f7 Mon Sep 17 00:00:00 2001
From: Paul Solecki <51918433+psoleckimoj@users.noreply.github.com>
Date: Wed, 24 Jul 2024 11:06:30 +0100
Subject: [PATCH 3/7] Disable approved visitors (#711)
---
.../prisoner-content-hub-frontend/values-production.yaml | 2 +-
helm_deploy/prisoner-content-hub-frontend/values-staging.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/helm_deploy/prisoner-content-hub-frontend/values-production.yaml b/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
index 27ac0944..37b8117e 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
@@ -4,7 +4,7 @@ application:
analyticsSiteId: G-H1MT63QRLQ
googleTagManagerSiteId: GTM-M62TTBK
mockAuthEnabled: false
- approvedVisitorsFeatureEnabled: true
+ approvedVisitorsFeatureEnabled: false
adjudicationsFeatureEnabled: true
ingress:
diff --git a/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml b/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
index 5ab1c7a0..c685df36 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
@@ -4,7 +4,7 @@ application:
analyticsSiteId: G-FVRKLRH5PJ
googleTagManagerSiteId: GTM-M62TTBK
mockAuthEnabled: false
- approvedVisitorsFeatureEnabled: true
+ approvedVisitorsFeatureEnabled: false
adjudicationsFeatureEnabled: true
ingress:
From 56af8373e4081829eb3f06172b7a85cc5f06ecf6 Mon Sep 17 00:00:00 2001
From: Sweety Mariam John <162119856+sweetymj@users.noreply.github.com>
Date: Wed, 24 Jul 2024 13:12:05 +0100
Subject: [PATCH 4/7] LNP-866-enable-chemlsford (#712)
---
helm_deploy/prisoner-content-hub-frontend/values.yaml | 1 +
server/content/establishmentData.json | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/helm_deploy/prisoner-content-hub-frontend/values.yaml b/helm_deploy/prisoner-content-hub-frontend/values.yaml
index 0206a872..900cf5e3 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values.yaml
@@ -44,6 +44,7 @@ ingress:
prefixes:
- berwyn
- bullingdon
+ - chelmsford
- cookhamwood
- erlestoke
- felthama
diff --git a/server/content/establishmentData.json b/server/content/establishmentData.json
index bc92f50d..1e4d97b3 100644
--- a/server/content/establishmentData.json
+++ b/server/content/establishmentData.json
@@ -11,6 +11,12 @@
"youth": false,
"agencyId": "BNI"
},
+ "2001": {
+ "name": "chelmsford",
+ "displayName": "HMP Chelmsford",
+ "youth": false,
+ "agencyId": "CDI"
+ },
"959": {
"name": "cookhamwood",
"displayName": "HMP Cookham Wood",
From 65b4a2c5c045f71a564dd19ac2cd4534ecc695f0 Mon Sep 17 00:00:00 2001
From: Paul Solecki <51918433+psoleckimoj@users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:33:20 +0100
Subject: [PATCH 5/7] LNP-868: Add profile feature switching per site (#710)
* Allow profile features to be switched on/off per site
* Allow profile features to be switched on/off per site
* Return 404 page when profile disabled
* Replicate behaviour of approved visitors
* Extra check to check the site is enabled as well as the feature
* Extra check to check the site is enabled as well as the feature
* Remove adjudications enabled flag, enabled everywhere
* Remove approvedVisitors feature as fully enabled
* Make adjudications enabled match what is currently in prod
* Remove Chelmsford from approved visitors
* Get rid of hardwired Berwyn stuff
* Fix test
* Fix test mocking
* Fix tests
* Tidy feature/site checking
* Move function to utils
* Remove changes from irrelevant file
* Use common fn
* Make function easier to test
* Add start of tests for checkFeatureEnabledAtSite
* Add more tests
* Use constant to make config simpler/cleaner
* Rename new home template to home
* Enable approved visitors only at The Mount
* The Mount no approved visitors
* Comment to document commented out const
---
.../templates/_envs.tpl | 6 -
.../values-development.yaml | 2 -
.../values-production.yaml | 2 -
.../values-staging.yaml | 2 -
server/config.js | 113 ++++++++++++++----
.../__tests__/configureEstablishment.spec.js | 24 ++++
server/middleware/configureEstablishment.js | 2 +
server/routes/__tests__/homepage.spec.js | 1 +
server/routes/__tests__/profile.spec.js | 33 ++++-
server/routes/adjudications.js | 10 +-
server/routes/approvedVisitors.js | 9 +-
server/routes/homepage.js | 2 +-
server/routes/profile.js | 36 ++++--
server/utils/__tests__/index.spec.js | 83 +++++++++++++
server/utils/index.js | 9 ++
server/views/components/basicTemplate.njk | 2 +-
server/views/pages/home-new.html | 77 ------------
server/views/pages/home.html | 63 +++++++---
server/views/pages/profile.html | 17 +--
19 files changed, 343 insertions(+), 150 deletions(-)
delete mode 100644 server/views/pages/home-new.html
diff --git a/helm_deploy/prisoner-content-hub-frontend/templates/_envs.tpl b/helm_deploy/prisoner-content-hub-frontend/templates/_envs.tpl
index 9af9b58d..4a0e263e 100644
--- a/helm_deploy/prisoner-content-hub-frontend/templates/_envs.tpl
+++ b/helm_deploy/prisoner-content-hub-frontend/templates/_envs.tpl
@@ -52,12 +52,6 @@ env:
name: {{ .Values.application.contentConfigMapName }}
key: internalUrl
- - name: APPROVED_VISITORS_FEATURE_ENABLED
- value: {{ .Values.application.config.approvedVisitorsFeatureEnabled | quote }}
-
- - name: ADJUDICATIONS_FEATURE_ENABLED
- value: {{ .Values.application.config.adjudicationsFeatureEnabled | quote }}
-
- name: ELASTICSEARCH_ENDPOINT
valueFrom:
secretKeyRef:
diff --git a/helm_deploy/prisoner-content-hub-frontend/values-development.yaml b/helm_deploy/prisoner-content-hub-frontend/values-development.yaml
index 3851eeb4..393a8383 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values-development.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values-development.yaml
@@ -7,8 +7,6 @@ application:
analyticsSiteId: G-0RBPFCWD3X
googleTagManagerSiteId: GTM-M62TTBK
mockAuthEnabled: true
- approvedVisitorsFeatureEnabled: true
- adjudicationsFeatureEnabled: true
ingress:
annotations:
diff --git a/helm_deploy/prisoner-content-hub-frontend/values-production.yaml b/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
index 37b8117e..6f7002ec 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values-production.yaml
@@ -4,8 +4,6 @@ application:
analyticsSiteId: G-H1MT63QRLQ
googleTagManagerSiteId: GTM-M62TTBK
mockAuthEnabled: false
- approvedVisitorsFeatureEnabled: false
- adjudicationsFeatureEnabled: true
ingress:
annotations:
diff --git a/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml b/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
index c685df36..f2698a6f 100644
--- a/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
+++ b/helm_deploy/prisoner-content-hub-frontend/values-staging.yaml
@@ -4,8 +4,6 @@ application:
analyticsSiteId: G-FVRKLRH5PJ
googleTagManagerSiteId: GTM-M62TTBK
mockAuthEnabled: false
- approvedVisitorsFeatureEnabled: false
- adjudicationsFeatureEnabled: true
ingress:
annotations:
diff --git a/server/config.js b/server/config.js
index da845fc3..e91a11d0 100755
--- a/server/config.js
+++ b/server/config.js
@@ -14,6 +14,16 @@ const feedbackEndpoint = getRequiredEnv(
'/local-feedback/_doc',
);
+// covers all features being enabled to stop repetition as requested, commented out to stop errors in linting while no sites are using everything
+// const ALL_PROFILE_FEATURES = [
+// 'adjudications',
+// 'approvedVisitors',
+// 'incentives',
+// 'money',
+// 'timetable',
+// 'visits',
+// ];
+
module.exports = {
isProduction,
logLevel: getEnv('LOG_LEVEL', 'info'),
@@ -95,27 +105,88 @@ module.exports = {
showStackTraces:
getEnv('ENABLE_STACK_TRACES_ON_ERROR_PAGES', 'false') === 'true',
useRedisCache: getEnv('ENABLE_REDIS_CACHE', 'true') === 'true',
- approvedVisitorsFeatureEnabled:
- getEnv('APPROVED_VISITORS_FEATURE_ENABLED', 'false') === 'true',
- adjudicationsFeatureEnabled:
- getEnv('ADJUDICATIONS_FEATURE_ENABLED', 'false') === 'true',
- adjudicationsFeatureEnabledAt: [
- 'cookhamwood',
- 'erlestoke',
- 'felthama',
- 'felthamb',
- 'garth',
- 'lindholme',
- 'newhall',
- 'ranby',
- 'stokeheath',
- 'styal',
- 'swaleside',
- 'themount',
- 'wayland',
- 'werrington',
- 'wetherby',
- ],
+ },
+ sites: {
+ berwyn: {
+ enabled: false,
+ features: [],
+ },
+ bullingdon: {
+ enabled: true,
+ features: ['incentives', 'money', 'timetable', 'visits'],
+ },
+ chelmsford: {
+ enabled: true,
+ features: ['incentives', 'money', 'timetable', 'visits'],
+ },
+ cookhamwood: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ erlestoke: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ felthama: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ felthamb: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ garth: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ lindholme: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ newhall: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ ranby: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ stokeheath: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ styal: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ swaleside: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ themount: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ thestudio: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ wayland: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ werrington: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ wetherby: {
+ enabled: true,
+ features: ['adjudications', 'incentives', 'money', 'timetable', 'visits'],
+ },
+ woodhill: {
+ enabled: true,
+ features: ['incentives', 'money', 'timetable', 'visits'],
+ },
},
analytics: {
endpoint: getEnv(
diff --git a/server/middleware/__tests__/configureEstablishment.spec.js b/server/middleware/__tests__/configureEstablishment.spec.js
index 28563027..3768f25b 100644
--- a/server/middleware/__tests__/configureEstablishment.spec.js
+++ b/server/middleware/__tests__/configureEstablishment.spec.js
@@ -1,3 +1,26 @@
+const config = {
+ sites: {
+ berwyn: {
+ enabled: true,
+ features: [
+ 'adjudications',
+ 'approvedVisitors',
+ 'incentives',
+ 'money',
+ 'timetable',
+ 'visits',
+ ],
+ },
+ },
+ analytics: {
+ endpoint: 'https://www.google-analytics.com/collect',
+ siteId: 'G-0RBPFCWD3X',
+ gtmSiteId: 'GTM-M62TTBK',
+ },
+};
+
+jest.mock('../../config', () => config);
+
const configureEstablishment = require('../configureEstablishment');
describe('configureEstablishment', () => {
@@ -22,6 +45,7 @@ describe('configureEstablishment', () => {
configureEstablishment(req, res, next);
expect(res.locals.establishmentName).toBe('berwyn');
+ expect(res.locals.establishmentEnabled).toBe(true);
expect(res.locals.establishmentDisplayName).toBe('HMP Berwyn');
expect(next).toHaveBeenCalled();
});
diff --git a/server/middleware/configureEstablishment.js b/server/middleware/configureEstablishment.js
index 482b6de0..5ae4aa5c 100644
--- a/server/middleware/configureEstablishment.js
+++ b/server/middleware/configureEstablishment.js
@@ -1,5 +1,6 @@
const { v4: uuid } = require('uuid');
const { getEstablishmentId, getEstablishmentDisplayName } = require('../utils');
+const config = require('../config');
const configureEstablishment = (req, res, next) => {
const establishmentName = req.session?.establishmentName;
@@ -13,6 +14,7 @@ const configureEstablishment = (req, res, next) => {
res.locals.feedbackId = uuid();
res.locals.establishmentName = establishmentName;
+ res.locals.establishmentEnabled = config.sites[establishmentName]?.enabled;
res.locals.establishmentDisplayName = `${getEstablishmentDisplayName(
req.session.establishmentId,
)}`;
diff --git a/server/routes/__tests__/homepage.spec.js b/server/routes/__tests__/homepage.spec.js
index eae9ffbd..8f70afc5 100644
--- a/server/routes/__tests__/homepage.spec.js
+++ b/server/routes/__tests__/homepage.spec.js
@@ -188,6 +188,7 @@ describe('GET /', () => {
establishmentPersonalisationToggle(),
};
req.user = userSupplier();
+ res.locals.establishmentEnabled = true;
next();
});
app.use(setCurrentUser);
diff --git a/server/routes/__tests__/profile.spec.js b/server/routes/__tests__/profile.spec.js
index b30f02ee..e1000a2d 100644
--- a/server/routes/__tests__/profile.spec.js
+++ b/server/routes/__tests__/profile.spec.js
@@ -1,6 +1,29 @@
const request = require('supertest');
const cheerio = require('cheerio');
+const config = {
+ sites: {
+ berwyn: {
+ enabled: true,
+ features: [
+ 'adjudications',
+ 'approvedVisitors',
+ 'incentives',
+ 'money',
+ 'timetable',
+ 'visits',
+ ],
+ },
+ },
+ analytics: {
+ endpoint: 'https://www.google-analytics.com/collect',
+ siteId: 'G-0RBPFCWD3X',
+ gtmSiteId: 'GTM-M62TTBK',
+ },
+};
+
+jest.mock('../../config', () => config);
+
const {
testApp: { setupApp, userSupplier, sessionSupplier },
testData: { user },
@@ -19,12 +42,20 @@ describe('GET /profile', () => {
let app;
beforeEach(() => {
+ const establishmentData = {
+ 1: {
+ name: 'berwyn',
+ },
+ };
const cmsService = {
getPrimaryNavigation: jest.fn().mockResolvedValue([]),
getUrgentBanners: jest.fn().mockResolvedValue([]),
getTopics: jest.fn().mockReturnValue([]),
};
- app = setupApp({ offenderService, cmsService });
+ app = setupApp(
+ { offenderService, cmsService },
+ { config, establishmentData },
+ );
userSupplier.mockReturnValue(user);
});
diff --git a/server/routes/adjudications.js b/server/routes/adjudications.js
index e3f93269..fec397ee 100644
--- a/server/routes/adjudications.js
+++ b/server/routes/adjudications.js
@@ -2,6 +2,7 @@ const express = require('express');
const config = require('../config');
const { createBreadcrumbs } = require('../utils/breadcrumbs');
const { createPagination } = require('../utils/pagination');
+const { checkFeatureEnabledAtSite } = require('../utils');
const { logger } = require('../utils/logger');
const createAdjudicationsRouter = ({ offenderService }) => {
@@ -27,10 +28,7 @@ const createAdjudicationsRouter = ({ offenderService }) => {
const { user, originalUrl: returnUrl, query } = req;
if (
- config.features.adjudicationsFeatureEnabled &&
- config.features.adjudicationsFeatureEnabledAt.includes(
- req.session.establishmentName,
- )
+ checkFeatureEnabledAtSite(req.session.establishmentName, 'adjudications')
) {
let personalisation;
let error = null;
@@ -66,9 +64,9 @@ const createAdjudicationsRouter = ({ offenderService }) => {
const { adjudicationId } = req.params;
if (
- config.features.adjudicationsFeatureEnabled &&
- config.features.adjudicationsFeatureEnabledAt.includes(
+ checkFeatureEnabledAtSite(
req.session.establishmentName,
+ 'adjudications',
) &&
adjudicationId
) {
diff --git a/server/routes/approvedVisitors.js b/server/routes/approvedVisitors.js
index bb41c783..4f58b0e8 100644
--- a/server/routes/approvedVisitors.js
+++ b/server/routes/approvedVisitors.js
@@ -1,6 +1,6 @@
const express = require('express');
-const config = require('../config');
const { createBreadcrumbs } = require('../utils/breadcrumbs');
+const { checkFeatureEnabledAtSite } = require('../utils');
const createApprovedVisitorsRouter = ({ offenderService }) => {
const router = express.Router();
@@ -32,7 +32,12 @@ const createApprovedVisitorsRouter = ({ offenderService }) => {
router.get('/', async (req, res, next) => {
const { user, originalUrl: returnUrl, query } = req;
- if (config.features.approvedVisitorsFeatureEnabled) {
+ if (
+ checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'approvedVisitors',
+ )
+ ) {
try {
const personalisation = user
? await getPersonalisation(user, query)
diff --git a/server/routes/homepage.js b/server/routes/homepage.js
index 05a21302..91b0cf1f 100755
--- a/server/routes/homepage.js
+++ b/server/routes/homepage.js
@@ -40,7 +40,7 @@ const createHomepageRouter = ({ cmsService, offenderService }) => {
isLastPage &&
(updatesContentWithDuplicatesRemoved.length < 5 || !useLargeUpdateTile);
- res.render('pages/home-new', {
+ res.render('pages/home', {
config: {
content: true,
header: true,
diff --git a/server/routes/profile.js b/server/routes/profile.js
index 658e6170..c03d541c 100644
--- a/server/routes/profile.js
+++ b/server/routes/profile.js
@@ -1,6 +1,7 @@
const express = require('express');
const config = require('../config');
const { createBreadcrumbs } = require('../utils/breadcrumbs');
+const { checkFeatureEnabledAtSite } = require('../utils');
const createProfileRouter = ({ offenderService }) => {
const router = express.Router();
@@ -84,6 +85,10 @@ const createProfileRouter = ({ offenderService }) => {
};
router.get('/', async (req, res, next) => {
+ if (!config.sites[req.session.establishmentName]?.enabled) {
+ return next();
+ }
+
try {
const { user } = req;
const personalisation = user ? await getPersonalisation(user) : {};
@@ -96,14 +101,31 @@ const createProfileRouter = ({ offenderService }) => {
detailsType: 'small',
data: { contentType: 'profile', breadcrumbs: createBreadcrumbs(req) },
...personalisation,
- displayApprovedVisitorsCard:
- config.features.approvedVisitorsFeatureEnabled,
- displayAdjudicationsFeature:
- config.features.adjudicationsFeatureEnabled &&
- config.features.adjudicationsFeatureEnabledAt.includes(
+ displayVisits: checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'visits',
+ ),
+ displayTimetable: checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'timetable',
+ ),
+ displayIncentives: checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'incentives',
+ ),
+ displayMoney: checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'money',
+ ),
+ displayApprovedVisitors: checkFeatureEnabledAtSite(
+ req.session.establishmentName,
+ 'approvedVisitors',
+ ),
+ displayAdjudications:
+ checkFeatureEnabledAtSite(
req.session.establishmentName,
- ) &&
- personalisation.hasAdjudications,
+ 'adjudications',
+ ) && personalisation.hasAdjudications,
});
} catch (e) {
return next(e);
diff --git a/server/utils/__tests__/index.spec.js b/server/utils/__tests__/index.spec.js
index 5a93d63e..811f5ef7 100644
--- a/server/utils/__tests__/index.spec.js
+++ b/server/utils/__tests__/index.spec.js
@@ -4,6 +4,7 @@ const {
capitalizePersonName,
groupBy,
sortBy,
+ checkFeatureEnabledAtSite,
} = require('../index');
describe('Utils', () => {
@@ -191,4 +192,86 @@ describe('Utils', () => {
expect(contacts).toStrictEqual([contactC, contactA, contactB]);
});
});
+
+ describe('checkFeatureEnabledAtSite', () => {
+ const config = {
+ sites: {
+ prisonDisabled: {
+ enabled: false,
+ features: [],
+ },
+ prisonEnabledNoFeatures: {
+ enabled: true,
+ features: [],
+ },
+ prisonEnabledAdjudications: {
+ enabled: true,
+ features: ['adjudications'],
+ },
+ prisonEnabledApprovedVisitors: {
+ enabled: true,
+ features: ['approvedVisitors'],
+ },
+ prisonEnabledMoney: {
+ enabled: true,
+ features: ['money'],
+ },
+ prisonEnabledIncentives: {
+ enabled: true,
+ features: ['incentives'],
+ },
+ prisonEnabledTimetable: {
+ enabled: true,
+ features: ['timetable'],
+ },
+ prisonEnabledVisits: {
+ enabled: true,
+ features: ['visits'],
+ },
+ prisonEnabledVisitsMoney: {
+ enabled: true,
+ features: ['visits', 'money'],
+ },
+ },
+ };
+
+ test.each([
+ { site: 'prisonDisabled', feature: 'adjudications', expected: false },
+ {
+ site: 'prisonEnabledNoFeatures',
+ feature: 'adjudications',
+ expected: false,
+ },
+ {
+ site: 'prisonEnabledAdjudications',
+ feature: 'adjudications',
+ expected: true,
+ },
+ {
+ site: 'prisonEnabledMoney',
+ feature: 'adjudications',
+ expected: false,
+ },
+ {
+ site: 'prisonEnabledVisitsMoney',
+ feature: 'adjudications',
+ expected: false,
+ },
+ {
+ site: 'prisonEnabledVisitsMoney',
+ feature: 'visits',
+ expected: true,
+ },
+ {
+ site: 'prisonEnabledVisitsMoney',
+ feature: 'money',
+ expected: true,
+ },
+ ])(
+ 'checkFeatureEnabledAtSite($site, $feature) should return $expected',
+ ({ site, feature, expected }) => {
+ expect(checkFeatureEnabledAtSite(site, feature, config)).toBe(expected);
+ },
+ );
+ });
});
diff --git a/server/utils/index.js b/server/utils/index.js
index d6fb2d20..bead3ee2 100644
--- a/server/utils/index.js
+++ b/server/utils/index.js
@@ -1,4 +1,5 @@
const defaultEstablishmentData = require('../content/establishmentData.json');
+const defaultConfig = require('../config');
const getEstablishmentId = (
establishmentName,
@@ -72,6 +73,13 @@ const sortBy = key => (a, b) => {
return a[key] < b[key] ? -1 : 1;
};
+function checkFeatureEnabledAtSite(site, feature, config = defaultConfig) {
+ return (
+ config.sites[site]?.enabled &&
+ config.sites[site]?.features.includes(feature)
+ );
+}
+
module.exports = {
getEstablishmentId,
getEstablishment,
@@ -82,4 +90,5 @@ module.exports = {
capitalizePersonName,
groupBy,
sortBy,
+ checkFeatureEnabledAtSite,
};
diff --git a/server/views/components/basicTemplate.njk b/server/views/components/basicTemplate.njk
index f8171a3f..06c7f559 100644
--- a/server/views/components/basicTemplate.njk
+++ b/server/views/components/basicTemplate.njk
@@ -85,7 +85,7 @@
{{ pageNavigation({ title: title, hideHomePage: data.breadcrumbs }) }}
{% endblock %}
{% block userDetails %}
- {% if establishmentName != 'berwyn' %}
+ {% if establishmentEnabled %}
{{ userDetails({
hideSignInLink: hideSignInLink,
isSignedIn: isSignedIn,
diff --git a/server/views/pages/home-new.html b/server/views/pages/home-new.html
deleted file mode 100644
index a5ddf8ff..00000000
--- a/server/views/pages/home-new.html
+++ /dev/null
@@ -1,77 +0,0 @@
-{% from "govuk/components/button/macro.njk" import govukButton %}
-{% from "../components/personal-schedule-today/macro.njk" import personalScheduleToday %}
-{% from "../components/content-tile-small/macro.njk" import contentTileSmall %}
-{% from "../components/content-tile-featured/macro.njk" import contentTileFeatured %}
-{% from "../components/update-items/macro.njk" import updateItems %}
-{% from "../components/hub-content-block/macro.njk" import hubContentBlock %}
-{% from "../components/key-info-items/macro.njk" import keyInfoItems %}
-
-{% extends "../components/basicTemplate.njk" %}
-
-{% set blackBackground = true %}
-
-{% block pageNavigation %}
- {{ govukButton({
- text: "Browse all topics",
- href: "/topics",
- isStartButton: true,
- classes: "govuk-!-margin-top-2 govuk-!-margin-bottom-2 govuk-!-margin-right-2"
- }) }}
-{% endblock %}
-
-{% block title %}
- {% if establishmentName != 'berwyn' %}
-
- {{personalScheduleToday({ data: currentEvents, authReturnUrl: returnUrl }, userName if isSignedIn else '')}}
-
- {% endif %}
-{% endblock %}
-
-{% block content %}
- {% if largeUpdateTile or (updatesContent | length) or (keyInfo.data | length) %}
-
- Updates
-
-
-
- {% if largeUpdateTile %}
- {{ contentTileFeatured(largeUpdateTile) }}
- {% endif %}
-
-
- {% if updatesContent | length %}
- {{ updateItems(updatesContent, updatesContentHideViewAll) }}
- {% endif %}
-
-
- {% if keyInfo.data | length %}
- {{ keyInfoItems(keyInfo) }}
- {% endif %}
-
-
-
- {% endif %}
-
- {{ hubContentBlock({
- title: 'Featured',
- id: 'featuredContent',
- data: featuredContent
- }) }}
-
- {{ hubContentBlock({
- title: 'Recently added',
- viewAllUrl: '/recently-added',
- id: 'recentlyAdded',
- data: recentlyAddedHomepageContent
- }) }}
-
- {{ hubContentBlock({
- title: 'Explore the Hub',
- id: 'exploreContent',
- data: exploreContent,
- hideHorizontalRule: true
- }) }}
-{% endblock %}
-
-{% block feedback %}
-{% endblock %}
diff --git a/server/views/pages/home.html b/server/views/pages/home.html
index 3302a3e4..449a2f0f 100644
--- a/server/views/pages/home.html
+++ b/server/views/pages/home.html
@@ -1,7 +1,10 @@
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "../components/personal-schedule-today/macro.njk" import personalScheduleToday %}
-{% from "../components/content-tile-large/macro.njk" import contentTileLarge %}
{% from "../components/content-tile-small/macro.njk" import contentTileSmall %}
+{% from "../components/content-tile-featured/macro.njk" import contentTileFeatured %}
+{% from "../components/update-items/macro.njk" import updateItems %}
+{% from "../components/hub-content-block/macro.njk" import hubContentBlock %}
+{% from "../components/key-info-items/macro.njk" import keyInfoItems %}
{% extends "../components/basicTemplate.njk" %}
@@ -12,12 +15,12 @@
text: "Browse all topics",
href: "/topics",
isStartButton: true,
- classes: "govuk-!-margin-2"
+ classes: "govuk-!-margin-top-2 govuk-!-margin-bottom-2 govuk-!-margin-right-2"
}) }}
{% endblock %}
{% block title %}
- {% if establishmentName != 'berwyn' %}
+ {% if establishmentEnabled %}
{{personalScheduleToday({ data: currentEvents, authReturnUrl: returnUrl }, userName if isSignedIn else '')}}
@@ -25,19 +28,49 @@
{% endblock %}
{% block content %}
-
- {% if homepage.upperFeatured %}
- {{ contentTileLarge({content: homepage.upperFeatured, imageAlign: 'right'}) }}
- {% endif %}
-
- {% for tile in homepage.smallTiles %}
- {{ contentTileSmall(tile) }}
- {% endfor %}
+ {% if largeUpdateTile or (updatesContent | length) or (keyInfo.data | length) %}
+
+ Updates
+
+
+
+ {% if largeUpdateTile %}
+ {{ contentTileFeatured(largeUpdateTile) }}
+ {% endif %}
+
+
+ {% if updatesContent | length %}
+ {{ updateItems(updatesContent, updatesContentHideViewAll) }}
+ {% endif %}
+
+
+ {% if keyInfo.data | length %}
+ {{ keyInfoItems(keyInfo) }}
+ {% endif %}
+
- {% if homepage.lowerFeatured %}
- {{ contentTileLarge({content: homepage.lowerFeatured, imageAlign: 'left'}) }}
- {% endif %}
-
+
+ {% endif %}
+
+ {{ hubContentBlock({
+ title: 'Featured',
+ id: 'featuredContent',
+ data: featuredContent
+ }) }}
+
+ {{ hubContentBlock({
+ title: 'Recently added',
+ viewAllUrl: '/recently-added',
+ id: 'recentlyAdded',
+ data: recentlyAddedHomepageContent
+ }) }}
+
+ {{ hubContentBlock({
+ title: 'Explore the Hub',
+ id: 'exploreContent',
+ data: exploreContent,
+ hideHorizontalRule: true
+ }) }}
{% endblock %}
{% block feedback %}
diff --git a/server/views/pages/profile.html b/server/views/pages/profile.html
index 2db9f8b3..634247ef 100644
--- a/server/views/pages/profile.html
+++ b/server/views/pages/profile.html
@@ -26,6 +26,7 @@
You are signed out
Sign in to see your personal information.
{% else %}
+ {% if displayTimetable %}
Today's timetable
@@ -58,7 +59,8 @@ Today's timetable
{% endif %}
-
+ {% endif %}
+ {% if displayIncentives %}
Incentives (IEP)
@@ -78,7 +80,8 @@ Incentives (IEP)
{% endif %}
-
+ {% endif %}
+ {% if displayMoney %}
Money
@@ -127,8 +130,8 @@ Money
{% endif %}
-
-
+ {% endif %}
+ {% if displayVisits %}
Visits
@@ -172,7 +175,7 @@ Visits
{%- endcall %}
{%- endif %}
- {% if displayApprovedVisitorsCard %}
+ {% if displayApprovedVisitors %}
{{imageCard({ id: 'approvedVisitors', src: "/public/images/image_visitors.jpg", link: knownPages.profile.visitorsLink, description: "View my visitors - social" }) }}
@@ -184,8 +187,8 @@ Visits
{% endif %}
-
- {% if displayAdjudicationsFeature %}
+ {% endif %}
+ {% if displayAdjudications %}
Adjudications
From ee41b8bdb50d256e253ba5dfddbc0689729ec73e Mon Sep 17 00:00:00 2001
From: Elliot Ward
Date: Tue, 13 Aug 2024 09:31:11 +0100
Subject: [PATCH 6/7] =?UTF-8?q?LNP-943:=20=F0=9F=94=A5=20=20remove=20field?=
=?UTF-8?q?=5Fnot=5Fin=5Fseries=20filter=20when=20querying=20for=20content?=
=?UTF-8?q?=20within=20a=20category.=20(#713)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
e2e/cypress/mockApis/drupalData/urgentBanners.json | 1 -
.../cmsQueries/__tests__/categoryContentQuery.spec.js | 2 +-
server/repositories/cmsQueries/categoryContentQuery.js | 1 -
3 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/e2e/cypress/mockApis/drupalData/urgentBanners.json b/e2e/cypress/mockApis/drupalData/urgentBanners.json
index a94029d9..9cdca62a 100644
--- a/e2e/cypress/mockApis/drupalData/urgentBanners.json
+++ b/e2e/cypress/mockApis/drupalData/urgentBanners.json
@@ -132,7 +132,6 @@
"published_at": "2020-11-13T12:50:07+00:00",
"field_moj_episode": null,
"field_moj_season": null,
- "field_not_in_series": true,
"field_release_date": null
},
"relationships": {
diff --git a/server/repositories/cmsQueries/__tests__/categoryContentQuery.spec.js b/server/repositories/cmsQueries/__tests__/categoryContentQuery.spec.js
index fd968394..b7e11ab0 100644
--- a/server/repositories/cmsQueries/__tests__/categoryContentQuery.spec.js
+++ b/server/repositories/cmsQueries/__tests__/categoryContentQuery.spec.js
@@ -10,7 +10,7 @@ describe('Category collection query', () => {
describe('path', () => {
it('should create correct path', () => {
expect(query.path()).toStrictEqual(
- `/jsonapi/prison/${ESTABLISHMENTNAME}/node?filter%5Bfield_moj_top_level_categories.id%5D=${UUID}&filter%5Bfield_not_in_series%5D=1&include=field_moj_thumbnail_image&sort=-created&fields%5Bnode--page%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bnode--moj_video_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bnode--moj_radio_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bmoj_pdf_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&${getPagination(
+ `/jsonapi/prison/${ESTABLISHMENTNAME}/node?filter%5Bfield_moj_top_level_categories.id%5D=${UUID}&include=field_moj_thumbnail_image&sort=-created&fields%5Bnode--page%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bnode--moj_video_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bnode--moj_radio_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&fields%5Bmoj_pdf_item%5D=drupal_internal__nid%2Ctitle%2Cfield_summary%2Cfield_moj_thumbnail_image%2Cpath%2Cpublished_at&${getPagination(
PAGE,
LIMIT,
)}`,
diff --git a/server/repositories/cmsQueries/categoryContentQuery.js b/server/repositories/cmsQueries/categoryContentQuery.js
index 19c61ec8..b8c5e05a 100644
--- a/server/repositories/cmsQueries/categoryContentQuery.js
+++ b/server/repositories/cmsQueries/categoryContentQuery.js
@@ -19,7 +19,6 @@ class CategoryContentQuery {
this.page = page;
const queryWithoutOffset = new Query()
.addFilter('field_moj_top_level_categories.id', uuid)
- .addFilter('field_not_in_series', 1)
.addFields('node--page', CategoryContentQuery.#TILE_FIELDS)
.addFields('node--moj_video_item', CategoryContentQuery.#TILE_FIELDS)
.addFields('node--moj_radio_item', CategoryContentQuery.#TILE_FIELDS)
From f9efc0fb1574e511f46fd29a9ff3cb7c6f48f8bc Mon Sep 17 00:00:00 2001
From: Elliot Ward
Date: Thu, 15 Aug 2024 11:15:57 +0100
Subject: [PATCH 7/7] =?UTF-8?q?LNP-953:=20=E2=AC=86=EF=B8=8F=20=20update?=
=?UTF-8?q?=20axios=20to=201.7.4.=20(#714)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package-lock.json | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 7a96dde8..887fc188 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3173,9 +3173,10 @@
}
},
"node_modules/axios": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz",
- "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==",
+ "version": "1.7.4",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz",
+ "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==",
+ "license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",