Resolve "/unlabel quick action - limit autocomplete to applied labels"
What does this MR do?
The MR adds filtering of labels available on ~
, /label ~
, /unlabel ~
, and /relabel ~
commands.
What does this MR not do?
The MR does not support real-time synchronization.
gfm_auto_complete.js
loads labels only once (by current design).
So synchronizing data is out of this MR's scope.
Expected behavior
-
/label
should show only labels that are
- available for current project
- not set to current issuable yet
-
/lab[TAB]
should behave exactly as above. -
/unlabel
should show only labels that are
- available for current project
- already set to current issuable
-
/unlab[TAB]
should behave exactly as above. -
/relabel
should show only labels that are available for current project. -
/relab[TAB]
should behave exactly as above. -
~
should show only labels that are available for current project regardless which ones are set.
Details
Backend
-
autocomplete_sources_controller.rb#labels
now respects parameterstype
andtype_id
(like in#commands
action). - If parameters are presented,
AutocompleteService.labels
mixes available labels with current set labels of passed issuable. - Frontend receives such an response:
..., {"title":"backend","color":"#FFECDB","set":true}, ...
Frontend
gfm_auto_complete.js#setupLabels
now has both modified matcher
(to parse slash commands) and filter
(to filter only needed labels).
Are there points in the code the reviewer needs to double check?
- Feature specs work correctly only for
~
command, but fail oncommand + ~
construction like/label ~
. Modification ofswitch
(adding an unneeded extra variable) infilter
ofgfm_auto_complete.js#setupLabels
fixes the specs, but it looks strange to me. - Frontend code is not maximal DRYed. I'm not sure if part of
matcher
code should be moved to a standalone function.
Why was this MR needed?
It makes UX better and improves user's workflow.
Screenshots
When no labels set yet
When labels frontend
and backend
are already set
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Closes #22680 (closed) and #27319 (closed)
Edited by blackst0ne