Resolve "When the branch name is a divider or separator, the project home page cannot display the branch name correctly."
What does this MR do?
This MR fixes an issue where branches named separator
or divider
don't show up in the project ref switcher, but do cause it to render an actual divider or separator dropdown item.
Problem
The gl_dropdown.js
file reads in string primitives for each data item. If these strings match either divider
or separator
, the file doesn't render the data, and instead renders an actual divider or separator item.
Unfortunately, "separator"
and "divider"
are much too easy to accidentally conflict with.
Solution
This MR completely refactors the rendering portion(s) of the gl_dropdown.js
file.
All divider
s and separator
s must be generated by { "type": ("separator"|"divider") }
instead of plaintext strings.
More solution notes from commit c91f915a:
Basic Intent: Allow all branch names without accidentally creating layout or backstage DOM. e.g. a branch named
separator
should never create a separatorli
element.Ideally, there should never be a string that could cause this kind of conflict.
Implementation: All of
GitLabDropdown.renderItem
is extracted to a standalone module.To render a divider or separator, consumers must now pass in an object like
{ "type": "divider" }
or{ "type": "separator" }
Notable choices:
- All of the functions have a cyclomatic complexity of 3 or less
- See: https://en.wikipedia.org/wiki/Cyclomatic_complexity
- Note the "Correlation to number of defects" section
- While software complexity may not have a directly causal relationship with defects, less complex software is generally easier to reason about, and may reduce defects. I personally try to maintain complexity of no higher than 3.
Other Notes
There's an epic issue that addresses the double scrollbar problem that occurs when the branch/tag/commit list is scrollable, which is visible in the after
screenshot (since the list is now long enough to scroll, barely), or on gitlab.com
.
Screenshots
Before | After |
---|---|
![]() |
![]() |
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
~~Label as security and @ mention @gitlab-com/gl-security/appsec
~~ -
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #65473 (moved)
Merge request reports
Activity
changed milestone to %Backlog
added devopscreate frontend groupsource code priority4 repository severity4 typebug labels
added 1 commit
- edfac052 - Use a more obscure string for dropdown separators
added 1 commit
- 2a7b2f45 - Use a more obscure string for dropdown separators
2 Warnings This merge request changed files with disabled eslint rules. Please consider fixing them. The title of this merge request is longer than 72 characters and would violate our commit message rules when using the Squash on Merge feature. Please consider adjusting the title, or rebase the commits manually and don’t use Squash on Merge. Disabled eslint rules
The following files have disabled
eslint
rules. Please consider fixing them:app/assets/javascripts/gl_dropdown.js
app/assets/javascripts/labels_select.js
app/assets/javascripts/milestone_select.js
app/assets/javascripts/namespace_select.js
app/assets/javascripts/search_autocomplete.js
app/assets/javascripts/users_select.js
spec/javascripts/gl_dropdown_spec.js
Run the following command for more details
node_modules/.bin/eslint --report-unused-disable-directives --no-inline-config \ 'app/assets/javascripts/gl_dropdown.js' \ 'app/assets/javascripts/labels_select.js' \ 'app/assets/javascripts/milestone_select.js' \ 'app/assets/javascripts/namespace_select.js' \ 'app/assets/javascripts/search_autocomplete.js' \ 'app/assets/javascripts/users_select.js' \ 'spec/javascripts/gl_dropdown_spec.js'
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.
Category Reviewer Maintainer frontend Illya Klymov ( @xanf
)Paul Slaughter ( @pslaughter
)Generated by
DangerEdited by 🤖 GitLab Bot 🤖marked the checklist item Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. as completed
marked the checklist item Code review guidelines as completed
marked the checklist item Merge request performance guidelines as completed
added 1 commit
- 20b1905b - Use a more obscure string for dropdown separators
marked the checklist item Style guides as completed
assigned to @thomasrandolph
added 1 commit
- 32118ff9 - Use a more obscure string for dropdown separators
added 1 commit
- caf0b0ab - Use a more obscure string for dropdown separators
added 1 commit
- 643a696a - Use a more obscure string for dropdown separators
added backstage [DEPRECATED] label
added 51 commits
-
643a696a...e2251a09 - 50 commits from branch
master
- 1043de5c - Use a more obscure string for dropdown separators
-
643a696a...e2251a09 - 50 commits from branch