Skip to content
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
2 changes: 1 addition & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const config = convict({
serviceName: {
doc: 'Applications Service Name',
format: String,
default: 'Submit a form to Defra'
default: 'Digital Express Toolkit'
},
serviceVersion: {
doc: 'The service version, this variable is injected into your docker container in CDP environments',
Expand Down
2 changes: 1 addition & 1 deletion src/server/devserver/dxt-devtool-baselayout.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
homepageUrl: currentPath if context.isForceAccess else "https://defra.github.io/forms-engine-plugin/",
containerClasses: "govuk-width-container",
productName: productName | safe | trim,
serviceName: "Digital Express Toolkit",
serviceName: config.serviceName,
serviceUrl: currentPath if context.isForceAccess else serviceUrl
}) }}
{% endblock %}
Expand Down
19 changes: 9 additions & 10 deletions src/server/plugins/nunjucks/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { basename, join } from 'node:path'
import Boom from '@hapi/boom'
import { StatusCodes } from 'http-status-codes'

import pkg from '~/package.json' with { type: 'json' }
import { config } from '~/src/config/index.js'
import { createLogger } from '~/src/server/common/helpers/logging/logger.js'
import {
Expand Down Expand Up @@ -32,6 +31,7 @@ export async function context(request) {
!Boom.isBoom(response) && response?.statusCode === StatusCodes.OK

const pluginStorage = request?.server.plugins['forms-engine-plugin']

let consumerViewContext = {}

if (!pluginStorage) {
Expand All @@ -51,15 +51,6 @@ export async function context(request) {
// take consumers props first so we can override it
...consumerViewContext,
baseLayoutPath: pluginStorage.baseLayoutPath,
appVersion: pkg.version,
config: {
cdpEnvironment: config.get('cdpEnvironment'),
designerUrl: config.get('designerUrl'),
feedbackLink: encodeUrl(config.get('feedbackLink')),
phaseTag: config.get('phaseTag'),
serviceName: config.get('serviceName'),
serviceVersion: config.get('serviceVersion')
},
crumb: safeGenerateCrumb(request),
currentPath: `${request.path}${request.url.search}`,
previewMode: isPreviewMode ? formState : undefined,
Expand Down Expand Up @@ -87,6 +78,14 @@ export function devtoolContext(_request) {
}

return {
config: {
cdpEnvironment: config.get('cdpEnvironment'),
designerUrl: config.get('designerUrl'),
feedbackLink: encodeUrl(config.get('feedbackLink')),
phaseTag: config.get('phaseTag'),
serviceName: config.get('serviceName'),
serviceVersion: config.get('serviceVersion')
},
assetPath: '/assets',
getDxtAssetPath: (asset = '') => {
return `/${webpackManifest?.[asset] ?? asset}`
Expand Down
7 changes: 0 additions & 7 deletions src/server/plugins/nunjucks/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@

/**
* @typedef {object} ViewContext - Nunjucks view context
* @property {string} appVersion - Application version
* @property {string} [baseLayoutPath] - Base layout path
* @property {Partial<Config>} config - Application config properties
* @property {string} [crumb] - Cross-Site Request Forgery (CSRF) token
* @property {string} [cspNonce] - Content Security Policy (CSP) nonce
* @property {string} [currentPath] - Current path
* @property {string} [previewMode] - Preview mode
* @property {string} [slug] - Form slug
* @property {FormContext} [context] - the current form context
* @property {PluginOptions['viewContext']} [injectedViewContext] - the current form context
*/

/**
* @typedef {ReturnType<typeof config['getProperties']>} Config - Application config properties
*/

/**
Expand Down
Loading