feat: Make CTRL+S hotkey work for environment modal #4701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Closes #1447
This PR makes CTRL+S hotkey work for environment modal. Here are the changes that I had to do:
The hotkey didn't have access to data of formik used in the environment modal, so the existing
saveEnvironment(values, environmentUid, collectionUid)
couldn't be used. So the first step was making it not acceptvalues
from dispatcher i.e.,saveEnvironment(environmentUid, collectionUid)
.Unlike other components (Collections, Requests) where redux states were updated as user edited them,
EnvironmentVariables
changes were only being tracked in formik. So the next step was to update the redux state of environments. There was already an incorrectly namedsaveEnvironment
which updated the state but was not used. So I renamed it toupdateEnvironment
(as was the naming convention for other cases) and dispatched the changing form values to it.Next I added a key called
environmentSettingsSelectedTab
inside collection's state to track which environment was being edited. This was necessary for saving.environmentSettingsSelectedTab
is updated using the actionupdateEnvironmentSettingsSelectedTab
whenever the tab is switched.Added toast to inform user that the environment has been persisted.
Passed
isModified
down toEnvironmentVariables
to track changes and save only when there are actual changes.Contribution Checklist: