Skip to content

Commit

Permalink
Added activate button to environment window. (usebruno#1531)
Browse files Browse the repository at this point in the history
Co-authored-by: Anoop M D <[email protected]>
  • Loading branch information
2 people authored and naman-bruno committed Jan 17, 2025
1 parent c0c839a commit 20e4045
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import cloneDeep from 'lodash/cloneDeep';
import { IconTrash, IconAlertCircle } from '@tabler/icons';
import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
import { selectEnvironment } from 'providers/ReduxStore/slices/collections/actions';
import SingleLineEditor from 'components/SingleLineEditor';
import StyledWrapper from './StyledWrapper';
import { uuid } from 'utils/common';
Expand Down Expand Up @@ -84,6 +85,18 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
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) => {
formik.setValues(formik.values.filter((variable) => variable.uid !== id));
};
Expand Down Expand Up @@ -184,12 +197,19 @@ const EnvironmentVariables = ({ environment, collection, setIsModified, original
</div>

<div>
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={formik.handleSubmit}>
Save
</button>
<span class="mr-2">
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={formik.handleSubmit}>
Save
</button>
</span>
<button type="submit" className="ml-2 px-1 submit btn btn-md btn-secondary mt-2" onClick={handleReset}>
Reset
</button>
<span>
<button type="submit" className="submit btn btn-md btn-secondary mt-2" onClick={onActivate}>
Activate
</button>
</span>
</div>
</StyledWrapper>
);
Expand Down

0 comments on commit 20e4045

Please sign in to comment.