mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 08:53:30 +01:00
feat: add validation to prevent duplicate global environment names (#3450)
This commit is contained in:
parent
44debfd9b9
commit
a752921413
@ -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);
|
||||
});
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user