Handle non-committed changes when switching branches in the pipeline editor
Summary
When switching between branches on the pipeline editor using the branch switcher, changes are not persisted. Switching away from a branch, then switching back to it, discards your changes and shows the config as it was when you first loaded the page. This happens to both committed and non-committed changes. This issue addresses the less severe of the two, non-committed changes. Uncommitted changes will be fixed in #331105 (closed)
Steps to reproduce
- Enable the
pipeline_editor_branch_switcher
feature flag (this is currently on for gitlab.com) - Open the pipeline editor on a project with a
.gitlab-ci.yaml
file. - Make some changes to the config file (but don't commit them)
- Switch away from that branch
- Switch back to that branch. Your changes will have dissapeared.
Here's an example video of me encountering the problem. test_f
Example Project
This project already has the feature flag enabled and is specifically set up to test issues like this. Please feel free to (ab)use it as needed to test this feature.
https://gitlab.com/samdbeckham/test
What is the current bug behavior?
When switching between branches, changes are not persisted in the UI.
What is the expected correct behavior?
You are shown a warning telling you you will lose your unsaved changes.
Proposal
Expected Behavior
- When user switches branches after editing the content, a modal will pop up warning them of unsaved changes. (header: "You have unsaved changes"; body: "Unsaved changes will be lost")
- Clicking
Commit Changes
should close the modal and automatically scroll down to the commit form. - Clicking
Switch Branches
will close the modal, switch to the target branch, and load the content of the target branch without saving changes.