Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6a872d3
Accept a base page layout path in plugin options
alexluckett Apr 9, 2025
e8da583
remove non-engine pages, leaving just a development UI
alexluckett Apr 9, 2025
36c380d
allow plugin consumer to provide viewContext props
alexluckett Apr 9, 2025
8149852
Export engine dir
alexluckett Apr 17, 2025
788b89a
take nunjucks paths and view context from consumer
alexluckett Apr 17, 2025
b461c45
add local devtool UI
alexluckett Apr 22, 2025
3855d55
Drop redundant configureEnginePlugin
alexluckett Apr 22, 2025
0b43828
make DXT devtool layout more obvious
alexluckett Apr 22, 2025
a8dd77e
update docs
alexluckett Apr 22, 2025
8cffdc8
fix circular reference error when stringifying error
alexluckett Apr 24, 2025
32e3be5
an example of custom styling
alexluckett Apr 24, 2025
27b8234
remove unused type
alexluckett Apr 24, 2025
06c425a
Remove service banner text
alexluckett Apr 24, 2025
de0a429
Remove cookies + blankie
alexluckett Apr 24, 2025
68f6ea3
Revert "Drop redundant configureEnginePlugin"
alexluckett Apr 24, 2025
8597062
remove runner responsibilities: health, cookies tests
alexluckett Apr 24, 2025
70347d2
remove runner responsibility: feedback tests
alexluckett Apr 24, 2025
3d9527a
Remove consumer responsibility: phase banner
alexluckett Apr 24, 2025
c2e40f8
fix linting issues
alexluckett Apr 24, 2025
1f80acf
Remove runner responsibility: help page tests
alexluckett Apr 24, 2025
1efb66f
Move devtool view context into separate function
alexluckett Apr 24, 2025
45ce42b
Load engine forms from disk
alexluckett Apr 24, 2025
94ab1fc
Only load file-based forms when running the devserver
alexluckett Apr 24, 2025
1613637
Resolve form mocking issue when running tests
alexluckett Apr 24, 2025
8c81a25
Move base layout into nunjucks options
alexluckett Apr 25, 2025
8ab723d
clarify when localFormsService returns a function, not the serviec
alexluckett Apr 25, 2025
a2509b0
patch context test for new required plugin
alexluckett Apr 25, 2025
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
33 changes: 30 additions & 3 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,44 @@ await server.register({
}
})

const viewPaths = [join(config.get('appDir'), 'views')]

// Register the `forms-engine-plugin`
await server.register({
plugin
plugin,
options: {
cacheName: 'session', // must match a session you've instantiated in your hapi server config
/**
* Options that DXT uses to render Nunjucks templates
*/
nunjucks: {
basePageLayout: 'your-base-layout.html', // the base page layout. Usually based off https://design-system.service.gov.uk/styles/page-template/
viewPaths // list of directories DXT should use to render your views. Must contain basePageLayout.
},
/**
* Services is what DXT uses to interact with external APIs
*/
services: {
formsService, // where your forms should be downloaded from.
formSubmissionService, // handles temporary storage of file uploads
outputService // where your form should be submitted to
},
/**
* View context attributes made available to your pages. Returns an object containing an arbitrary set of key-value pairs.
*/
viewContext: (request) => {
"example": "hello world" // available to render on a nunjucks page as {{ example }}
}
}
})

await server.start()
```

## Step 3: Handling static assets

TODO: CSS will be updated with a proper build process using SASS.

1. [Update webpack to bundle the DXT application assets (CSS, JavaScript, etc)](https://github.com/DEFRA/forms-engine-plugin-example-ui/pull/1/files#diff-1fb26bc12ac780c7ad7325730ed09fc4c2c3d757c276c3dacc44bfe20faf166f)
2. [Serve the newly bundled assets from your web server](https://github.com/DEFRA/forms-engine-plugin-example-ui/pull/1/files#diff-e5b183306056f90c7f606b526dbc0d0b7e17bccd703945703a0811b6e6bb3503)

Expand All @@ -116,8 +144,7 @@ Blocks marked with `# FEATURE: <name>` are optional and can be omitted if the fe
FEEDBACK_LINK=http://test.com
# END FEATURE: Phase banner

# START FEATURE: DXT -- used if using DXT's infrastructure to store your forms and file uploads
MANAGER_URL=http://localhost:3001
# START FEATURE: DXT -- used if using DXT's infrastructure for file uploads
DESIGNER_URL=http://localhost:3000
SUBMISSION_URL=http://localhost:3002

