Show an alert when a protected environment update fails

What does this MR do and why?

updateEnvironment in the protected environments edit store caught every rejection and only committed RECEIVE_UPDATE_PROTECTED_ENVIRONMENT_ERROR, which clears the loading flag and nothing else. Removing an approver or deployer the API refused — a 422 for the last deployer, a 403, a 500, a network error — left the page looking unchanged with no message. updateRule also committed RECEIVE_RULE_UPDATED after that swallowed failure, closing the edit form and discarding what the user had typed.

This MR:

  • shows an alert on failure, including the API's validation message when it returns one;
  • resolves updateEnvironment with whether the update succeeded, so updateRule only closes the edit form on success (the store's other callers ignore the value, so no rejection escapes to the Vue components);
  • adds the same alert to unprotectEnvironment, which swallowed errors the same way.

Two strings are added to locale/gitlab.pot. Specs cover the alert text with and without a server message, the resolved value, and the edit form staying open on failure; they fail without the store change.

References

Differences

Before: Deleting the last deployer on a protected environment does nothing visible; editing an approver rule and hitting an API error closes the form and loses the edits.

After: An alert reads "Failed to update the protected environment. Deploy access levels is too short (minimum is 1 character)" (or the generic message for other failures), and the edit form stays open with the user's values.

How to set up and validate locally

  1. In a project, open Settings > CI/CD > Protected environments and protect an environment with a single deployer.
  2. Delete that deployer.
  3. On master nothing happens; with this MR an alert explains the API rejected the change.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jeston Singh

Merge request reports

Loading
Loading