BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
2 deletions
+42
-2
labels_finder.rb
app/finders/labels_finder.rb
+1
-1
issuables_helper.rb
app/helpers/issuables_helper.rb
+6
-0
_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-1
issue_37143_2.yml
changelogs/unreleased/issue_37143_2.yml
+5
-0
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