hof 22.6.0 → 22.7.0-service-paused-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/components/index.js +2 -1
- package/components/service-paused/Readme.md +26 -0
- package/components/service-paused/index.js +48 -0
- package/config/hof-defaults.js +2 -1
- package/frontend/template-partials/translations/src/en/pages.json +8 -0
- package/frontend/template-partials/views/service-paused.html +24 -0
- package/index.js +7 -0
- package/package.json +1 -1
- package/sandbox/server.js +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 2025-05-14, Version 22.7.0 (Stable), @Rhodine-orleans-lindsay
|
2
|
+
### Added
|
3
|
+
- Service paused funtionality that allows for services to redirect to a 'Service Unavailable' when there is a need to pause a service.
|
4
|
+
- Includes service paused component
|
5
|
+
- default service paused html view
|
6
|
+
- Flag to set service paused config to true or false in order to run component
|
7
|
+
### Security
|
8
|
+
- Updates patch and minor dependencies
|
9
|
+
|
1
10
|
## 2025-05-09, Version 22.6.0 (Stable), @vivekkumar-ho
|
2
11
|
### Changed
|
3
12
|
- Support for passing `maxlengthAttribute` property for input-text field. The HTML maxlength attribute is applied when `maxlengthAttribute: true` and the `maxlength` validator are specified in the field config
|
package/components/index.js
CHANGED
@@ -9,5 +9,6 @@ module.exports = {
|
|
9
9
|
homeOfficeCountries: require('./homeoffice-countries'),
|
10
10
|
notify: require('./notify'),
|
11
11
|
summary: require('./summary'),
|
12
|
-
sessionTimeoutWarning: require('./session-timeout-warning')
|
12
|
+
sessionTimeoutWarning: require('./session-timeout-warning'),
|
13
|
+
servicePaused: require('./service-paused')
|
13
14
|
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Service Paused Behaviour
|
2
|
+
|
3
|
+
## What this does
|
4
|
+
Allows a service to be paused when required and then resumed. It ensures that anyone using the service that lands on any part of the form is diverted to a "Service Unavailable" page which will communicate to the user that the service is not available at this time.
|
5
|
+
|
6
|
+
## Implementation
|
7
|
+
- Add the behaviour to the hof-settings.json file of the service
|
8
|
+
- Set the `SERVICE_PAUSED` env to `true`
|
9
|
+
|
10
|
+
## Page Content Customisation
|
11
|
+
There is default text for this page. Default text can be overridden by setting the `message` and `answers-saved` properties in the pages.json of the service. Note that information relating to who to contact and alternatives to using the form is optional and so there is no default text for these unless the properties `contact` and `alternative` are set in pages.json:
|
12
|
+
|
13
|
+
```json
|
14
|
+
"message": {
|
15
|
+
"message": "This service will be unavailble for a week."
|
16
|
+
},
|
17
|
+
"answers-saved": {
|
18
|
+
"message": "Your information has not been saved."
|
19
|
+
},
|
20
|
+
"contact": {
|
21
|
+
"message": "You can contact test@test.com for more information"
|
22
|
+
},
|
23
|
+
"alternative": {
|
24
|
+
"message": "You can access the www.test.com website instead"
|
25
|
+
},
|
26
|
+
```
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* @fileOverview
|
4
|
+
* Provides custom behavior for rendering a service down template when a service needs to be temporarily paused. This includes
|
5
|
+
* - Redirecting the user to a 'service down' page
|
6
|
+
* - Setting custom content and titles on the service down page.
|
7
|
+
*
|
8
|
+
* @module servicePausedBehaviour
|
9
|
+
* @requires ../../config/hof-defaults
|
10
|
+
* @param {Class} superclass - The class to be extended.
|
11
|
+
* @returns {Class} - The extended class with service down handling functionality.
|
12
|
+
*/
|
13
|
+
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
const config = require('../../config/hof-defaults');
|
17
|
+
const logger = require('../../lib/logger')(config);
|
18
|
+
|
19
|
+
module.exports = superclass => class extends superclass {
|
20
|
+
getValues(req, res, callback) {
|
21
|
+
return super.getValues(req, res, (err, values) => {
|
22
|
+
if (err) {
|
23
|
+
logger.error(`Error getting values: ${err}`);
|
24
|
+
return callback(err, values);
|
25
|
+
}
|
26
|
+
if (config.servicePaused === true || config.servicePaused === 'true') {
|
27
|
+
logger.info(`Service is paused. Redirecting...`);
|
28
|
+
res.redirect('/service-paused');
|
29
|
+
}
|
30
|
+
|
31
|
+
return callback(null, values);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
locals(req, res) {
|
35
|
+
// set default service unavailable message
|
36
|
+
const superLocals = super.locals(req, res);
|
37
|
+
if (config.servicePaused === true || config.servicePaused === 'true') {
|
38
|
+
superLocals.header = req.translate('pages.service-paused.header');
|
39
|
+
superLocals.title = req.translate('pages.service-paused.title');
|
40
|
+
superLocals.message = req.translate('pages.service-paused.message');
|
41
|
+
superLocals['answers-saved'] = req.translate('pages.service-paused.answers-saved');
|
42
|
+
superLocals.contact = req.translate('pages.service-paused.contact');
|
43
|
+
superLocals.alternative = req.translate('pages.service-paused.alternative');
|
44
|
+
return superLocals;
|
45
|
+
}
|
46
|
+
return superLocals;
|
47
|
+
}
|
48
|
+
};
|
package/config/hof-defaults.js
CHANGED
@@ -51,7 +51,8 @@ const defaults = {
|
|
51
51
|
pdfConverter: process.env.PDF_CONVERTER_URL
|
52
52
|
},
|
53
53
|
serveStatic: process.env.SERVE_STATIC_FILES !== 'false',
|
54
|
-
sessionTimeOutWarning: process.env.SESSION_TIMEOUT_WARNING || 300
|
54
|
+
sessionTimeOutWarning: process.env.SESSION_TIMEOUT_WARNING || 300,
|
55
|
+
servicePaused: process.env.SERVICE_PAUSED || false
|
55
56
|
};
|
56
57
|
|
57
58
|
module.exports = Object.assign({}, defaults, rateLimits);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{{<layout}}
|
2
|
+
{{$journeyHeader}}
|
3
|
+
{{#t}}journey.header{{/t}}
|
4
|
+
{{/journeyHeader}}
|
5
|
+
|
6
|
+
{{$propositionHeader}}
|
7
|
+
{{> partials-navigation}}
|
8
|
+
{{/propositionHeader}}
|
9
|
+
|
10
|
+
{{$header}}
|
11
|
+
{{header}}
|
12
|
+
{{/header}}
|
13
|
+
|
14
|
+
{{$content}}
|
15
|
+
<p>{{message}}</p>
|
16
|
+
<p>{{answers-saved}}</p>
|
17
|
+
{{#contact}}
|
18
|
+
<p>{{contact}}</p>
|
19
|
+
{{/contact}}
|
20
|
+
{{#alternative}}
|
21
|
+
<p>{{alternative}}</p>
|
22
|
+
{{/alternative}}
|
23
|
+
{{/content}}
|
24
|
+
{{/layout}}
|
package/index.js
CHANGED
@@ -231,6 +231,13 @@ function bootstrap(options) {
|
|
231
231
|
// Set up routing so <YOUR-SITE-URL>/assets are served from /node_modules/govuk-frontend/govuk/assets
|
232
232
|
app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/assets')));
|
233
233
|
|
234
|
+
if (config.servicePaused === true || config.servicePaused === 'true') {
|
235
|
+
app.use('/service-paused', (req, res) => {
|
236
|
+
const locals = Object.assign({}, req.translate('pages.service-paused'));
|
237
|
+
res.render('service-paused', locals);
|
238
|
+
});
|
239
|
+
}
|
240
|
+
|
234
241
|
if (config.getAccessibility === true) {
|
235
242
|
deprecate(
|
236
243
|
'`getAccessibility` option is deprecated and may be removed in future versions.',
|
package/package.json
CHANGED
package/sandbox/server.js
CHANGED