Add sites from the site manager - #1680
Conversation
| /** | ||
| * Generate a slug from the site name. | ||
| * TODO: remove this when site storage is implemented. | ||
| * In site storage slugs will be generated automatically. | ||
| */ | ||
| newSlug = newSlug.replace(' ', '-'); | ||
| /** | ||
| * If the site name already exists, we won't need to add it again. | ||
| * TODO: remove this check when site storage is implemented. | ||
| * In site storage we won't be limited to having unique site names. | ||
| */ |
There was a problem hiding this comment.
@brandonpayton I made some assumptions here about how site storage will work but it's not necessary to implement it in that way.
| .add-site-input { | ||
| margin-bottom: 24px; | ||
| } | ||
| .add-site-input.invalid-input :global(.components-input-control__backdrop) { | ||
| border-color: #e26f56 !important; | ||
| } | ||
|
|
||
| .add-site-input.invalid-input :global(.components-base-control__help) { | ||
| color: #e26f56; | ||
| } |
There was a problem hiding this comment.
I wasn't able to find any validation in WordPress components.
…anager-sidebar/index.tsx
| /** | ||
| * The `wordpress` site is selected when no site slug is provided. | ||
| */ | ||
| const isSelected = | ||
| site.slug === siteSlug || | ||
| (siteSlug === undefined && | ||
| site.slug === 'wordpress'); |
There was a problem hiding this comment.
This is an unrelated bug fix.
|
The hamburger menu seems broken: CleanShot.2024-08-09.at.11.17.25.mp4 |
|
I was wondering what causes the issue and couldn't crack it. I checked out trunk and this PR again and that problem is now gone. How weird! |
|
Is there a reason we have to ask the user to invent a name? Could we just call it "My new site" and skip the modal? On the other hand, modal will have more options in the future so maybe it's a good start. A few UX notes about the modal itself:
|
520161a to
cdebe5f
Compare
There is no way to change the name today, so I wanted to give users a choice.
It's now changing, so the name can be anything. I also added validation to avoid duplicate names.
I added
Fixed. |
Agreed, it should be fine to just write that name to a |
|
Thanks for the review @adamziel! With auto-generating names this PR should work ok for users until we get the site storage. |

Motivation for the change, related issues
The current site manager allows users to switch between sites only, but it still isn't clear how to add a site.
To allow users to add sites this PR adds an Add site button and modal for inserting the site name.
On submit a new site is added and loaded.
Implementation details
The
add-site-buttoncomponent validates the name and generates a slug out of it.Because we can only store the slug until site storage is completed, the name is limited to lowercase letters and numbers.
The site sidebar now supports adding sites. Sites are added to the state which will later get moved to site storage.
The
add-site-buttoncomponent isn't completed, this is only a temporary implementation.Once we have the site manager, the button will just create a new site without any modals or inputs.
Testing Instructions (or ideally a Blueprint)