WebApp Redesign: Interact with sites list via redux - #1679
Conversation
|
Planning to explore adding, removing, and actually saving site metadata next. |
|
@bgrgicak, I added some rough implementation for adding and removing sites. None of it is even tested yet, but I hope you find it useful if you decide to work on something related in the UI. There are a ton of TODOs and things to think more about. The purpose of sketching this is to get it out of my head and into something real so we can iterate on it. |
|
Lovely, thank you for exploring this! |
| ### Tools | ||
|
|
||
| - Add max-len rule. ([#1613](https://github.com/WordPress/wordpress-playground/pull/1613)) | ||
| - Add max-len rule. ([#1613](https://github.com/WordPress/wordpress-playground/pull/1613)) |
There was a problem hiding this comment.
🤔 I don't know why these changelog changes are included.
|
This has been updated with the latest from |
|
What's next: |
|
Interesting: Safari doesn't support the So I guess this means that we need to spawn a worker for writing site info here if we want to be able to do it in UI code. |
| */ | ||
| name = name.replace(/wordpress/i, 'WordPress'); | ||
| const sites = useSelector( | ||
| (state: PlaygroundReduxState) => state.siteListing.sites |
There was a problem hiding this comment.
Let's also select loading/error status here and reflect in the UI, even if we show crude or basic error messages in case of error.
|
There is an error when adding sites that may be due to merging with the latest from trunk. Looking into it. |
|
The error turned out to be due to throwing an error during a directory existence check where it should not have been thrown. It might have been accidentally added for testing and not reverted. After that, with the latest from trunk, adding a new site failed because unzipping WordPress couldn't move the WordPress source dir into place because there was already a mostly empty directory containing a single playground-site-metadata.json file. So I updated the unzip code to tolerate that specific scenario and move the children of the WordPress source dir into place instead. It currently hardcodes the name of the Playground site metadata file, and I'd like to import that instead. |
|
There are some lingering TODOs, but we should ship this and continue iterating. |
Motivation for the change, related issues
This is a PR to start exploring site storage. In order to start from a concrete place, this PR starts by setting up the site manager sidebar to interact with the sites list via redux.
Related to #1659
Implementation details
This PR adds a
site-storagemodule that provides functions for adding, removing, and listing sites. It currently only supports writing to sites stored in OPFS.Today, Safari only appears to support writing to OPFS files from worker threads, so this PR adds a
site-storage-metadata-worker.tsmodule that the UI thread can spawn to write site metadata to OPFS.This PR adds a
siteListingproperty to our web app's redux state. It looks like:SiteListingStatuscan reflect whether the listing is loading, loaded, or in an error state.The site-manager-sidebar has been updated to select sites state from redux and interact with the sites list via redux actions. Currently, the loading status is ignored, but we should show it to the user in a follow-up PR.
Testing Instructions (or ideally a Blueprint)
Run
npm run devand interact with the sites list in Chrome and Safari. (Unfortunately, Firefox does not yet support loading Service Worker modules, and that feature is required for our current dev setup)