Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate always available name for a new website #900

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

nightnei
Copy link
Contributor

@nightnei nightnei commented Feb 6, 2025

Proposed Changes

When you run out of available names, there is very weird result: after clicking "Add site" button we immediately see the next:
Screenshot 2025-02-06 at 12 08 34
Screenshot 2025-02-06 at 12 09 25

With this PR, the generation of names is always successful (we add numeric postfix), so users don't need to do extra actions and spend time to figure out "what is going on" .

Testing Instructions

Apply the next diff:

diff --git a/src/lib/generate-site-name.ts b/src/lib/generate-site-name.ts
index 3052a2f..ae3e6ad 100644
--- a/src/lib/generate-site-name.ts
+++ b/src/lib/generate-site-name.ts
@@ -4,24 +4,6 @@ export function generateSiteName( usedSiteNames: string[] ): string {
        const siteNames = [
                __( 'My Bold Website' ),
                __( 'My Bright Website' ),
-               __( 'My Blissful Website' ),
-               __( 'My Calm Website' ),
-               __( 'My Cool Website' ),
-               __( 'My Dreamy Website' ),
-               __( 'My Elite Website' ),
-               __( 'My Fresh Website' ),
-               __( 'My Glowing Website' ),
-               __( 'My Happy Website' ),
-               __( 'My Joyful Website' ),
-               __( 'My Noble Website' ),
-               __( 'My Pure Website' ),
-               __( 'My Peak Website' ),
-               __( 'My Prime Website' ),
-               __( 'My Serene Website' ),
-               __( 'My Shiny Website' ),
-               __( 'My Sparkly Website' ),
-               __( 'My Swift Website' ),
-               __( 'My True Website' ),
        ];
 
        const defaultName = __( 'My WordPress Website' );
  1. Remove all websites
  2. Assert that default website has name My WordPress Website and create it
  3. "Add new" website and assert that it has random name between My Bold Website and My Bright Website
  4. Add one more website and assert that it has the second name which left from previous step
  5. Add new website and assert that we have numeric postfix and further generations increase postfix correctly for random name

@nightnei nightnei requested a review from a team February 6, 2025 12:11
@nightnei nightnei changed the title fix: generate always available name for a new website Generate always available name for a new website Feb 6, 2025
Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

Left a couple of suggestions.
I think adding a postfix is an improvement 💪

In addition to this, we could increase our list of default sitenames by having a really long list of adjetives produced by an LLM and then use something like sprintf( __( 'My %s Website' ), adjetive ),

}

export const sanitizeFolderName = ( filename: string ) => {
const LATIN = 'a-z';
const CYRILLIC = 'а-яё';
const ARABIC = '\\u0600-\\u06FF';
const HEBREW = '\\u0590-\\u05FF';
const HEREW = '\\u0590-\\u05FF';
Copy link
Member

Choose a reason for hiding this comment

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

I think this change is not intentional.

while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) {
postfix++;
}
return `${ randomName } ${ postfix }`;
Copy link
Member

Choose a reason for hiding this comment

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

Should we take into account RTL languages ? For those languages the postfix should be on the left.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to always use My WordPress Website for subsequent names with the number, so user who uses all random names will keep getting My WordPress Website 1, My WordPress Website 2 and so on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally for me, it's one more good option. And I don't see any pros/cons, anyway it's more kinda "Temporary name", 99% that the user will change it to something connected with their website, unless it's testing site.
Only one good thing what I see with the current approach is that we have diversity of names 😅
So I would go with either proposed approach by me or remove all adjectives and keep only My WordPress Website ${number}. But I am ok with any approach, as long as we provide unique names.

Copy link
Contributor Author

@nightnei nightnei Feb 10, 2025

Choose a reason for hiding this comment

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

UPDATE, Oh, I guess you meant exactly to use only subsequent names of My WordPress Website and remove adjective options, right? If so, ignore my previous message and I think that it's good simple approach too, I don't have strong preference either to use it or keep proposed by me.

while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) {
postfix++;
}
return `${ randomName } ${ postfix }`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to always use My WordPress Website for subsequent names with the number, so user who uses all random names will keep getting My WordPress Website 1, My WordPress Website 2 and so on?

}

const randomName = siteNames[ Math.floor( Math.random() * siteNames.length ) ];
let postfix = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be suffix instead of postfix? Or just a siteNumber to ensure it makes sense for LTR and RTL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be suffix instead of postfix? Or just a siteNumber to ensure it makes sense for LTR and RTL?

If we make it as suffix, then it will be confusing for LTR environments, since we used to see number at the end (e.g. in MacOS, Windows).
So my opinion, we should change postfix with suffix only for RTL.
WDYT?
Screenshot 2025-02-10 at 11 49 22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants