From 707a733c671e981e210312c01c1af07ce5f8e9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Mon, 7 Oct 2024 17:54:27 +0200 Subject: [PATCH] [Website] Restore the single-click "Edit Settings" flow (#1854) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation for the change, related issues Restores the easily accessible "Edit settings" button Playground had before merging #1731, and refocuses the user experience on a single, temporary Playground. Multiple Playgrounds are still possible, but now they're less emphasized. As we've learned from @annezazu and other users, the recent [Multiple Playgrounds UI update](https://github.com/WordPress/wordpress-playground/pull/1731) made rapid fire iterations in Playground more difficult. Before #1731, we've had an easily accessible button to update WP and PHP versions. After #1731, that feature required multiple clicks and finding the right button. This PR introduces the following changes: * Add an easily-accessible "Site settings" button for quick PHP/WP version updates * The URL reflects the Query API values used to create the temporary Playground. * Limit the number of temporary Playground sites to exactly one – just like before #1731. The temporary Playground is always there and cannot be deleted. * The only way to create a stored Playground is by saving the temporary Playground. Once you do that, you get a fresh temporary Playground. Kudos to @jarekmorawski for thinking through and designing multiple variations of the user flows ❤️ ## Technical details The implementation is straightforward and focused on rearranging React components and CSS. There's one gotcha in the process of saving temporary site settings. The settings form submission calls `window.history.pushState()` and the `EnsurePlaygroundIsSelected` component watches for the URL changes. However, the user may click the "Update Settings & Reset Playground" button even without changing any form value. Normally, this would mean we can't detect a change and reset the Playground. This PR, thus, adds the `?random=` parameter to the query string to allow Playground notice the change and recreate the temporary site. ## Visuals ![CleanShot 2024-10-06 at 23 19 12@2x](https://github.com/user-attachments/assets/11e69587-a6ca-4f73-8d51-f15997950e71) ![CleanShot 2024-10-07 at 01 35 12@2x](https://github.com/user-attachments/assets/0e13f94a-adef-4f5a-8fc3-f3f4b9a577c6) Here's the video walkthrough – note I've recorded it before this PR was fully ready for a review: https://github.com/user-attachments/assets/b2f04fa6-d7d5-43ad-93e2-975a2a9cea21 ## Follow up work There are more design elements to consider, e.g. Snackbar notices. @jarekmorawski already designed some improvements and is working more. I would still like to get this PR in and continue iterating based on the feedback we get. ## UI updates checklist - [x] Tested mobile interactions - [x] Resolved accessibility issues reported by Axe Devtools ## Testing plan CI aside, interact with the design proposed in this PR and confirm it feels right. --- packages/playground/website/index.html | 2 +- .../website/playwright/e2e/website-ui.spec.ts | 158 +++-- .../website/playwright/website-page.ts | 75 +-- .../src/components/browser-chrome/index.tsx | 43 ++ .../browser-chrome/style.module.css | 13 + .../edit-site-settings-button/index.tsx | 42 ++ .../style.module.css | 3 + .../ensure-playground-site-is-selected.tsx | 101 +-- .../website/src/components/layout/index.tsx | 2 +- .../src/components/layout/style.module.css | 3 + .../components/playground-viewport/index.tsx | 19 +- .../src/components/plugin-ide/setup.ts | 31 - .../src/components/site-manager/icons.tsx | 3 +- .../src/components/site-manager/index.tsx | 8 +- .../components/site-manager/sidebar/index.tsx | 195 +++--- .../site-manager/sidebar/style.module.css | 22 +- .../site-manager/site-create-button/index.tsx | 50 -- .../site-manager/site-info-panel/index.tsx | 620 ++++++------------ .../site-info-panel/style.module.css | 67 +- .../active-site-settings-form.tsx | 35 + .../site-manager/site-settings-form/index.tsx | 562 +--------------- .../stored-site-settings-form.tsx} | 90 ++- .../site-settings-form/style.module.css | 43 ++ .../temporary-site-settings-form.tsx} | 63 +- .../unconnected-site-settings-form.tsx | 498 ++++++++++++++ .../site-manager/storage-type/index.tsx | 2 +- .../website/src/lib/get-relative-date.ts | 31 + .../website/src/lib/site-metadata.ts | 6 +- .../lib/state/redux/persist-temporary-site.ts | 3 + .../src/lib/state/redux/slice-sites.ts | 76 ++- .../website/src/lib/state/url/router.ts | 14 +- 31 files changed, 1338 insertions(+), 1542 deletions(-) create mode 100644 packages/playground/website/src/components/edit-site-settings-button/index.tsx create mode 100644 packages/playground/website/src/components/edit-site-settings-button/style.module.css delete mode 100644 packages/playground/website/src/components/plugin-ide/setup.ts delete mode 100644 packages/playground/website/src/components/site-manager/site-create-button/index.tsx create mode 100644 packages/playground/website/src/components/site-manager/site-settings-form/active-site-settings-form.tsx rename packages/playground/website/src/components/site-manager/{site-edit-button/index.tsx => site-settings-form/stored-site-settings-form.tsx} (51%) rename packages/playground/website/src/components/site-manager/{start-similar-site-button/index.tsx => site-settings-form/temporary-site-settings-form.tsx} (57%) create mode 100644 packages/playground/website/src/components/site-manager/site-settings-form/unconnected-site-settings-form.tsx create mode 100644 packages/playground/website/src/lib/get-relative-date.ts diff --git a/packages/playground/website/index.html b/packages/playground/website/index.html index e7392029e0..91806487eb 100644 --- a/packages/playground/website/index.html +++ b/packages/playground/website/index.html @@ -43,7 +43,7 @@ -
+