Bugfix/rename with same name for Environments (#3199)

* added safe to rename for rename-environment to enable case insensitive file change

* chore: removed else block

---------

Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
Pragadesh-45 2024-09-26 16:02:15 +05:30 committed by GitHub
parent 25f43f12c7
commit 2e4051b022
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,9 @@ const RenameEnvironment = ({ onClose, environment, collection }) => {
.required('name is required') .required('name is required')
}), }),
onSubmit: (values) => { onSubmit: (values) => {
if (values.name === environment.name) {
return;
}
dispatch(renameEnvironment(values.name, environment.uid, collection.uid)) dispatch(renameEnvironment(values.name, environment.uid, collection.uid))
.then(() => { .then(() => {
toast.success('Environment renamed successfully'); toast.success('Environment renamed successfully');

View File

@ -298,7 +298,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
} }
const newEnvFilePath = path.join(envDirPath, `${newName}.bru`); const newEnvFilePath = path.join(envDirPath, `${newName}.bru`);
if (fs.existsSync(newEnvFilePath)) { if (!safeToRename(envFilePath, newEnvFilePath)) {
throw new Error(`environment: ${newEnvFilePath} already exists`); throw new Error(`environment: ${newEnvFilePath} already exists`);
} }