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 35fe6416fc..526e518610 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 @@ -9,7 +9,8 @@ const { managePluginsPagePath, getTemplateLink, loadInstalledPluginsPage, - loadPluginsPage, manageInstalledPluginsPagePath + loadPluginsPage, + manageInstalledPluginsPagePath } = require('../plugin-utils') const { showHideAllLinkQuery, assertVisible, assertHidden } = require('../../step-by-step-utils') 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 c740237b5f..dc62095b6a 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 @@ -30,7 +30,7 @@ describe('Handle a plugin update', () => { waitForApplication(pluginsPage) - cy.get('[data-plugin-group-status="available"]') + cy.get('[data-plugin-group-status="search"]') .find(`[data-plugin-package-name="${dependencyPlugin}"]`) .find('button') .contains('Install') diff --git a/lib/manage-prototype-handlers.js b/lib/manage-prototype-handlers.js index e88338cd49..2b086c7adc 100644 --- a/lib/manage-prototype-handlers.js +++ b/lib/manage-prototype-handlers.js @@ -17,7 +17,7 @@ const syncChanges = require('./sync-changes') const { lookupPackageInfo, getInstalledPackages, - getAvailablePackages, + getAllPackages, getDependentPackages, getDependencyPackages, waitForPackagesCache @@ -419,18 +419,18 @@ function buildPluginData (pluginData) { } async function prepareForPluginPage (isInstalledPage, search) { - const availablePlugins = await getAvailablePackages() + const allPlugins = await getAllPackages() const installedPlugins = await getInstalledPackages() const plugins = isInstalledPage ? installedPlugins - : availablePlugins.filter(plugin => { + : allPlugins.filter(plugin => { const pluginName = plugin.packageName?.toLowerCase() return pluginName.indexOf(search.toLowerCase()) >= 0 }) return { - status: isInstalledPage ? 'installed' : 'available', + status: isInstalledPage ? 'installed' : 'search', plugins: plugins.map(buildPluginData), found: plugins.length, updates: installedPlugins.filter(plugin => plugin.installedVersion !== plugin.latestVersion).length @@ -510,7 +510,7 @@ async function getPluginsHandler (req, res) { currentSection: pageName, links: managementLinks, isInstalledPage, - isAvailablePage: !isInstalledPage, + isSearchPage: !isInstalledPage, search, plugins, updatesMessage, diff --git a/lib/manage-prototype-handlers.test.js b/lib/manage-prototype-handlers.test.js index 4b5e35c5de..06be2ea4ab 100644 --- a/lib/manage-prototype-handlers.test.js +++ b/lib/manage-prototype-handlers.test.js @@ -33,7 +33,8 @@ const { postPluginsStatusHandler, postPluginsModeMiddleware, getPluginsModeHandler, - postPluginsModeHandler, postPluginsHandler + postPluginsModeHandler, + postPluginsHandler } = require('./manage-prototype-handlers') const { projectDir } = require('./utils/paths') @@ -108,7 +109,7 @@ jest.mock('./plugins/packages', () => { } }), getInstalledPackages: jest.fn().mockResolvedValue([]), - getAvailablePackages: jest.fn().mockResolvedValue([availablePackage]), + getAllPackages: jest.fn().mockResolvedValue([availablePackage]), getDependentPackages: jest.fn().mockResolvedValue([]), getDependencyPackages: jest.fn().mockResolvedValue([]) } @@ -442,7 +443,7 @@ describe('manage-prototype-handlers', () => { 'views/manage-prototype/plugins.njk', expect.objectContaining({ currentSection: 'Plugins', - isAvailablePage: false, + isSearchPage: false, isInstalledPage: true, plugins: [], status: 'installed' @@ -457,10 +458,10 @@ describe('manage-prototype-handlers', () => { 'views/manage-prototype/plugins.njk', expect.objectContaining({ currentSection: 'Plugins', - isAvailablePage: true, + isSearchPage: true, isInstalledPage: false, plugins: [availablePlugin], - status: 'available' + status: 'search' }) ) }) diff --git a/lib/nunjucks/views/manage-prototype/plugins.njk b/lib/nunjucks/views/manage-prototype/plugins.njk index 3f4ba44c06..6d3d48e0cb 100644 --- a/lib/nunjucks/views/manage-prototype/plugins.njk +++ b/lib/nunjucks/views/manage-prototype/plugins.njk @@ -17,7 +17,7 @@
- {% if isAvailablePage %} + {% if isSearchPage %} @@ -44,7 +44,7 @@
- {% if isAvailablePage %} + {% if isSearchPage %}
{{ govukLabel({ @@ -95,13 +95,21 @@ By {{ plugin.scope }}
{% endif %} - {% if isInstalledPage %} + {% if plugin.installedVersion %}
v{{ plugin.installedVersion }}
{% endif %}
+ {% if isSearchPage and plugin.installedVersion %} +

+ {{ govukTag({ + text: "Installed", + classes: "govuk-tag--grey" + }) }} +

+ {% endif %} {% if plugin.description %}
{{ plugin.description }} @@ -115,19 +123,21 @@ attributes: { id: "install-" + plugin.packageName, formaction: plugin.installLink } }) }} {% endif %} - {% if plugin.uninstallLink %} - {{ govukButton({ - html: 'Uninstall ' + plugin.name + '', - classes: "govuk-button--secondary", - attributes: { id: "uninstall-" + plugin.packageName, formaction: plugin.uninstallLink } - }) }} - {% endif %} - {% if plugin.updateLink %} - {{ govukButton({ - html: 'Update ' + plugin.name + '', - classes: "govuk-button--secondary", - attributes: { id: "update-" + plugin.packageName, formaction: plugin.updateLink } - }) }} + {% if isInstalledPage %} + {% if plugin.uninstallLink %} + {{ govukButton({ + html: 'Uninstall ' + plugin.name + '', + classes: "govuk-button--secondary", + attributes: { id: "uninstall-" + plugin.packageName, formaction: plugin.uninstallLink } + }) }} + {% endif %} + {% if plugin.updateLink %} + {{ govukButton({ + html: 'Update ' + plugin.name + '', + classes: "govuk-button--secondary", + attributes: { id: "update-" + plugin.packageName, formaction: plugin.updateLink } + }) }} + {% endif %} {% endif %} {% if plugin.helpLink %} available && !installed) .sort(packageNameSort) .reduce(emphasizeBasePlugins, []) } @@ -274,7 +273,7 @@ module.exports = { waitForPackagesCache, lookupPackageInfo, getInstalledPackages, - getAvailablePackages, + getAllPackages, getDependentPackages, getDependencyPackages } diff --git a/lib/plugins/packages.spec.js b/lib/plugins/packages.spec.js index 72f8508670..3fbfbdb218 100644 --- a/lib/plugins/packages.spec.js +++ b/lib/plugins/packages.spec.js @@ -16,7 +16,7 @@ const requestHttps = require('../utils/requestHttps') const { getInstalledPackages, setPackagesCache, - getAvailablePackages, + getAllPackages, getDependentPackages, getDependencyPackages } = require('./packages') @@ -84,10 +84,14 @@ describe('packages', () => { }) }) - describe('getAvailablePackages', () => { + describe('getAllPackages', () => { it('', async () => { - const availablePackages = await getAvailablePackages() - expect(availablePackages).toEqual([availableUninstalledPackage]) + const allPackages = await getAllPackages() + expect(allPackages).toEqual([ + availableInstalledPackage, + availableUninstalledPackage, + unavailableInstalledPackage, + unavailableUninstalledPackage]) }) }) @@ -239,7 +243,7 @@ describe('packages', () => { '/dist/jquery.js' ], meta: { - description: 'Add the jQuery JavaScript library to your prototype' + description: 'jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.' } }, versions: [ diff --git a/lib/plugins/plugin-utils.js b/lib/plugins/plugin-utils.js index 1767fa81b4..63154073d7 100644 --- a/lib/plugins/plugin-utils.js +++ b/lib/plugins/plugin-utils.js @@ -5,12 +5,12 @@ function getProxyPluginConfig (packageName) { scripts: ['/dist/jquery.js'], assets: ['/dist'], meta: { - description: 'Add the jQuery JavaScript library to your prototype' + description: 'jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.' } }, 'notifications-node-client': { meta: { - description: 'Send emails and SMS from GOV.UK Notify' + description: 'GOV.UK Notify makes it easy for public sector service teams to send emails, text messages and letters.' } } }