Resolve "When the branch name is a divider or separator, the project home page cannot display the branch name correctly."
-
Review changes -
-
Download -
Patches
-
Plain diff
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
- version 36eb346616
- version 35454c9748
- version 3420fda604
- version 33ef65d683
- version 32d7dea643
- version 314878e3df
- version 30cb29dd9d
- version 29db43afed
- version 28d03c660e
- version 27361bd380
- version 26f9ce0525
- version 25debaaa86
- version 243ed63719
- version 2325fc1972
- version 22e904279d
- version 2110389ce8
- version 201a0779a1
- version 19ad7ed9be
- version 185c10627f
- version 17a5621b5f
- version 16a4435e01
- version 157394961c
- version 14793c9667
- version 13fda977a4
- version 12fda977a4
- version 1171cc7c67
- version 10acec4317
- version 9f9aa6a9b
- version 82fd508e7
- version 71043de5c
- version 6643a696a
- version 5caf0b0ab
- version 432118ff9
- version 320b1905b
- version 22a7b2f45
- version 1edfac052
- master (base)
- latest version814ff26c5 commits,
- version 36eb3466165 commits,
- version 35454c97485 commits,
- version 3420fda6045 commits,
- version 33ef65d6835 commits,
- version 32d7dea6435 commits,
- version 314878e3df5 commits,
- version 30cb29dd9d5 commits,
- version 29db43afed5 commits,
- version 28d03c660e5 commits,
- version 27361bd3805 commits,
- version 26f9ce05255 commits,
- version 25debaaa865 commits,
- version 243ed637195 commits,
- version 2325fc19725 commits,
- version 22e904279d5 commits,
- version 2110389ce85 commits,
- version 201a0779a14 commits,
- version 19ad7ed9be4 commits,
- version 185c10627f7 commits,
- version 17a5621b5f6 commits,
- version 16a4435e015 commits,
- version 157394961c4 commits,
- version 14793c96674 commits,
- version 13fda977a44 commits,
- version 12fda977a44 commits,
- version 1171cc7c674 commits,
- version 10acec43171 commit,
- version 9f9aa6a9b1 commit,
- version 82fd508e71 commit,
- version 71043de5c1 commit,
- version 6643a696a1 commit,
- version 5caf0b0ab1 commit,
- version 432118ff91 commit,
- version 320b1905b1 commit,
- version 22a7b2f451 commit,
- version 1edfac0521 commit,
- Side-by-side
- Inline