Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'manage' start page #239

Merged
merged 15 commits into from
Aug 12, 2024
9 changes: 8 additions & 1 deletion config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ aws: {
}
# ToDo: url and name might need updating
url: 'https://check-planning.data.gov.uk'
serviceName: 'Provide planning and housing data for England'
# NOTE: this property is deprecated, use serviceNames instead
serviceName: 'Submit and update your planning data'
# NOTE: the keys in this map are sometimes referred to as "serviceType" in the templates
serviceNames: {
submit: 'Submit and update your planning data',
check: 'Check planning and housing data for England',
manage: 'Submit and update your planning data'
}
feedbackLink: 'https://docs.google.com/forms/d/e/1FAIpQLSdYXqY0Aaket9XJBiGDhSL_CD_cxHZxgvQCFZZtdURdvvIY5A/viewform'
email: {
templates: {
Expand Down
15 changes: 11 additions & 4 deletions config/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import _ from 'lodash'
import yaml from 'js-yaml'
import * as v from 'valibot'

const NonEmptyString = v.pipe(v.string(), v.nonEmpty())

export const ConfigSchema = v.object({
port: v.pipe(v.integer(), v.minValue(1)),
asyncRequestApi: v.object({
url: v.url(),
port: v.pipe(v.integer(), v.minValue(1)),
requestsEndpoint: v.pipe(v.string(), v.nonEmpty()),
requestsEndpoint: NonEmptyString,
requestTimeout: v.number()
}),
maintenance: v.object({
serviceUnavailable: v.boolean(),
upTime: v.pipe(v.string(), v.nonEmpty())
upTime: NonEmptyString
}),
aws: v.object({
region: v.string(),
Expand All @@ -23,12 +25,17 @@ export const ConfigSchema = v.object({
redis: v.optional(
v.object({
secure: v.boolean(),
host: v.pipe(v.string(), v.nonEmpty()),
host: NonEmptyString,
port: v.number()
})
),
url: v.url(),
serviceName: v.pipe(v.string(), v.nonEmpty()),
serviceName: NonEmptyString,
serviceNames: v.object({
check: NonEmptyString,
submit: NonEmptyString,
manage: NonEmptyString
}),
feedbackLink: v.url(),
email: v.object({
templates: v.object({
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"hmpo-form-wizard": "^13.0.0",
"hmpo-i18n": "^6.0.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"maplibre-gl": "^4.1.0",
"multer": "^1.4.5-lts.1",
"notifications-node-client": "^8.2.0",
Expand Down
16 changes: 11 additions & 5 deletions src/filters/getFullServiceName.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import config from '../../config/index.js'

const getFullServiceName = (service) => {
/*
* Get the full service name from the short service name.
*
* The names should be specified in the config under 'serviceNames'.
*
* @param {string} service
* @returns {string}
*/
export default (service) => {
if (!service || typeof service !== 'string') {
throw new Error('Service name must be a non-empty string')
throw new TypeError('Service name must be a non-empty string')
}
return config.serviceName.replace('Provide', service)
return config.serviceNames[service.toLowerCase()] || service
}

export default getFullServiceName
2 changes: 1 addition & 1 deletion src/routes/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ router.get('/', async (req, res) => {
}

const toReturn = {
name: config.serviceName,
name: config.serviceNames.submit,
environment: config.environment,
version: process.env.GIT_COMMIT || 'unknown',
maintenance: config.maintenance.serviceUnavailable,
Expand Down
11 changes: 11 additions & 0 deletions src/routes/manage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import express from 'express'
import nunjucks from 'nunjucks'

const router = express.Router()

router.get('/', (req, res) => {
const manage = nunjucks.render('start.html', {})
res.send(manage)
})

export default router
2 changes: 1 addition & 1 deletion src/serverSetup/nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function setupNunjucks ({ app, datasetNameMapping }) {
})

const globalValues = {
serviceName: config.serviceName,
serviceName: config.serviceNames.submit,
feedbackLink: config.feedbackLink
}

Expand Down
3 changes: 3 additions & 0 deletions src/serverSetup/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import accessibility from '../routes/accessibility.js'
import polling from '../routes/api.js'
import health from '../routes/health.js'
import organisations from '../routes/organisations.js'
import manage from '../routes/manage.js'
import privacy from '../routes/privacy.js'
import cookies from '../routes/cookies.js'

Expand All @@ -14,6 +15,8 @@ export function setupRoutes (app) {

app.use('/api', polling)

app.use('/manage', manage)

app.use('/accessibility', accessibility)
app.use('/privacy-notice', privacy)
app.use('/cookies', cookies)
Expand Down
2 changes: 1 addition & 1 deletion src/views/check/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

- Article 4 direction data
- conservation area data
- listed building outline data
- listed building data
- tree preservation order data

## Before you start
Expand Down
6 changes: 5 additions & 1 deletion src/views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
{% endif %}

{% block pageTitle %}
{{ pageName }} - {{ serviceName }}
{% if pageName == "" %}
{{ serviceName }}
{% else %}
{{ pageName }} - {{ serviceName }}
{% endif %}
{% endblock %}

{% block head %}
Expand Down
1 change: 1 addition & 0 deletions src/views/organisations/find.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "layouts/main.html" %}

{% set serviceType = 'Submit' %}
{% set pageName = "Find your organisation" %}

{% block beforeContent %}
Expand Down
77 changes: 77 additions & 0 deletions src/views/start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{% extends "layouts/main.html" %}
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "x-govuk/components/related-navigation/macro.njk" import xGovukRelatedNavigation %}

{% set serviceType = 'Manage' %}
{% set pageName = '' %}

{% block content %}

{% set content %}

Use this service to submit or update:

- Article 4 direction data
- conservation area data
- listed building data
- tree preservation order data

## Before you start

Your data must follow the [data specification](https://www.planning.data.gov.uk/guidance/specifications/).

You need to choose to provide your data in one of these file formats:

- CSV
- GeoJSON
- GML
- GeoPackage

Alternatively you can provide us with a URL.


{{ govukButton({
text: "Start now",
href: "/organisations",
isStartButton: true
}) }}

{% endset %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">
{{ serviceName }}
</h1>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{content | govukMarkdown(headingsStartWith="l") | safe}}
</div>
<div class="govuk-grid-column-one-third">
{{ xGovukRelatedNavigation({
sections: [{
items: [
{
text: "Prepare data to the specifications",
href: "https://www.planning.data.gov.uk/guidance/specifications/"
},
{
text: "Publish data on your website",
href: "https://www.planning.data.gov.uk/guidance/publish-data-on-your-website"
}
],
subsections: [{
title: "Explore the topic",
items: [{
text: "Housing and planning",
href: "/browse/performing-arts"
}]
}]
}]
}) }}
</div>
</div>
{% endblock %}
22 changes: 14 additions & 8 deletions src/views/submit/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@

{% set content %}

Use this service to submit or update:

- Article 4 direction data
- conservation area data
- listed building data
- tree preservation order data

## Before you start

### Publish data on your website
Your data must follow the [data specification](https://www.planning.data.gov.uk/guidance/specifications/).

Your data must be on a URL the public can access. We collect the latest data from there every day.
You need to choose to provide your data in one of these file formats:

You must link to that URL from a webpage about the data. This needs to be on your official planning authority website,
usually ending in gov.uk.
- CSV
- GeoJSON
- GML
- GeoPackage

The webpage must include, for each dataset:
Alternatively you can provide us with a URL.

- the link to the data URL
- a summary of what the data is about
- a statement that the data is provided under the Open Government Licence

<form novalidate method="post">
{{ govukButton({
Expand Down
8 changes: 4 additions & 4 deletions test/integration/health.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('GET health', () => {
expect(res.body.dependencies[2]).toHaveProperty('name', 'redis')
expect(res.body.dependencies[2]).toHaveProperty('status')

expect(res.body.name).toEqual(config.serviceName)
expect(res.body.name).toEqual(config.serviceNames.submit)
expect(res.body.environment).toEqual(config.environment)
expect(res.body.version).toEqual('test_commit_short')
expect(res.body.maintenance).toEqual(config.maintenance.serviceUnavailable)
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('GET health', () => {
expect(res.body.dependencies[1]).toHaveProperty('status')
expect(res.body.dependencies[2]).toHaveProperty('name', 'redis')
expect(res.body.dependencies[2]).toHaveProperty('status')
expect(res.body.name).toEqual(config.serviceName)
expect(res.body.name).toEqual(config.serviceNames.submit)
expect(res.body.environment).toEqual(config.environment)
expect(res.body.version).toEqual('test_commit_short')
expect(res.body.maintenance).toEqual(config.maintenance.serviceUnavailable)
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('GET health', () => {
expect(res.body.dependencies[1]).toHaveProperty('status', 'unhealthy')
expect(res.body.dependencies[2]).toHaveProperty('name', 'redis')
expect(res.body.dependencies[2]).toHaveProperty('status', 'ok')
expect(res.body.name).toEqual(config.serviceName)
expect(res.body.name).toEqual(config.serviceNames.submit)
expect(res.body.environment).toEqual(config.environment)
expect(res.body.version).toEqual('test_commit_short')
expect(res.body.maintenance).toEqual(config.maintenance.serviceUnavailable)
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('GET health', () => {
expect(res.body.dependencies[1]).toHaveProperty('status', 'ok')
expect(res.body.dependencies[2]).toHaveProperty('name', 'redis')
expect(res.body.dependencies[2]).toHaveProperty('status', 'unhealthy')
expect(res.body.name).toEqual(config.serviceName)
expect(res.body.name).toEqual(config.serviceNames.submit)
expect(res.body.environment).toEqual(config.environment)
expect(res.body.version).toEqual('test_commit_short')
expect(res.body.maintenance).toEqual(config.maintenance.serviceUnavailable)
Expand Down
4 changes: 1 addition & 3 deletions test/unit/check-answers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { describe, expect, it } from 'vitest'
import { setupNunjucks } from '../../src/serverSetup/nunjucks.js'
import { runGenericPageTests } from './generic-page.js'
import config from '../../config/index.js'
import { stripWhitespace } from '../utils/stripWhiteSpace.js'

describe('check-answers View', async () => {
Expand All @@ -22,8 +21,7 @@ describe('check-answers View', async () => {
const html = stripWhitespace(nunjucks.render('check-answers.html', params))

runGenericPageTests(html, {
pageTitle: 'Check your answers - Check planning and housing data for England',
serviceName: config.serviceName
pageTitle: 'Check your answers - Check planning and housing data for England'
})

it('should render the lpa selected', () => {
Expand Down
4 changes: 1 addition & 3 deletions test/unit/check/confirmationPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { describe, expect, it } from 'vitest'
import { setupNunjucks } from '../../../src/serverSetup/nunjucks.js'
import { runGenericPageTests } from '../generic-page.js'
import config from '../../../config/index.js'
import { stripWhitespace } from '../../utils/stripWhiteSpace.js'

const nunjucks = setupNunjucks({ datasetNameMapping: new Map() })
Expand All @@ -17,8 +16,7 @@ describe('Check confirmation View', () => {
const html = stripWhitespace(nunjucks.render('submit/confirmation.html', params))

runGenericPageTests(html, {
pageTitle: 'mockDataset submitted - Submit planning and housing data for England',
serviceName: config.serviceName
pageTitle: 'mockDataset submitted - Submit and update your planning data'
})

it('should render the gov uk panel', () => {
Expand Down
4 changes: 1 addition & 3 deletions test/unit/choose-datasetPage.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, it } from 'vitest'
import { setupNunjucks } from '../../src/serverSetup/nunjucks.js'
import { runGenericPageTests } from './generic-page.js'
import config from '../../config/index.js'
import { testValidationErrorMessage } from './validation-tests.js'

const nunjucks = setupNunjucks({ datasetNameMapping: new Map() })
Expand All @@ -13,8 +12,7 @@ describe('choose dataset View', () => {
const html = nunjucks.render('choose-dataset.html', params)

runGenericPageTests(html, {
pageTitle: 'Choose dataset - Submit planning and housing data for England',
serviceName: config.serviceName
pageTitle: 'Choose dataset - Submit and update your planning data'
})

it('should display an error message when the dataset field is empty', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/dataset-details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('dataset details View', () => {
const html = stripWhitespace(nunjucks.render('dataset-details.html', params))
const datasetName = mockDataSubjects.mockDataset.dataSets[0].value
runGenericPageTests(html, {
pageTitle: `Enter ${datasetName.toLowerCase()} details - Submit planning and housing data for England`,
serviceName: config.serviceName
pageTitle: `Enter ${datasetName.toLowerCase()} details - Submit and update your planning data`,
serviceName: config.serviceNames.submit
})

it('should render the correct header', () => {
Expand Down
Loading