Skip to content

Generate always available name for a new website - #900

Merged
nightnei merged 4 commits into
trunkfrom
fix/generateAlwaysAvailableNameForNewWebsite
Feb 13, 2025
Merged

Generate always available name for a new website#900
nightnei merged 4 commits into
trunkfrom
fix/generateAlwaysAvailableNameForNewWebsite

Conversation

@nightnei

@nightnei nightnei commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

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 Feb 6, 2025

@sejas sejas left a comment

Copy link
Copy Markdown
Member

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 ),

Comment thread src/lib/generate-site-name.ts Outdated
const CYRILLIC = 'а-яё';
const ARABIC = '\\u0600-\\u06FF';
const HEBREW = '\\u0590-\\u05FF';
const HEREW = '\\u0590-\\u05FF';

Copy link
Copy Markdown
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.

Comment thread src/lib/generate-site-name.ts Outdated
while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) {
postfix++;
}
return `${ randomName } ${ postfix }`;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@nightnei nightnei Feb 10, 2025

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this is what I meant. So the order would look as follows:

  • My WordPress Website
  • One of My RANDOM Website names
  • My WordPress Website 1
  • My WordPress Website 2
    This seems to be the least confusing to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread src/lib/generate-site-name.ts Outdated
while ( usedSiteNames.includes( `${ randomName } ${ postfix }` ) ) {
postfix++;
}
return `${ randomName } ${ postfix }`;

Copy link
Copy Markdown
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?

Comment thread src/lib/generate-site-name.ts Outdated
}

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

Copy link
Copy Markdown
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
Copy Markdown
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My comment referred only to the variable name. postfix is the name of the mail-sending agent. I think it should be affix, instead, or even better, just siteNumber.

@wojtekn wojtekn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works as expected. I'm just unsure if the first number should be 1 or 2, because in the end, "My WordPress Website 1" will be second site of that name. Not a big deal, though, as it's edge case.

@fredrikekelund

Copy link
Copy Markdown
Contributor

I'm just unsure if the first number should be 1 or 2, because in the end, "My WordPress Website 1" will be second site of that name

I haven't reviewed the code here, but the commonsensical approach would be to start the counter from 2, IMO.

@nightnei
nightnei merged commit 9806694 into trunk Feb 13, 2025
@nightnei
nightnei deleted the fix/generateAlwaysAvailableNameForNewWebsite branch February 13, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants