diff --git a/cypress/e2e/plugins/0-mock-plugin-tests/install-plugin-via-ui-test.cypress.js b/cypress/e2e/plugins/0-mock-plugin-tests/install-plugin-via-ui-test.cypress.js index 8c3e66f539..630978c6ba 100644 --- a/cypress/e2e/plugins/0-mock-plugin-tests/install-plugin-via-ui-test.cypress.js +++ b/cypress/e2e/plugins/0-mock-plugin-tests/install-plugin-via-ui-test.cypress.js @@ -3,7 +3,11 @@ const path = require('path') const { loadTemplatesPage, managePluginsPagePath, - performPluginAction + performPluginAction, + initiatePluginAction, + provePluginInstalled, + provePluginTemplatesInstalled, + provePluginTemplatesUninstalled } = require('../plugin-utils') const panelCompleteQuery = '[aria-live="polite"] #panel-complete' @@ -20,7 +24,7 @@ describe('Install and uninstall Local Plugin via UI Test', async () => { it(`The ${dependentPlugin} plugin will be installed`, () => { log(`The ${dependentPlugin} plugin templates are not available`) loadTemplatesPage() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') + provePluginTemplatesUninstalled(dependentPlugin) // ------------------------ @@ -33,41 +37,32 @@ describe('Install and uninstall Local Plugin via UI Test', async () => { .should('be.visible') cy.get('a').contains('Back to plugins').click() - cy.get('#installed-plugins-link').click() - - cy.get(`[data-plugin-package-name="${dependentPlugin}"] button`).contains('Uninstall') + provePluginInstalled(dependentPlugin, dependentPluginName) // ------------------------ log(`The ${dependentPlugin} plugin templates are available`) cy.get('a').contains('Templates').click() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist') + provePluginTemplatesInstalled(dependentPlugin) // ------------------------ log('Uninstall the local plugin') cy.get('a').contains('Plugins').click() - cy.get('#installed-plugins-link').click() - - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`) - .scrollIntoView() - .find('button') - .contains('Uninstall') - .click() - performPluginAction('uninstall', dependentPlugin, dependentPluginName) + initiatePluginAction('uninstall', dependentPlugin, dependentPluginName) // ------------------------ log(`The ${dependentPlugin} plugin templates are not available`) cy.get('a').contains('Templates').click() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') + provePluginTemplatesUninstalled(dependentPlugin) }) it(`The ${dependentPlugin} plugin and ${dependencyPlugin} will be installed`, () => { log(`The ${dependentPlugin} plugin templates are not available`) loadTemplatesPage() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') + provePluginTemplatesUninstalled(dependentPlugin) // ------------------------ @@ -91,7 +86,7 @@ describe('Install and uninstall Local Plugin via UI Test', async () => { log(`The ${dependentPlugin} plugin templates are available`) cy.get('a').contains('Templates').click() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist') + provePluginTemplatesInstalled(dependentPlugin) // ------------------------ @@ -107,6 +102,6 @@ describe('Install and uninstall Local Plugin via UI Test', async () => { log(`The ${dependentPlugin} plugin templates are not available`) cy.get('a').contains('Templates').click() - cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') + provePluginTemplatesUninstalled(dependentPlugin) }) }) diff --git a/cypress/e2e/plugins/1-available-plugins-tests/available-plugins.cypress.js b/cypress/e2e/plugins/1-available-plugins-tests/available-plugins.cypress.js index 51c1bf632a..4366078df7 100644 --- a/cypress/e2e/plugins/1-available-plugins-tests/available-plugins.cypress.js +++ b/cypress/e2e/plugins/1-available-plugins-tests/available-plugins.cypress.js @@ -5,7 +5,12 @@ const { loadTemplatesPage, loadPluginsPage, manageTemplatesPagePath, - manageInstalledPluginsPagePath + provePluginInstalled, + provePluginUninstalled, + performPluginAction, + initiatePluginAction, + provePluginTemplatesUninstalled, + provePluginTemplatesInstalled } = require('../plugin-utils') const panelCompleteQuery = '[aria-live="polite"] #panel-complete' @@ -18,7 +23,7 @@ async function installPluginTests ({ plugin, templates, version }) { log(`The ${plugin} plugin templates are not available`) uninstallPlugin(plugin) loadTemplatesPage() - cy.get(`[data-plugin-package-name="${plugin}"]`).should('not.exist') + provePluginTemplatesUninstalled(plugin) // ------------------------ @@ -30,22 +35,23 @@ async function installPluginTests ({ plugin, templates, version }) { cy.get('#plugin-action-button').click() } else { loadPluginsPage() + provePluginUninstalled(plugin) log(`Install the ${plugin} plugin`) - cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Install').click() + performPluginAction('install', plugin) } cy.get(panelCompleteQuery, { timeout: 20000 }) .should('be.visible') cy.get('a').contains('Back to plugins').click() - cy.get('#installed-plugins-link').click() - cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Uninstall') + provePluginInstalled(plugin) // ------------------------ log(`The ${plugin} plugin templates are available`) cy.get('a').contains('Templates').click() - cy.get(`[data-plugin-package-name="${plugin}"]`).should('exist') + + provePluginTemplatesInstalled(plugin) // ------------------------ @@ -59,15 +65,11 @@ async function installPluginTests ({ plugin, templates, version }) { // ------------------------ log(`Uninstall the ${plugin} plugin`) - cy.visit(manageInstalledPluginsPagePath) - - cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Uninstall').click() + cy.visit(managePluginsPagePath) - cy.get(panelCompleteQuery, { timeout: 20000 }) - .should('be.visible') - cy.get('a').contains('Back to plugins').click() + initiatePluginAction('uninstall', plugin) - cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Install') + provePluginUninstalled(plugin) }) }) } diff --git a/cypress/e2e/plugins/1-available-plugins-tests/install-available-plugin.cypress.js b/cypress/e2e/plugins/1-available-plugins-tests/install-available-plugin.cypress.js index 526e518610..9017adb8b2 100644 --- a/cypress/e2e/plugins/1-available-plugins-tests/install-available-plugin.cypress.js +++ b/cypress/e2e/plugins/1-available-plugins-tests/install-available-plugin.cypress.js @@ -10,7 +10,9 @@ const { getTemplateLink, loadInstalledPluginsPage, loadPluginsPage, - manageInstalledPluginsPagePath + manageInstalledPluginsPagePath, + initiatePluginAction, + provePluginUpdated } = require('../plugin-utils') const { showHideAllLinkQuery, assertVisible, assertHidden } = require('../../step-by-step-utils') @@ -93,14 +95,8 @@ describe('Management plugins: ', () => { loadInstalledPluginsPage() log(`Update the ${plugin} plugin`) - - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Update') - .click() - - performPluginAction('update', plugin, pluginName) + initiatePluginAction('update', plugin, pluginName) + provePluginUpdated(plugin) }) it(`Create a page using a template from the ${plugin} plugin`, () => { @@ -134,14 +130,7 @@ describe('Management plugins: ', () => { log(`Uninstall the ${plugin} plugin`) cy.visit(manageInstalledPluginsPagePath) - - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Uninstall') - .click() - - performPluginAction('uninstall', plugin, pluginName) + initiatePluginAction('uninstall', plugin, pluginName) provePluginFunctionalityFails() @@ -150,14 +139,7 @@ describe('Management plugins: ', () => { log(`Reinstall the ${plugin} plugin`) cy.visit(managePluginsPagePath) - - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Install') - .click() - - performPluginAction('install', plugin, pluginName) + initiatePluginAction('install', plugin, pluginName) provePluginFunctionalityWorks() }) diff --git a/cypress/e2e/plugins/1-available-plugins-tests/install-common-templates-plugin-from-templates-page.cypress.js b/cypress/e2e/plugins/1-available-plugins-tests/install-common-templates-plugin-from-templates-page.cypress.js index cb67506b12..50de2257a7 100644 --- a/cypress/e2e/plugins/1-available-plugins-tests/install-common-templates-plugin-from-templates-page.cypress.js +++ b/cypress/e2e/plugins/1-available-plugins-tests/install-common-templates-plugin-from-templates-page.cypress.js @@ -1,4 +1,5 @@ const { waitForApplication, uninstallPlugin, restoreStarterFiles } = require('../../utils') +const { provePluginTemplatesInstalled } = require('../plugin-utils') const manageTemplatesPagePath = '/manage-prototype/templates' const panelCompleteQuery = '[aria-live="polite"] #panel-complete' @@ -25,7 +26,7 @@ describe('Install common templates from templates page', () => { cy.get('a').contains('Back to templates').click() - cy.get(`[data-plugin-package-name="${plugin}"]`).contains('Common Templates') + provePluginTemplatesInstalled(plugin) cy.get('a.govuk-button').should('not.exist') }) diff --git a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-installation-mismatch.cypress.js b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-installation-mismatch.cypress.js index cf7bb995a6..06e831ef66 100644 --- a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-installation-mismatch.cypress.js +++ b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-installation-mismatch.cypress.js @@ -1,5 +1,14 @@ -const { replaceInFile, waitForApplication, restoreStarterFiles, log } = require('../../utils') +const { + replaceInFile, + waitForApplication, + restoreStarterFiles, + log +} = require('../../utils') const path = require('path') +const { + provePluginUninstalled, + provePluginInstalledOldVersion +} = require('../plugin-utils') const plugin = '@govuk-prototype-kit/task-list' const pluginVersion = '1.1.1' const originalText = '"dependencies": {' @@ -18,11 +27,7 @@ describe('Handle a plugin installation mismatch', () => { log(`Make sure ${plugin} is displayed as not installed`) cy.visit(pluginsPage) - - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Install') + provePluginUninstalled(plugin) log('Force the plugins to be installed with an npm install') cy.exec(`cd ${Cypress.env('projectFolder')} && npm install`) @@ -31,10 +36,6 @@ describe('Handle a plugin installation mismatch', () => { waitForApplication() cy.visit(pluginsPage) - cy.get('#installed-plugins-link').click() - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Uninstall') + provePluginInstalledOldVersion(plugin) }) }) diff --git a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-update-when-a-dependency-is-now-required.cypress.js b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-update-when-a-dependency-is-now-required.cypress.js index dc62095b6a..2425f3561d 100644 --- a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-update-when-a-dependency-is-now-required.cypress.js +++ b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/handle-plugin-update-when-a-dependency-is-now-required.cypress.js @@ -1,6 +1,18 @@ -import { installPlugin, restoreStarterFiles, uninstallPlugin, waitForApplication } from '../../utils' import path from 'path' +import { + installPlugin, + restoreStarterFiles, + uninstallPlugin, + waitForApplication +} from '../../utils' + +import { + initiatePluginAction, + provePluginInstalled, + provePluginUninstalled +} from '../plugin-utils' + const plugin = '@govuk-prototype-kit/common-templates' const pluginVersion = '1.1.1' const pluginsPage = '/manage-prototype/plugins' @@ -30,39 +42,19 @@ describe('Handle a plugin update', () => { waitForApplication(pluginsPage) - cy.get('[data-plugin-group-status="search"]') - .find(`[data-plugin-package-name="${dependencyPlugin}"]`) - .find('button') - .contains('Install') - - cy.get('#installed-plugins-link').click() - - cy.get('[data-plugin-group-status="installed"]') - .find(`[data-plugin-package-name="${plugin}"]`) - .find('button') - .contains('Update') - .click() - - cy.get('#plugin-action-confirmation') - .find('ul') - .contains(dependencyPluginName) - - cy.get('#plugin-action-button').click() - - cy.get('#panel-complete', { timeout: 20000 }) - .should('be.visible') - .contains('Update complete') - - cy.get('#instructions-complete a') - .contains('Back to plugins') - .click() + provePluginUninstalled(dependencyPlugin) - cy.get('#installed-plugins-link').click() + initiatePluginAction('update', plugin, null, { + confirmation: () => { + cy.get('#plugin-action-confirmation') + .find('ul') + .contains(dependencyPluginName) - cy.get('[data-plugin-group-status="installed"]') - .find(`[data-plugin-package-name="${dependencyPlugin}"]`) + cy.get('#plugin-action-button').click() + } + }) - cy.get('[data-plugin-group-status="installed"]') - .find(`[data-plugin-package-name="${plugin}"]`) + provePluginInstalled(plugin) + provePluginInstalled(dependencyPlugin, dependencyPluginName) }) }) diff --git a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/remove-govuk-frontend.cypress.js b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/remove-govuk-frontend.cypress.js index fc4645f6b5..872fe1987c 100644 --- a/cypress/e2e/plugins/2-prototype-kit-plugin-tests/remove-govuk-frontend.cypress.js +++ b/cypress/e2e/plugins/2-prototype-kit-plugin-tests/remove-govuk-frontend.cypress.js @@ -1,4 +1,10 @@ -const { managePluginsPagePath, performPluginAction } = require('../plugin-utils') +const { + managePluginsPagePath, + performPluginAction, + provePluginInstalled, + provePluginUninstalled, + initiatePluginAction +} = require('../plugin-utils') const { uninstallPlugin, restoreStarterFiles } = require('../../utils') const plugin = 'govuk-frontend' @@ -21,9 +27,8 @@ describe('Manage prototype pages without govuk-frontend', () => { performPluginAction('uninstall', plugin, pluginName) cy.task('log', 'Make sure govuk-frontend is uninstalled') - cy.get(`[data-plugin-package-name="${plugin}"]`) - .find('button') - .contains('Install') + + provePluginUninstalled(plugin) cy.task('log', 'Test home page') cy.get('a').contains('Home').click() @@ -39,19 +44,10 @@ describe('Manage prototype pages without govuk-frontend', () => { cy.task('log', `Install the ${plugin} plugin`) - cy.get(`[data-plugin-package-name="${plugin}"]`) - .scrollIntoView() - .find('button') - .contains('Install') - .click() - - performPluginAction('install', plugin, pluginName) - - cy.get('#installed-plugins-link').click() + initiatePluginAction('install', plugin, pluginName) cy.task('log', 'Make sure govuk-frontend is installed') - cy.get(`[data-plugin-package-name="${plugin}"]`) - .find('button') - .contains('Uninstall') + + provePluginInstalled(plugin, pluginName) }) }) diff --git a/cypress/e2e/plugins/plugin-utils.js b/cypress/e2e/plugins/plugin-utils.js index 56541707bd..45c90b2604 100644 --- a/cypress/e2e/plugins/plugin-utils.js +++ b/cypress/e2e/plugins/plugin-utils.js @@ -31,18 +31,120 @@ async function loadTemplatesPage () { await waitForApplication(manageTemplatesPagePath) } +function provePluginTemplatesInstalled (plugin) { + cy.visit(manageTemplatesPagePath) + cy.get(`[data-plugin-package-name="${plugin}"]`).should('exist') +} + +function provePluginTemplatesUninstalled (plugin) { + cy.visit(manageTemplatesPagePath) + cy.get(`[data-plugin-package-name="${plugin}"]`).should('not.exist') +} + +function initiatePluginAction (action, plugin, pluginName, options = {}) { + cy.visit(managePluginsPagePath) + + if (pluginName) { + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .contains(pluginName) + } + + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .click() + + cy.get('button') + .contains(capitalize(action)) + .click() + + if (options.confirmation) { + options.confirmation() + } + + performPluginAction(action, plugin, pluginName) +} + +function provePluginInstalled (plugin, pluginName) { + cy.visit(managePluginsPagePath) + if (pluginName) { + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .contains(pluginName) + } + + cy.get(`[data-plugin-package-name="${plugin}"] strong.govuk-tag`) + .contains('Installed') + + cy.get('#installed-plugins-link').click() + + cy.get(`[data-plugin-package-name="${plugin}"]`) + .should('exist') +} + +function provePluginUninstalled (plugin, pluginName) { + cy.visit(managePluginsPagePath) + if (pluginName) { + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .contains(pluginName) + } + + cy.get(`[data-plugin-package-name="${plugin}"] strong.govuk-tag`) + .should('not.exist') + + cy.get('#installed-plugins-link').click() + + cy.get(`[data-plugin-package-name="${plugin}"]`) + .should('not.exist') +} + +function provePluginUpdated (plugin, pluginName) { + provePluginInstalled(plugin, pluginName) + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .click() + + cy.get('button') + .contains(capitalize('update')).should('not.exist') +} + +function provePluginInstalledOldVersion (plugin, pluginName) { + cy.visit(managePluginsPagePath) + if (pluginName) { + cy.get(`[data-plugin-package-name="${plugin}"]`) + .scrollIntoView() + .find('a') + .contains(pluginName) + } + + cy.get(`[data-plugin-package-name="${plugin}"] strong.govuk-tag`) + .contains('Update available') + + cy.get('#installed-plugins-link').click() + + cy.get(`[data-plugin-package-name="${plugin}"]`) + .should('exist') +} + function performPluginAction (action, plugin, pluginName) { cy.task('log', `The ${plugin} plugin should be displayed`) - cy.get('h2') - .contains(pluginName) + + if (pluginName) { + cy.get('h2') + .contains(pluginName) + } const processingText = `${action === 'update' ? 'Updat' : action}ing ...` if (Cypress.env('skipPluginActionInterimStep') !== 'true') { cy.get(panelCompleteQuery, { timeout: 20000 }) .should('not.be.visible') - cy.get(panelCompleteQuery) - .should('not.be.visible') cy.get(panelErrorQuery) .should('not.be.visible') cy.get(panelProcessingQuery) @@ -75,7 +177,7 @@ function failAction (action) { cy.get('#plugin-action-button').click() if (Cypress.env('skipPluginActionInterimStep') !== 'true') { - cy.get(panelCompleteQuery) + cy.get(panelCompleteQuery, { timeout: 20000 }) .should('not.be.visible') cy.get(panelErrorQuery) .should('not.be.visible') @@ -105,6 +207,13 @@ module.exports = { loadInstalledPluginsPage, loadTemplatesPage, getTemplateLink, + initiatePluginAction, performPluginAction, + provePluginInstalled, + provePluginUninstalled, + provePluginUpdated, + provePluginInstalledOldVersion, + provePluginTemplatesInstalled, + provePluginTemplatesUninstalled, failAction } diff --git a/lib/assets/sass/manage-prototype.scss b/lib/assets/sass/manage-prototype.scss index 977587e8a3..979d48a9fd 100644 --- a/lib/assets/sass/manage-prototype.scss +++ b/lib/assets/sass/manage-prototype.scss @@ -440,6 +440,15 @@ body .govuk-prototype-kit-manage-prototype-govuk-tag { padding-left: 0 !important; } +.govuk-prototype-kit-manage-prototype-plugin-heading { + margin-bottom: 0; +} + +.govuk-prototype-kit-manage-prototype-plugin-sub-heading { + color: #505a5f; + margin-bottom: 15px; +} + .govuk-prototype-kit-manage-prototype-plugin-list-plugin-list { border-top: 1px solid #b1b4b6; margin-bottom: 2em; @@ -574,3 +583,10 @@ body .govuk-prototype-kit-manage-prototype-govuk-tag { } } } + +.govuk-prototype-kit-manage-prototype-plugin-details-links { + padding-top: 20px; + margin-bottom: 20px; + border-top: 2px solid #b1b4b6; + border-bottom: 2px solid #b1b4b6; +} diff --git a/lib/manage-prototype-handlers.js b/lib/manage-prototype-handlers.js index 8c5b50c3be..6665e5d5e4 100644 --- a/lib/manage-prototype-handlers.js +++ b/lib/manage-prototype-handlers.js @@ -411,7 +411,7 @@ function buildPluginData (pluginData) { packageName, latestVersion, installedLocally, - installLink: `${contextPath}/plugins/install?package=${encodeURIComponent(packageName)}`, + installLink: installedVersion ? undefined : `${contextPath}/plugins/install?package=${encodeURIComponent(packageName)}`, installCommand: `npm install ${packageName}`, updateLink: installed && !installedLocally && latestVersion !== installedVersion ? `${contextPath}/plugins/update?package=${encodeURIComponent(packageName)}` : undefined, updateCommand: latestVersion && `npm install ${packageName}@${latestVersion}`, @@ -436,7 +436,7 @@ async function prepareForPluginPage (isInstalledPage, search) { status: isInstalledPage ? 'installed' : 'search', plugins: plugins.map(buildPluginData), found: plugins.length, - updates: installedPlugins.filter(plugin => plugin.installedVersion !== plugin.latestVersion).length + updates: installedPlugins.filter(plugin => !plugin.installedLocally && plugin.installedVersion !== plugin.latestVersion).length } } @@ -726,6 +726,19 @@ async function postPluginsModeHandler (req, res) { res.json({ status }) } +async function getPluginDetailsHandler (req, res) { + const packageName = req.query.package + const plugin = await lookupPackageInfo(packageName) + const { name, scope, installedVersion, latestVersion, ...pluginData } = buildPluginData(plugin) + const viewData = { + ...pluginData, + installedVersion, + latestVersion, + plugin: { name, scope, version: installedVersion || latestVersion } + } + res.render(getManagementView('plugin-details.njk'), viewData) +} + module.exports = { contextPath, setKitRestarted, @@ -749,5 +762,6 @@ module.exports = { getPluginsModeHandler, postPluginsStatusHandler, postPluginsModeMiddleware, - postPluginsModeHandler + postPluginsModeHandler, + getPluginDetailsHandler } diff --git a/lib/manage-prototype-routes.js b/lib/manage-prototype-routes.js index 42c824c03e..e3147d1880 100644 --- a/lib/manage-prototype-routes.js +++ b/lib/manage-prototype-routes.js @@ -24,7 +24,8 @@ const { postPluginsModeHandler, postPluginsStatusHandler, pluginCacheMiddleware, - postPluginsHandler + postPluginsHandler, + getPluginDetailsHandler } = require('./manage-prototype-handlers') const { packageDir, projectDir } = require('./utils/paths') const { govukFrontendPaths } = require('./govukFrontendPaths') @@ -79,6 +80,8 @@ router.post('/plugins/:mode', postPluginsModeMiddleware) router.post('/plugins/:mode', csrfProtection, postPluginsModeHandler) +router.get('/plugin-details', getPluginDetailsHandler) + // Find GOV.UK Frontend (via internal package, project fallback) router.use('/dependencies/govuk-frontend', express.static( govukFrontendPaths([packageDir, projectDir]).baseDir) diff --git a/lib/nunjucks/views/manage-prototype/plugin-details.njk b/lib/nunjucks/views/manage-prototype/plugin-details.njk new file mode 100644 index 0000000000..ce5c4ec475 --- /dev/null +++ b/lib/nunjucks/views/manage-prototype/plugin-details.njk @@ -0,0 +1,90 @@ +{% extends "views/manage-prototype/layout.njk" %} +{% from "govuk/components/button/macro.njk" import govukButton %} + +{% block beforeContent %} + {{ super() }} + Back to plugins +{% endblock %} + +{% block content %} +
+ {% include "views/manage-prototype/plugin-header.njk" %} + +
+
+ {% if newerLink %} +

Latest version: {{ newerVersion }}

+ {% endif %} + {% if installedLinkAsDifferentLink %} +

Installed version: {{ installedLinkAsDifferentVersion }}

+ {% endif %} + +
+
+ {% if installLink %} + {{ govukButton({ + html: 'Install ' + plugin.name + '', + attributes: { id: "install-" + packageName, formaction: installLink } + }) }} + {% endif %} + {% if updateLink %} + {{ govukButton({ + html: 'Update ' + plugin.name + '', + attributes: { id: "update-" + packageName, formaction: updateLink } + }) }} + {% endif %} + {% if uninstallLink %} + {{ govukButton({ + html: 'Uninstall ' + plugin.name + '', + classes: "govuk-button--secondary", + attributes: { id: "uninstall-" + packageName, formaction: uninstallLink } + }) }} + {% endif %} +
+
+ + {% if plugin.releaseDateTime or preparedPluginLinks.releaseNotes or preparedPluginLinks.versionHistory %} + + {% endif %} +

Report

+ {% if debugInfo %} +
+                   {{ debugInfo }}
+                  
+ {% endif %} +
+ +
+

About this plugin

+ +

{{ description | default('No description has been provided.') }}

+ + {% if preparedPluginLinks.documentation %} +

How to use this plugin

+ {% endif %} + + {% if inThisPlugin.length %} +

Included in this plugin

+ {% for section in inThisPlugin %} +

{{ section.title }}

+
    + {% for item in section.items %} +
  • {{ item }}
  • + {% endfor %} +
+ {% endfor %} + {% endif %} +
+
+
+{% endblock %} diff --git a/lib/nunjucks/views/manage-prototype/plugin-header.njk b/lib/nunjucks/views/manage-prototype/plugin-header.njk new file mode 100644 index 0000000000..89466e5701 --- /dev/null +++ b/lib/nunjucks/views/manage-prototype/plugin-header.njk @@ -0,0 +1,9 @@ +
+
+

{{ plugin.name }}

+

v{{ plugin.version }}

+ {% if plugin.scope %} +

By {{ plugin.scope }}

+ {% endif %} +
+
diff --git a/lib/nunjucks/views/manage-prototype/plugins.njk b/lib/nunjucks/views/manage-prototype/plugins.njk index 1cb2129512..f8cc8e1ade 100644 --- a/lib/nunjucks/views/manage-prototype/plugins.njk +++ b/lib/nunjucks/views/manage-prototype/plugins.njk @@ -5,46 +5,47 @@ {% from "govuk/components/tag/macro.njk" import govukTag %} {% block content %} -
-
-
-

Plugins

-

- Plugins provide you with new components, styles and other features -

-
+
+
+

Plugins

+

+ Plugins provide you with new components, styles and other features +

+
-
-
- {% if isSearchPage %} - - - {% else %} - - - {% endif %} - {% if updatesMessage %} - {{ govukTag({ - text: updatesMessage - }) }} - {% endif %} -
+
+
+ {% if isSearchPage %} + + + {% else %} + + + {% endif %} + {% if updatesMessage %} + {{ govukTag({ + text: updatesMessage + }) }} + {% endif %} +
-
- {% if isSearchPage %} +
+ {% if isSearchPage %}
{{ govukLabel({ @@ -78,31 +79,39 @@ {{ foundMessage }}
- {% endif %} + {% endif %} -
    - {% for plugin in plugins %} -
  • +
      + {% for plugin in plugins %} +
    • -
      -

      - {{ plugin.name }} -

      - {% if plugin.scope %} -
      - By {{ plugin.scope }} -
      - {% endif %} - {% if plugin.installedVersion %} -
      - v{{ plugin.installedVersion }} -
      - {% endif %} -
      -
      - {% if isSearchPage and plugin.installedVersion %} +
      + + {{ plugin.name }} + + {% if plugin.scope %} +
      + By {{ plugin.scope }} +
      + {% endif %} + {% if plugin.installedVersion %} +
      + version {{ plugin.installedVersion }} +
      + {% endif %} +
      +
      +
      + {% if plugin.updateLink %} +

      + {{ govukTag({ + text: "Update available" + }) }} +

      + {% elseif isSearchPage and plugin.installedVersion %}

      {{ govukTag({ text: "Installed", @@ -110,46 +119,16 @@ }) }}

      {% endif %} - {% if plugin.description %} -
      - {{ plugin.description }} -
      - {% endif %} -
      -
      - {% if not plugin.installedVersion %} - {{ govukButton({ - html: 'Install ' + plugin.name + '', - attributes: { id: "install-" + plugin.packageName, formaction: plugin.installLink } - }) }} - {% endif %} - {% if isInstalledPage %} - {% if plugin.updateLink %} - {{ govukButton({ - html: 'Update ' + plugin.name + '', - attributes: { id: "update-" + plugin.packageName, formaction: plugin.updateLink } - }) }} - {% endif %} - {% if plugin.uninstallLink %} - {{ govukButton({ - html: 'Uninstall ' + plugin.name + '', - classes: "govuk-button--secondary", - attributes: { id: "uninstall-" + plugin.packageName, formaction: plugin.uninstallLink } - }) }} - {% endif %} - {% endif %} - {% if plugin.helpLink %} - Help - {{ plugin.name }} - {% endif %} -
      -
      -
    • - {% endfor %} -
    -
+ {% if plugin.description %} +
+ {{ plugin.description }} +
+ {% endif %} +
+ + {% endfor %} +
- +
{% endblock %}