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
74849f97
Commit
74849f97
authored
Jun 02, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '18031-sidebar-labels-queries' into 'master'
See merge request !4436
parents
94b0da42
078ba8c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
5 deletions
+24
-5
CHANGELOG
CHANGELOG
+1
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+4
-0
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+5
-5
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+14
-0
No files found.
CHANGELOG
View file @
74849f97
...
@@ -30,6 +30,7 @@ v 8.9.0 (unreleased)
...
@@ -30,6 +30,7 @@ v 8.9.0 (unreleased)
- Add Application Setting to configure Container Registry token expire delay (default 5min)
- Add Application Setting to configure Container Registry token expire delay (default 5min)
- Cache assigned issue and merge request counts in sidebar nav
- Cache assigned issue and merge request counts in sidebar nav
- Cache project build count in sidebar nav
- Cache project build count in sidebar nav
- Reduce number of queries needed to render issue labels in the sidebar
v 8.8.3
v 8.8.3
- Fix 404 page when viewing TODOs that contain milestones or labels in different projects. !4312
- Fix 404 page when viewing TODOs that contain milestones or labels in different projects. !4312
...
...
app/models/concerns/issuable.rb
View file @
74849f97
...
@@ -213,6 +213,10 @@ module Issuable
...
@@ -213,6 +213,10 @@ module Issuable
hook_data
hook_data
end
end
def
labels_array
labels
.
to_a
end
def
label_names
def
label_names
labels
.
order
(
'title ASC'
).
pluck
(
:title
)
labels
.
order
(
'title ASC'
).
pluck
(
:title
)
end
end
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
74849f97
...
@@ -114,20 +114,20 @@
...
@@ -114,20 +114,20 @@
.sidebar-collapsed-icon
.sidebar-collapsed-icon
=
icon
(
'tags'
)
=
icon
(
'tags'
)
%span
%span
=
issuable
.
labels
.
count
=
issuable
.
labels
_array
.
size
.title.hide-collapsed
.title.hide-collapsed
Labels
Labels
=
icon
(
'spinner spin'
,
class:
'block-loading'
)
=
icon
(
'spinner spin'
,
class:
'block-loading'
)
-
if
can_edit_issuable
-
if
can_edit_issuable
=
link_to
'Edit'
,
'#'
,
class:
'edit-link pull-right'
=
link_to
'Edit'
,
'#'
,
class:
'edit-link pull-right'
.value.bold.issuable-show-labels.hide-collapsed
{
class:
(
"has-labels"
if
issuable
.
labels
.
any?
)
}
.value.bold.issuable-show-labels.hide-collapsed
{
class:
(
"has-labels"
if
issuable
.
labels
_array
.
any?
)
}
-
if
issuable
.
labels
.
any?
-
if
issuable
.
labels
_array
.
any?
-
issuable
.
labels
.
each
do
|
label
|
-
issuable
.
labels
_array
.
each
do
|
label
|
=
link_to_label
(
label
,
type:
issuable
.
to_ability_name
)
=
link_to_label
(
label
,
type:
issuable
.
to_ability_name
)
-
else
-
else
.light
None
.light
None
.selectbox.hide-collapsed
.selectbox.hide-collapsed
-
issuable
.
labels
.
each
do
|
label
|
-
issuable
.
labels
_array
.
each
do
|
label
|
=
hidden_field_tag
"
#{
issuable
.
to_ability_name
}
[label_names][]"
,
label
.
id
,
id:
nil
=
hidden_field_tag
"
#{
issuable
.
to_ability_name
}
[label_names][]"
,
label
.
id
,
id:
nil
.dropdown
.dropdown
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"#{issuable.to_ability_name}[label_names][]"
,
ability_name:
issuable
.
to_ability_name
,
show_no:
"true"
,
show_any:
"true"
,
project_id:
(
@project
.
id
if
@project
),
issue_update:
issuable_json_path
(
issuable
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"#{issuable.to_ability_name}[label_names][]"
,
ability_name:
issuable
.
to_ability_name
,
show_no:
"true"
,
show_any:
"true"
,
project_id:
(
@project
.
id
if
@project
),
issue_update:
issuable_json_path
(
issuable
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
...
...
spec/models/concerns/issuable_spec.rb
View file @
74849f97
...
@@ -227,6 +227,20 @@ describe Issue, "Issuable" do
...
@@ -227,6 +227,20 @@ describe Issue, "Issuable" do
end
end
end
end
describe
'#labels_array'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
before
(
:each
)
do
issue
.
labels
<<
bug
end
it
'loads the association and returns it as an array'
do
expect
(
issue
.
reload
.
labels_array
).
to
eq
([
bug
])
end
end
describe
"votes"
do
describe
"votes"
do
let
(
:project
)
{
issue
.
project
}
let
(
:project
)
{
issue
.
project
}
...
...
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