mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 15:33:11 +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();
|
const uid = uuid();
|
||||||
ipcRenderer
|
ipcRenderer
|
||||||
.invoke('renderer:create-global-environment', { name, uid, variables })
|
.invoke('renderer:create-global-environment', { name, uid, variables })
|
||||||
.then(
|
.then(() => dispatch(_addGlobalEnvironment({ name, uid, variables })))
|
||||||
dispatch(_addGlobalEnvironment({ name, uid, variables }))
|
|
||||||
)
|
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
|
@ -63,6 +63,10 @@ class GlobalEnvironmentsStore {
|
|||||||
|
|
||||||
addGlobalEnvironment({ uid, name, variables = [] }) {
|
addGlobalEnvironment({ uid, name, variables = [] }) {
|
||||||
let globalEnvironments = this.getGlobalEnvironments();
|
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({
|
globalEnvironments.push({
|
||||||
uid,
|
uid,
|
||||||
name,
|
name,
|
||||||
|
Loading…
Reference in New Issue
Block a user