Add uniqueness check to "Create project" command (#5100)
* Add failing playwright test * Make create generate a unique name if the given one collides * Add a new consolidated getUniqueProjectName function with tests * Use getUniqueProjectName * Replace "New project" button text with "Create project" cc @pierremtb * Extend the e2e test to show the incrementing behavior cc @lf94
This commit is contained in:
@ -18,6 +18,7 @@ import {
|
||||
getNextProjectIndex,
|
||||
interpolateProjectNameWithIndex,
|
||||
doesProjectNameNeedInterpolated,
|
||||
getUniqueProjectName,
|
||||
} from 'lib/desktopFS'
|
||||
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||
import useStateMachineCommands from 'hooks/useStateMachineCommands'
|
||||
@ -195,15 +196,11 @@ const ProjectsContextDesktop = ({
|
||||
: settings.projects.defaultProjectName.current
|
||||
).trim()
|
||||
|
||||
if (doesProjectNameNeedInterpolated(name)) {
|
||||
const nextIndex = getNextProjectIndex(name, input.projects)
|
||||
name = interpolateProjectNameWithIndex(name, nextIndex)
|
||||
}
|
||||
|
||||
await createNewProjectDirectory(name)
|
||||
const uniqueName = getUniqueProjectName(name, input.projects)
|
||||
await createNewProjectDirectory(uniqueName)
|
||||
|
||||
return {
|
||||
message: `Successfully created "${name}"`,
|
||||
message: `Successfully created "${uniqueName}"`,
|
||||
name,
|
||||
}
|
||||
}),
|
||||
|
Reference in New Issue
Block a user