Expand Down
1 change: 0 additions & 1 deletion jest.setup.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
process.env.MANAGER_URL = 'http://localhost:3001'
process.env.REDIS_HOST = 'dummy'
process.env.REDIS_KEY_PREFIX = 'forms-designer'
process.env.REDIS_PASSWORD = 'dummy'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"./file-form-service.js": "./.server/server/utils/file-form-service.js",
"./controllers/*": "./.server/server/plugins/engine/pageControllers/*",
"./services/*": "./.server/server/plugins/engine/services/*",
"./engine/*": "./.server/server/plugins/engine/*",
"./package.json": "./package.json"
},
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions src/client/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@
.autocomplete__option {
@include govuk-typography-common;
}

// An example of some user-supplied styling
// Not great practice but it illustrates the point
.govuk-header {
background: #008531;
}

.govuk-header__container {
border-bottom: 10px solid #003d16;
}
58 changes: 0 additions & 58 deletions src/common/cookies.js

This file was deleted.

23 changes: 0 additions & 23 deletions src/common/cookies.test.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/common/types.js

This file was deleted.

21 changes: 4 additions & 17 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ export const config = convict({
/**
* API integrations
*/
managerUrl: {
format: String,
default: 'http://localhost:3001',
env: 'MANAGER_URL'
} as SchemaObj<string>,

designerUrl: {
format: String,
default: 'http://localhost:3000',
Expand Down Expand Up @@ -253,19 +247,12 @@ export const config = convict({
env: 'STAGING_PREFIX'
},

serviceBannerText: {
doc: 'Service banner text used to show a maintenance message on all pages when set',
format: String,
default: '',
env: 'SERVICE_BANNER_TEXT'
},

googleAnalyticsTrackingId: {
doc: 'Google analytics tracking ID to be used when a user has opted in to additional cookies',
submissionEmailAddress: {
doc: 'Email address to send the form to (local devtool only)',
format: String,
default: '',
env: 'GOOGLE_ANALYTICS_TRACKING_ID'
}
env: 'SUBMISSION_EMAIL_ADDRESS'
} as SchemaObj<string>
})

config.validate({ allowed: 'strict' })
71 changes: 71 additions & 0 deletions src/server/devserver/dxt-devtool-baselayout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{% extends "govuk/template.njk" %}

{% from "govuk/components/back-link/macro.njk" import govukBackLink -%}
{% from "govuk/components/footer/macro.njk" import govukFooter -%}
{% from "govuk/components/phase-banner/macro.njk" import govukPhaseBanner -%}
{% from "govuk/components/skip-link/macro.njk" import govukSkipLink -%}
{% from "govuk/macros/attributes.njk" import govukAttributes -%}
{% from "components/service-banner/macro.njk" import appServiceBanner -%}
{% from "components/tag-env/macro.njk" import appTagEnv -%}
{% from "govuk/components/cookie-banner/macro.njk" import govukCookieBanner -%}
{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner -%}

{% set productName %}
{{ appTagEnv({ env: "devtool" }) }}
{% endset %}

{% block head %}
<link rel="preload" as="font" href="{{ assetPath }}/fonts/bold-b542beb274-v2.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="{{ assetPath }}/fonts/light-94a07e06a1-v2.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="stylesheet" href="{{ getDxtAssetPath("stylesheets/application.scss") }}">
{% endblock %}

{% block pageTitle -%}
{{ "Error: " if errors | length }}{{ pageTitle | evaluate }} - {{ name if name else config.serviceName }} - GOV.UK
{%- endblock %}

{% block skipLink %}
{{ govukSkipLink({
href: '#main-content',
text: 'Skip to main content'
}) }}
{% endblock %}

{% block header %}
{{ govukHeader({
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",
serviceUrl: currentPath if context.isForceAccess else serviceUrl
}) }}
{% endblock %}

{% block beforeContent %}
{% if backLink %}
{{ govukBackLink(backLink) }}
{% endif %}
{% endblock %}

{% block content %}
<h1 class="govuk-heading-l">Default page template</h1>
{% endblock %}

{% block bodyEnd %}
<script type="module" nonce="{{ cspNonce }}" src="{{ getDxtAssetPath("application.js") }}"></script>
{% endblock %}

{% block footer %}
{% set meta = {
items: [
{
href: 'https://defra.github.io/forms-engine-plugin/',
text: 'DXT documentation'
}
]
} if slug %}

{% if not context.isForceAccess %}
{{ govukFooter({ meta: meta }) }}
{% endif %}
{% endblock %}
10 changes: 0 additions & 10 deletions src/server/forms/README.md

This file was deleted.

Loading
Loading