Bugfix: show proper error toast when user tries to rename project to conflicting name (#5613)
* Correct error toast behavior so rename error comes through * Add rename error state to E2E test
This commit is contained in:
@ -306,6 +306,9 @@ const ProjectsContextDesktop = ({
|
||||
('output' in event &&
|
||||
typeof event.output === 'string' &&
|
||||
event.output) ||
|
||||
('error' in event &&
|
||||
event.error instanceof Error &&
|
||||
event.error.message) ||
|
||||
''
|
||||
),
|
||||
},
|
||||
@ -340,6 +343,13 @@ const ProjectsContextDesktop = ({
|
||||
name = interpolateProjectNameWithIndex(name, nextIndex)
|
||||
}
|
||||
|
||||
// Toast an error if the project name is taken
|
||||
if (projects.find((p) => p.name === name)) {
|
||||
return Promise.reject(
|
||||
new Error(`Project with name "${name}" already exists`)
|
||||
)
|
||||
}
|
||||
|
||||
await renameProjectDirectory(
|
||||
window.electron.path.join(defaultDirectory, oldName),
|
||||
name
|
||||
|
Reference in New Issue
Block a user