Skip to content

Commit

Permalink
feat: add validation to prevent duplicate global environment names (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pragadesh-45 authored Nov 20, 2024
1 parent 44debfd commit a752921
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export const addGlobalEnvironment = ({ name, variables = [] }) => (dispatch, get
const uid = uuid();
ipcRenderer
.invoke('renderer:create-global-environment', { name, uid, variables })
.then(
dispatch(_addGlobalEnvironment({ name, uid, variables }))
)
.then(() => dispatch(_addGlobalEnvironment({ name, uid, variables })))
.then(resolve)
.catch(reject);
});
Expand Down
4 changes: 4 additions & 0 deletions packages/bruno-electron/src/store/global-environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class GlobalEnvironmentsStore {

addGlobalEnvironment({ uid, name, variables = [] }) {
let globalEnvironments = this.getGlobalEnvironments();
const existingEnvironment = globalEnvironments.find(env => env?.name == name);
if (existingEnvironment) {
throw new Error('Environment with the same name already exists');
}
globalEnvironments.push({
uid,
name,
Expand Down

0 comments on commit a752921

Please sign in to comment.