Ref Switcher should be improved for performance and to prevent crashes
The _ref_switcher.html.haml
file is included in a number of views and loads all branches and tags for the repository whenever it renders. This is a problem for any repository of considerable size because it may have hundreds of branches and tags, even thousands or tens of thousands in some cases.
Suggested improvements:
- The partial uses a Select2 dropdown when it should probably be using the new dropdowns @iamphill has built for GitLab.
- Branch and tag data should be loaded asynchronously, only when the user tries to open the dropdown.
- For particularly large projects, it should only load the first N branches/tags, and the user should have to manually request further data after reaching the bottom of the list (this causes problems with search since not all the data would be downloaded locally. In that case we'd need a backend method to search branches/tags and return data).
- Not vital, but ideally there'd be a tab for branches and one for tags. Scrolling all the way through hundreds of branches to reach the tags is a pain.
The partial is currently included in all of the following views:
app/views/projects/badges/index.html.haml
app/views/projects/blob/_blob.html.haml
app/views/projects/commits/show.html.haml
app/views/projects/find_file/show.html.haml
app/views/projects/graphs/commits.html.haml
app/views/projects/graphs/show.html.haml
app/views/projects/network/_head.html.haml
app/views/projects/tree/_tree_header.html.haml
This was brought up with #18182 (closed), where the Files view of a 100k-branch repository crashes the browser.