mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 01:14:23 +01:00
fix: selected global env switch (#3344)
This commit is contained in:
parent
d70d4a482b
commit
d92e806899
@ -7,6 +7,7 @@ import StyledWrapper from './StyledWrapper';
|
|||||||
import ConfirmSwitchEnv from './ConfirmSwitchEnv';
|
import ConfirmSwitchEnv from './ConfirmSwitchEnv';
|
||||||
import ManageSecrets from 'components/Environments/EnvironmentSettings/ManageSecrets/index';
|
import ManageSecrets from 'components/Environments/EnvironmentSettings/ManageSecrets/index';
|
||||||
import ImportEnvironment from '../ImportEnvironment';
|
import ImportEnvironment from '../ImportEnvironment';
|
||||||
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
const EnvironmentList = ({ environments, activeEnvironmentUid, selectedEnvironment, setSelectedEnvironment, isModified, setIsModified }) => {
|
const EnvironmentList = ({ environments, activeEnvironmentUid, selectedEnvironment, setSelectedEnvironment, isModified, setIsModified }) => {
|
||||||
const [openCreateModal, setOpenCreateModal] = useState(false);
|
const [openCreateModal, setOpenCreateModal] = useState(false);
|
||||||
@ -26,7 +27,18 @@ const EnvironmentList = ({ environments, activeEnvironmentUid, selectedEnvironme
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedEnvironment) {
|
||||||
|
const _selectedEnvironment = environments?.find(env => env?.uid === selectedEnvironment?.uid);
|
||||||
|
const hasSelectedEnvironmentChanged = !isEqual(selectedEnvironment, _selectedEnvironment);
|
||||||
|
if (hasSelectedEnvironmentChanged) {
|
||||||
|
setSelectedEnvironment(_selectedEnvironment);
|
||||||
|
}
|
||||||
|
setOriginalEnvironmentVariables(selectedEnvironment.variables);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const environment = environments?.find(env => env.uid === activeEnvironmentUid) || environments?.[0];
|
const environment = environments?.find(env => env.uid === activeEnvironmentUid) || environments?.[0];
|
||||||
|
|
||||||
setSelectedEnvironment(environment);
|
setSelectedEnvironment(environment);
|
||||||
setOriginalEnvironmentVariables(environment?.variables || []);
|
setOriginalEnvironmentVariables(environment?.variables || []);
|
||||||
}, [environments, activeEnvironmentUid]);
|
}, [environments, activeEnvironmentUid]);
|
||||||
|
Loading…
Reference in New Issue
Block a user