diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-10-29 10:50:18 +0100 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-11-23 16:11:52 +0100 |
commit | c068ac67b3e40fdc039c80372306f9cc3360d594 (patch) | |
tree | d707871f8b7f5deb7f62d7630f317e94946eb1cc /app/finders | |
parent | f0630090aaea98daef3582bc95efe3a43736a10f (diff) | |
download | gitlab-ce-c068ac67b3e40fdc039c80372306f9cc3360d594.tar.gz |
Filter by `None`/`Any` for labels in issues/mrs API
By using the parameters `?labels=None|Any` the user can filter
issues/mrs from the API that has `none/any` label.
Affected endpoints are:
- /api/issues
- /api/projects/:id/issues
- /api/groups/:id/issues
- /api/merge_requests
- /api/projects/:id/merge_requests
- /api/groups/:id/merge_requests
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index fdc630cbf72..e04e3a2a7e0 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -210,7 +210,14 @@ class IssuableFinder end def filter_by_no_label? - labels? && params[:label_name].include?(Label::None.title) + downcased = label_names.map(&:downcase) + + # Label::NONE is deprecated and should be removed in 12.0 + downcased.include?(FILTER_NONE) || downcased.include?(Label::NONE) + end + + def filter_by_any_label? + label_names.map(&:downcase).include?(FILTER_ANY) end def labels @@ -465,6 +472,8 @@ class IssuableFinder items = if filter_by_no_label? items.without_label + elsif filter_by_any_label? + items.any_label else items.with_label(label_names, params[:sort]) end |