Skip to content

Add sites from the site manager - #1680

Merged
bgrgicak merged 10 commits into
trunkfrom
add/site-manager-add-site-button
Aug 9, 2024
Merged

Add sites from the site manager#1680
bgrgicak merged 10 commits into
trunkfrom
add/site-manager-add-site-button

Conversation

@bgrgicak

@bgrgicak bgrgicak commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

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-button component 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-button component 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)

  • open Playground with browser storage
  • open the site manager menu (upper left corner)
  • see the Add site button
  • click on the button and see the modal
  • add a site using the modal

Screenshot 2024-08-09 at 06 57 28

Comment on lines +87 to +97
/**
* 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.
*/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonpayton I made some assumptions here about how site storage will work but it's not necessary to implement it in that way.

Comment on lines +14 to +23
.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;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to find any validation in WordPress components.

Comment on lines +143 to +149
/**
* The `wordpress` site is selected when no site slug is provided.
*/
const isSelected =
site.slug === siteSlug ||
(siteSlug === undefined &&
site.slug === 'wordpress');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated bug fix.

@adamziel

adamziel commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

The hamburger menu seems broken:

CleanShot.2024-08-09.at.11.17.25.mp4
@adamziel

adamziel commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

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!

@adamziel

adamziel commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

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:

  • The "Add site" button is inactive even after I provide a name. I assume that's because I have an uppercase letter in the text field. There's no indication of an error, though.
  • Let's just accept all the characters and skip the "Can be lowercase letters, numbers, and spaces" part. If there's a technical reason for not accepting uppercase letters, let's resolve that reason and accept them.
  • Let's get rid of the 1password widget
  • Pressing "enter" reloads the entire page without creating a new site

CleanShot 2024-08-09 at 11 23 20@2x

@bgrgicak
bgrgicak force-pushed the add/site-manager-add-site-button branch from 520161a to cdebe5f Compare August 9, 2024 13:07
@bgrgicak

bgrgicak commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator Author

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.

There is no way to change the name today, so I wanted to give users a choice.

Let's just accept all the characters and skip the "Can be lowercase letters, numbers, and spaces" part. If there's a technical reason for not accepting uppercase letters, let's resolve that reason and accept them.

It's now changing, so the name can be anything. I also added validation to avoid duplicate names.
TBH it feels like an overcomplicated temporary feature.

Let's get rid of the 1password widget

I added data-1p-ignore but I can't test it. Please let me know if it worked.

Pressing "enter" reloads the entire page without creating a new site

Fixed.

@adamziel

adamziel commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

TBH it feels like an overcomplicated temporary feature.

Agreed, it should be fine to just write that name to a name.json file for now so that it has no relationship with site slug whatsoever.

@bgrgicak
bgrgicak merged commit b9a6826 into trunk Aug 9, 2024
@bgrgicak
bgrgicak deleted the add/site-manager-add-site-button branch August 9, 2024 13:36
@bgrgicak

bgrgicak commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator Author

Thanks for the review @adamziel! With auto-generating names this PR should work ok for users until we get the site storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment