Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a956fac2
Commit
a956fac2
authored
Jan 17, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary query from labels filter
parent
5c51cbca
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
2 deletions
+42
-2
app/finders/labels_finder.rb
app/finders/labels_finder.rb
+1
-1
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+6
-0
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-1
changelogs/unreleased/issue_37143_2.yml
changelogs/unreleased/issue_37143_2.yml
+5
-0
spec/helpers/issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+29
-0
No files found.
app/finders/labels_finder.rb
View file @
a956fac2
...
...
@@ -71,7 +71,7 @@ class LabelsFinder < UnionFinder
end
def
projects?
params
[
:project_ids
]
.
present?
params
[
:project_ids
]
end
def
only_group_labels?
...
...
app/helpers/issuables_helper.rb
View file @
a956fac2
...
...
@@ -304,6 +304,12 @@ module IssuablesHelper
issuable
.
model_name
.
human
.
downcase
end
def
selected_labels
Array
(
params
[
:label_name
]).
map
do
|
label_name
|
Label
.
new
(
title:
label_name
)
end
end
private
def
sidebar_gutter_collapsed?
...
...
app/views/shared/issuable/_filter.html.haml
View file @
a956fac2
...
...
@@ -22,7 +22,7 @@
=
render
"shared/issuable/milestone_dropdown"
,
selected:
finder
.
milestones
.
try
(
:first
),
name: :milestone_title
,
show_any:
true
,
show_upcoming:
true
,
show_started:
true
.filter-item.inline.labels-filter
=
render
"shared/issuable/label_dropdown"
,
selected:
finder
.
labels
.
select
(
:title
).
uniq
,
use_id:
false
,
selected_toggle:
params
[
:label_name
],
data_options:
{
field_name:
"label_name[]"
}
=
render
"shared/issuable/label_dropdown"
,
selected:
selected_labels
,
use_id:
false
,
selected_toggle:
params
[
:label_name
],
data_options:
{
field_name:
"label_name[]"
}
-
if
issuable_filter_present?
.filter-item.inline.reset-filters
...
...
changelogs/unreleased/issue_37143_2.yml
0 → 100644
View file @
a956fac2
---
title
:
Remove unecessary query from labels filter
merge_request
:
author
:
type
:
performance
spec/helpers/issuables_helper_spec.rb
View file @
a956fac2
...
...
@@ -192,4 +192,33 @@ describe IssuablesHelper do
expect
(
JSON
.
parse
(
helper
.
issuable_initial_data
(
issue
))).
to
eq
(
expected_data
)
end
end
describe
'#selected_labels'
do
context
'if label_name param is a string'
do
it
'returns a new label with title'
do
allow
(
helper
).
to
receive
(
:params
)
.
and_return
(
ActionController
::
Parameters
.
new
(
label_name:
'test label'
))
labels
=
helper
.
selected_labels
expect
(
labels
).
to
be_an
(
Array
)
expect
(
labels
.
size
).
to
eq
(
1
)
expect
(
labels
.
first
.
title
).
to
eq
(
'test label'
)
end
end
context
'if label_name param is an array'
do
it
'returns a new label with title for each element'
do
allow
(
helper
).
to
receive
(
:params
)
.
and_return
(
ActionController
::
Parameters
.
new
(
label_name:
[
'test label 1'
,
'test label 2'
]))
labels
=
helper
.
selected_labels
expect
(
labels
).
to
be_an
(
Array
)
expect
(
labels
.
size
).
to
eq
(
2
)
expect
(
labels
.
first
.
title
).
to
eq
(
'test label 1'
)
expect
(
labels
.
second
.
title
).
to
eq
(
'test label 2'
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment