alphagov / govuk-prototype-kit

Rapidly create HTML prototypes of GOV.UK services
https://prototype-kit.service.gov.uk
MIT License
305 stars 236 forks source link

When updating a plugin relevant dependencies should be installed (the same UX as installing a plugin) #2242

Closed BenSurgisonGDS closed 1 year ago

BenSurgisonGDS commented 1 year ago

What

This is a part 2 of the required functionality in the ticket:

Allow plugin developers to specify that their plugin is dependent on other plugins

If a plugin has dependencies (defined in pluginDependencies in the govuk-prototype-kit.config.json the user should have the chance to either cancel the upgrade or continue the upgrade and install the dependency.

Current behaviour vs expected behaviour

Context

Setup for testing

npx govuk-prototype-kit create demo-kit_2242 && cd demo-kit_2242 && npm install @govuk-prototype-kit/common-templates@1.1.1 && echo '{"serviceName": "Service name goes here", "allowGovukFrontendUninstall": true}' > app/config.json && npm run dev

This starts a kit with an older version of Common Templates and with the ability to uninstall GOV.UK Frontend through the UI.

Install (currently working, should be maintained)

  1. Go to Manage prototype
  2. Go to Plugins
  3. Click Uninstall next to GOV.UK Frontend
  4. Click Uninstall next to Common Templates
  5. Click Back to plugins
  6. Click Install next to Common Templates (this will install the latest version)

Here the user is warned that a GOV.UK Frontend will also be installed.

Update (not currently working, should be implemented)

  1. Go to Manage prototype
  2. Go to Plugins
  3. Click Uninstall next to GOV.UK Frontend
  4. Click Update next to Common Templates

Here the user should be warned that a GOV.UK Frontend will also be installed. If they proceed then both Common Templates and GOV.UK Frontend should be installed, if not nothing should be installed.

Design

250596505-51d18ee2-d2bc-4a10-8d97-f6e2092434df

Done when

Who needs to work on this

Who needs to review this

BenSurgisonGDS commented 1 year ago

Update

image (1)

nataliecarey commented 1 year ago

@joelanman have you designed for the following scenarios?

  1. A major version bump which might break things in the user's code? e.g. if hmrc-frontend start using govuk-frontend@5.0.0 the first day it comes out, then a user clicks to install HMRC Frontend and their kit breaks. To try to fix this they uninstall HMRC Frontend, should govuk-frontend be downgraded? If not their kit is still broken.

1(a). If we do downgrade to solve point 1 - a user creates a new kit, they install HMRC Frontend which bumps the govuk-frontend version, they build some pages and then realise they don't need HMRC Frontend. They uninstall HMRC frontend and their govuk-frontend is downgraded breaking their pages.

(suggestion: Do we need to keep track of the historic state of plugins and offer an undo/revert option)

  1. The user has one plugin installed which has a govuk-frontend max version of 5.0.0, then they try to install a plugin which specifies "min-version": "5.0.0". (technically this ticket is written with just minVersion but I think that creates a strange paradigm that we should avoid)
nataliecarey commented 1 year ago

@BenSurgisonGDS Until we've got a clear approach for the above (and I'm sure there are other scenarios that need to be considered) could you focus on the upgrade working the same as install please?

So if a user upgrades to a new version which now specifies a dependent plugin they get the same behaviour as if they were installing that plugin for the first time. I think it might be worth separating into two tickets (one for upgrade, one for minVersion and maxVersion) but that depends on how the conversation goes with the wider team. For now I'd suggest just starting with the upgrade.

joelanman commented 1 year ago

Having chatted with Natalie, if there's new UX to be designed as per her questions above, I'd prefer to push this back because we're redesigning all the plugin UI anyway, so keep this work as simple as possible

nataliecarey commented 1 year ago

The functionality looks ready. I'm expecting to approve the PR when we've released the fixes for the two production bugs.