From aca7cebfecb89f38708afef3450c7720c8bf63e9 Mon Sep 17 00:00:00 2001
From: Jamie Maynard <29251905+j-maynard@users.noreply.github.com>
Date: Fri, 17 May 2024 14:22:27 +0100
Subject: [PATCH] 192 Implement Publishing Intro Page
This PR implements the Publishing journey start page. It relocates the
upload page to form part of this user journey. Additionally changes
were made to move the 'Beta banner' to the top partial.
---
src/app.ts | 18 +++++++++++-------
src/resources/locales/en-GB.json | 21 ++++++++++++++++++++-
src/views/data.ejs | 10 ----------
src/views/index.ejs | 30 ++++++++++--------------------
src/views/list.ejs | 10 ----------
src/views/partials/top.ejs | 21 +++++++++++++++++----
src/views/publish/start.ejs | 20 ++++++++++++++++++++
src/views/{ => publish}/upload.ejs | 17 ++++-------------
test/app.test.ts | 14 ++++++++++----
9 files changed, 92 insertions(+), 69 deletions(-)
create mode 100644 src/views/publish/start.ejs
rename src/views/{ => publish}/upload.ejs (88%)
diff --git a/src/app.ts b/src/app.ts
index ae0762a..1bbce13 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -63,16 +63,20 @@ app.get('/:lang/', (req: Request, res: Response) => {
res.render('index');
});
-app.get('/:lang/upload', (req: Request, res: Response) => {
- res.render('upload');
+app.get('/:lang/publish', (req: Request, res: Response) => {
+ res.render('publish/start');
});
-app.post('/:lang/upload', upload.single('csv'), async (req: Request, res: Response) => {
+app.get('/:lang/publish/upload', (req: Request, res: Response) => {
+ res.render('publish/upload');
+});
+
+app.post('/:lang/publish/upload', upload.single('csv'), async (req: Request, res: Response) => {
const lang = req.params.lang;
logger.debug(`Filename is ${req.body?.filename}`);
if (!req.file) {
res.status(400);
- res.render('upload', {
+ res.render('publish/upload', {
success: false,
headers: undefined,
data: undefined,
@@ -87,7 +91,7 @@ app.post('/:lang/upload', upload.single('csv'), async (req: Request, res: Respon
}
if (!req.body?.filename) {
res.status(400);
- res.render('upload', {
+ res.render('publish/upload', {
success: false,
headers: undefined,
data: undefined,
@@ -102,7 +106,7 @@ app.post('/:lang/upload', upload.single('csv'), async (req: Request, res: Respon
}
if (!req.body?.description) {
res.status(400);
- res.render('upload', {
+ res.render('publish/upload', {
success: false,
headers: undefined,
data: undefined,
@@ -125,7 +129,7 @@ app.post('/:lang/upload', upload.single('csv'), async (req: Request, res: Respon
res.redirect(`/${req.i18n.language}/data/?file=${processedCSV.datafile_id}`);
} else {
res.status(400);
- res.render('upload', processedCSV);
+ res.render('publish/upload', processedCSV);
}
});
diff --git a/src/resources/locales/en-GB.json b/src/resources/locales/en-GB.json
index ca590aa..2c1746d 100644
--- a/src/resources/locales/en-GB.json
+++ b/src/resources/locales/en-GB.json
@@ -2,6 +2,7 @@
"greeting": "Hello",
"beta": "Beta",
"menu": "Menu",
+ "publish-dataset": "Publish a Dataset",
"upload-csv": "Upload CSV",
"list-data-files": "List Data Files",
"feedback": "This is a new service – your feedback will help us to improve it.",
@@ -11,6 +12,11 @@
"app-running": "App is running",
"health-notes": "Expand endpoint to check for database connection and other services.",
"datalake-error": "Unable to connect to get Datalake",
+ "buttons": {
+ "continue": "Continue",
+ "back": "Back",
+ "cancel": "Cancel"
+ },
"pagination": {
"previous": "Previous",
"next": "Next",
@@ -21,6 +27,15 @@
"welcome": "We're going to use the GovUK Design system until we're able to get hold of the Welsh Government GEL",
"apitext": "You can find our api at "
},
+ "publish": {
+ "start": {
+ "title": "Create a new dataset",
+ "p1": "To create a new dataset, you'll need:",
+ "data-table": "a data table containing data and references to all relevant dimensions",
+ "lookup-table": "lookup tables for all relevant dimensions - using either common tables within this service or uploading them yourself",
+ "metadata": "details about the dataset including description, quality and how the data was collected"
+ }
+ },
"upload": {
"title": "Upload a CSV file",
"description": "Upload a CSV file to the data lake",
@@ -64,6 +79,10 @@
"healthcheck": "healthcheck",
"upload": "upload",
"list": "list",
- "data": "data"
+ "data": "data",
+ "publish": {
+ "start": "publish",
+ "upload": "upload"
+ }
}
}
diff --git a/src/views/data.ejs b/src/views/data.ejs
index 4f603a3..5bbd157 100644
--- a/src/views/data.ejs
+++ b/src/views/data.ejs
@@ -1,16 +1,6 @@
<%- include("partials/top"); %>
-
-
-
- <%= t('beta') %>
-
-
- <%= t('feedback') %>
-
-
-
<%- t('display.title') %> <%= locals.datafile_name || `<${t('errors.name_missing')}>` %>
diff --git a/src/views/index.ejs b/src/views/index.ejs
index a3e49ad..dd405a6 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -1,24 +1,14 @@
<%- include("partials/top"); %>
-
-
-
-
- <%= t('beta') %>
-
-
- <%= t('feedback') %>
-
-
-
-
-
- <%= t('homepage.title') %>
+
+
+
+ <%= t('homepage.title') %>
+
+ <%= t('homepage.welcome') %>
- <%= t('homepage.welcome') %>
-
- <%= t('homepage.apitext') %> /api
-
-
-
+ <%= t('homepage.apitext') %> /api
+
+
+
<%- include("partials/bottom"); %>
\ No newline at end of file
diff --git a/src/views/list.ejs b/src/views/list.ejs
index d5e19f4..7b646bc 100644
--- a/src/views/list.ejs
+++ b/src/views/list.ejs
@@ -1,16 +1,6 @@
<%- include("partials/top"); %>
-
-
-
- <%= t('beta') %>
-
-
- <%= t('feedback') %>
-
-
-
<%= t('list.title') %>
diff --git a/src/views/partials/top.ejs b/src/views/partials/top.ejs
index e1107f6..314ea38 100644
--- a/src/views/partials/top.ejs
+++ b/src/views/partials/top.ejs
@@ -3,7 +3,7 @@
- StatsWales <%= t('alpha') %>
+ StatsWales <%= t('beta') %>
@@ -62,8 +62,8 @@
-
\ No newline at end of file
+
+
+
+
+
+
+ <%= t('beta') %>
+
+
+ <%= t('feedback') %>
+
+
+
+
\ No newline at end of file
diff --git a/src/views/publish/start.ejs b/src/views/publish/start.ejs
new file mode 100644
index 0000000..c70b61b
--- /dev/null
+++ b/src/views/publish/start.ejs
@@ -0,0 +1,20 @@
+<%- include("../partials/top"); %>
+
+
+
+
+ <%= t('publish.start.title') %>
+ <%= t('publish.start.p1') %>
+
+ <%= t('publish.start.data-table') %>
+ <%= t('publish.start.lookup-table') %>
+ <%= t('publish.start.metadata') %>
+
+
+
+
+
+<%- include("../partials/bottom"); %>
\ No newline at end of file
diff --git a/src/views/upload.ejs b/src/views/publish/upload.ejs
similarity index 88%
rename from src/views/upload.ejs
rename to src/views/publish/upload.ejs
index c9f187f..06fb75e 100644
--- a/src/views/upload.ejs
+++ b/src/views/publish/upload.ejs
@@ -1,16 +1,6 @@
-<%- include("partials/top"); %>
-
-
-
-
- <%= t('beta') %>
-
-
- <%= t('feedback') %>
-
-
-
+<%- include("../partials/top"); %>
+
<%= t('upload.title') %>
@@ -79,4 +69,5 @@
-<%- include("partials/bottom"); %>
+
+<%- include("../partials/bottom"); %>
diff --git a/test/app.test.ts b/test/app.test.ts
index 2f710b2..924f752 100644
--- a/test/app.test.ts
+++ b/test/app.test.ts
@@ -78,8 +78,14 @@ describe('Test app.ts', () => {
expect(res.text).toContain('Croeso i Alffa StatsCymru');
});
- test('Upload page returns OK', async () => {
- const res = await request(app).get('/en-GB/upload');
+ test('Publish start page returns OK', async () => {
+ const res = await request(app).get('/en-GB/publish');
+ expect(res.status).toBe(200);
+ expect(res.text).toContain('Create a new dataset');
+ });
+
+ test('Publish upload page returns OK', async () => {
+ const res = await request(app).get('/en-GB/publish/upload');
expect(res.status).toBe(200);
expect(res.text).toContain('Upload a CSV');
});
@@ -88,7 +94,7 @@ describe('Test app.ts', () => {
const csvfile = path.resolve(__dirname, `./test-data-1.csv`);
const res = await request(app)
- .post('/en-GB/upload')
+ .post('/en-GB/publish/upload')
.attach('csv', csvfile)
.field('filename', 'test-data-3.csv')
.field('description', 'Test Data File 3');
@@ -97,7 +103,7 @@ describe('Test app.ts', () => {
});
test('Upload returns 400 and an error if no file attached', async () => {
- const res = await request(app).post('/en-GB/upload');
+ const res = await request(app).post('/en-GB/publish/upload');
expect(res.status).toBe(400);
expect(res.text).toContain('No CSV data available');
});