mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-16 09:50:17 +01:00
Added activate button to environment window. (#1531)
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
parent
e5d7cd1be9
commit
2df7fd6588
@ -3,6 +3,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|||||||
import { IconTrash, IconAlertCircle } from '@tabler/icons';
|
import { IconTrash, IconAlertCircle } from '@tabler/icons';
|
||||||
import { useTheme } from 'providers/Theme';
|
import { useTheme } from 'providers/Theme';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
|
import { selectEnvironment } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import SingleLineEditor from 'components/SingleLineEditor';
|
import SingleLineEditor from 'components/SingleLineEditor';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
import { uuid } from 'utils/common';
|
import { uuid } from 'utils/common';
|
||||||
@ -84,6 +85,18 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
|
|||||||
formik.setFieldValue(formik.values.length, newVariable, false);
|
formik.setFieldValue(formik.values.length, newVariable, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onActivate = () => {
|
||||||
|
dispatch(selectEnvironment(environment ? environment.uid : null, collection.uid))
|
||||||
|
.then(() => {
|
||||||
|
if (environment) {
|
||||||
|
toast.success(`Environment changed to ${environment.name}`);
|
||||||
|
} else {
|
||||||
|
toast.success(`No Environments are active now`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => console.log(err) && toast.error('An error occurred while selecting the environment'));
|
||||||
|
};
|
||||||
|
|
||||||
const handleRemoveVar = (id) => {
|
const handleRemoveVar = (id) => {
|
||||||
formik.setValues(formik.values.filter((variable) => variable.uid !== id));
|
formik.setValues(formik.values.filter((variable) => variable.uid !== id));
|
||||||
};
|
};
|
||||||
@ -184,12 +197,19 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
<span class="mr-2">
|
||||||
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={formik.handleSubmit}>
|
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={formik.handleSubmit}>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
|
</span>
|
||||||
<button type="submit" className="ml-2 px-1 submit btn btn-md btn-secondary mt-2" onClick={handleReset}>
|
<button type="submit" className="ml-2 px-1 submit btn btn-md btn-secondary mt-2" onClick={handleReset}>
|
||||||
Reset
|
Reset
|
||||||
</button>
|
</button>
|
||||||
|
<span>
|
||||||
|
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={onActivate}>
|
||||||
|
Activate
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user