From 5b86ccbeeda5a11ed00545b793414aa0f0109fc5 Mon Sep 17 00:00:00 2001 From: Natalie Carey Date: Wed, 5 Apr 2023 15:39:19 +0100 Subject: [PATCH] Fixing page highlights (including Plugins which was broken before). --- lib/manage-prototype-handlers.js | 9 ++++++--- lib/manage-prototype-handlers.test.js | 9 ++++++--- lib/nunjucks/views/manage-prototype/layout.njk | 3 +++ lib/nunjucks/views/manage-prototype/template-install.njk | 2 +- .../views/manage-prototype/template-post-install.njk | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/manage-prototype-handlers.js b/lib/manage-prototype-handlers.js index 3650c4658b..7aeadf9a3b 100644 --- a/lib/manage-prototype-handlers.js +++ b/lib/manage-prototype-handlers.js @@ -277,7 +277,8 @@ function getTemplatesInstallHandler (req, res) { if (templateConfig) { res.render(getManagementView('template-install.njk'), { - currentPage: `Create new ${templateConfig.name}`, + currentPage: 'Templates', + pageName: `Create new ${templateConfig.name}`, currentUrl: req.originalUrl, links: managementLinks, templateName: templateConfig.name, @@ -365,7 +366,8 @@ function getTemplatesPostInstallHandler (req, res) { const chosenUrl = req.query['chosen-url'] res.render(getManagementView('template-post-install.njk'), { - currentPage: pageName, + currentPage: 'Templates', + pageName, links: managementLinks, url: chosenUrl, filePath: path.join('app', 'views', `${chosenUrl}.${getFileExtensionForNunjucksFiles()}`) @@ -542,7 +544,8 @@ async function getPluginsModeHandler (req, res) { const returnLink = req.query.returnTo === 'templates' ? templatesReturnLink : pluginsReturnLink res.render(getManagementView('plugin-install-or-uninstall.njk'), { - currentPage: pageName, + currentPage: 'Plugins', + pageName, currentUrl: req.originalUrl, links: managementLinks, chosenPlugin, diff --git a/lib/manage-prototype-handlers.test.js b/lib/manage-prototype-handlers.test.js index 14222b12de..c81b37b1b1 100644 --- a/lib/manage-prototype-handlers.test.js +++ b/lib/manage-prototype-handlers.test.js @@ -252,7 +252,8 @@ describe('manage-prototype-handlers', () => { expect(res.render).toHaveBeenCalledWith( 'views/manage-prototype/template-install.njk', expect.objectContaining({ - currentPage: 'Create new A page with everything', + currentPage: 'Templates', + pageName: 'Create new A page with everything', chosenUrl, currentUrl: req.originalUrl, error, @@ -344,7 +345,8 @@ describe('manage-prototype-handlers', () => { expect(res.render).toHaveBeenCalledWith( 'views/manage-prototype/template-post-install.njk', expect.objectContaining({ - currentPage: 'Page created', + currentPage: 'Templates', + pageName: 'Page created', filePath: path.join(`app/views${chosenUrl}.html`) }) ) @@ -410,7 +412,8 @@ describe('manage-prototype-handlers', () => { chosenPlugin: availablePlugin, command: `npm install ${packageName}`, csrfToken, - currentPage: `Install ${pluginDisplayName.name}`, + currentPage: 'Plugins', + pageName: `Install ${pluginDisplayName.name}`, currentUrl: req.originalUrl, isSameOrigin: false, returnLink: { diff --git a/lib/nunjucks/views/manage-prototype/layout.njk b/lib/nunjucks/views/manage-prototype/layout.njk index 31548c85fe..103eb8c74c 100644 --- a/lib/nunjucks/views/manage-prototype/layout.njk +++ b/lib/nunjucks/views/manage-prototype/layout.njk @@ -1,6 +1,9 @@ {% extends "govuk-prototype-kit/layouts/govuk-branded.njk" %} {% block pageTitle %} + {% if pageName %} + {{ pageName }} - + {% endif %} {% if currentPage !== "Home" %}{{ currentPage }} - {% endif %}Manage your prototype - {{ serviceName }} diff --git a/lib/nunjucks/views/manage-prototype/template-install.njk b/lib/nunjucks/views/manage-prototype/template-install.njk index d67f88de5d..9546f81f75 100644 --- a/lib/nunjucks/views/manage-prototype/template-install.njk +++ b/lib/nunjucks/views/manage-prototype/template-install.njk @@ -24,7 +24,7 @@ }) }} {% endif %} -

{{ currentPage }}

+

{{ pageName }}

diff --git a/lib/nunjucks/views/manage-prototype/template-post-install.njk b/lib/nunjucks/views/manage-prototype/template-post-install.njk index 8c991feada..a721d3f770 100644 --- a/lib/nunjucks/views/manage-prototype/template-post-install.njk +++ b/lib/nunjucks/views/manage-prototype/template-post-install.njk @@ -4,7 +4,7 @@
-

{{ currentPage }}

+

{{ pageName }}

View your page at {{ url }}