Skip to content

Improve site name suggestions to ensure both name and path uniqueness - #972

Merged
bcotrim merged 2 commits into
trunkfrom
fix/new_default_site_folder_name
Feb 24, 2025
Merged

Improve site name suggestions to ensure both name and path uniqueness#972
bcotrim merged 2 commits into
trunkfrom
fix/new_default_site_folder_name

Conversation

@bcotrim

@bcotrim bcotrim commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

  • Modified site name generation to ensure both name and path uniqueness
  • Simplified code by using sites directly from useAddSite
  • Improved type safety with proper SiteDetails type usage

Testing Instructions

  1. Happy path
  • Create a new site using the default name
  • Create another site.
    Expected results: Site name is suggested without conflicting name or path
  1. Previous error case
  • Create a new site using the default name
  • Rename the site in "Settings"
  • Create a new site
    Expected results: Site name is suggested without conflicting name or path
  1. Suggested name limit
  • Create a new site using the default name
  • Create more sites until all suggestions are used (you can comment some names here to speed up the process)
  • Create another site.
    Expected results: Site name is suggested, using the default name plus an incremental value, without conflicting name or path

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@bcotrim
bcotrim requested a review from a team February 24, 2025 12:29
@bcotrim
bcotrim force-pushed the fix/new_default_site_folder_name branch from f79c97f to f51ed5f Compare February 24, 2025 13:09

@ivan-ottinger ivan-ottinger 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.

Nice clean-up and fix! 👌🏼🙂

  • the proposed changes look good
  • I could not reproduce the issue we are fixing here anymore
  • if all predefined name/path options are exhausted, the default one with a number incremented is suggested:

Markup on 2025-02-24 at 17:07:32

I did not observe any regressions.

@bcotrim
bcotrim merged commit 94e869d into trunk Feb 24, 2025
@bcotrim
bcotrim deleted the fix/new_default_site_folder_name branch February 24, 2025 17:32
if ( ! usedSiteNames.includes( defaultName ) ) {
const isPathUnique = ( name: string ): boolean => {
const sanitizedPath = sanitizeFolderName( name );
return ! usedSites.some( ( site ) => site.path.toLowerCase().endsWith( '/' + sanitizedPath ) );

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.

Is it Windows-friendly?

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.

It doesn't, thanks for catching that.
I added a follow-up PR: #976

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

Labels

None yet

3 participants