Skip to content

Handle non-committed changes when switching branches in PA editor

What does this MR do and why?

When user has unsaved changes in the PA editor and they try to switch branch, we now prompt them with a modal that ask them whether they want to discard their changes and switch branch or go back to the form so that they can commit their changes.

Screenshots or screen recordings

Screen_Recording_2021-10-21_at_1.14.42_PM

How to set up and validate locally

  1. In the rails console rails c, write Feature.enable(:pipeline_editor_branch_switcher)
  2. Setup a project with at least 2 branches
  3. Write a CI/CD config (anything even something invalid will do)
  4. Navigate to CI/CD => Editor
  5. Switch branch
  6. Notice that no modal appears and you navigate to the other branch
  7. Modify the CI/CD config
  8. Try to switch branch
  9. Notice that a modal appears
  10. Click on "Commit changes"
  11. Notice that the modal closes and it scrolls down to the commit form
  12. Try to switch branch again
  13. click on "Switch branch"
  14. Notice that you now switch branch and you lost the modifications you made.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #331107 (closed)

Edited by Frédéric Caplette

Merge request reports