Fix state is not reset when feature flag API request fails #13090
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.
Summary
Fixes #11167
Occurred changes and/or fixed issues
This PR fixes the issue above and adds an e2e test to cover the changes.
We now revert the change to the feature flag model if the API request to update it fails, ensuring it does not appear changed in the UI.
We also improve the error message, taking the message from the error response if available.
Finally, this PR fixes a small bug, where if an error occurred, closing the dialog and clicking enable/disable again on a flag would show the previous error.
Note: We can't wire this into the flags that require restart, as the API does not always return before it restarts, so the API call can error, but that can indicate that a restart has started.
Checklist