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
Jérome Perrin
gitlab-ce
Commits
b654229d
Commit
b654229d
authored
Sep 26, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix LabelsHelper#link_to_label to use the subject argument
parent
ae88126d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
28 deletions
+33
-28
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+14
-8
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+4
-4
app/views/shared/_label_row.html.haml
app/views/shared/_label_row.html.haml
+1
-1
app/views/shared/_labels_row.html.haml
app/views/shared/_labels_row.html.haml
+1
-1
spec/helpers/labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+13
-14
No files found.
app/helpers/labels_helper.rb
View file @
b654229d
...
...
@@ -31,7 +31,13 @@ module LabelsHelper
#
# Returns a String
def
link_to_label
(
label
,
subject:
nil
,
type: :issue
,
tooltip:
true
,
css_class:
nil
,
&
block
)
link
=
label_filter_path
(
label
,
type:
type
)
subject
||=
case
label
when
GroupLabel
then
label
.
group
when
ProjectLabel
then
label
.
project
end
link
=
label_filter_path
(
subject
,
label
,
type:
type
)
if
block_given?
link_to
link
,
class:
css_class
,
&
block
...
...
@@ -40,16 +46,16 @@ module LabelsHelper
end
end
def
label_filter_path
(
label
,
type:
issue
)
case
label
when
Group
Label
def
label_filter_path
(
subject
,
label
,
type:
issue
)
case
subject
when
Group
send
(
"
#{
type
.
to_s
.
pluralize
}
_group_path"
,
label
.
group
,
subject
,
label_name:
[
label
.
name
])
else
when
Project
send
(
"namespace_project_
#{
type
.
to_s
.
pluralize
}
_path"
,
label
.
pro
ject
.
namespace
,
label
.
pro
ject
,
sub
ject
.
namespace
,
sub
ject
,
label_name:
[
label
.
name
])
end
end
...
...
app/views/shared/_label.html.haml
View file @
b654229d
...
...
@@ -12,10 +12,10 @@
.dropdown-menu.dropdown-menu-align-right
%ul
%li
=
link_to_label
(
label
,
type: :merge_request
)
do
=
link_to_label
(
label
,
subject:
@project
,
type: :merge_request
)
do
=
pluralize
open_merge_requests_count
,
'merge request'
%li
=
link_to_label
(
label
)
do
=
link_to_label
(
label
,
subject:
@project
)
do
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
%li
.label-subscription
{
data:
{
url:
toggle_subscription_label_path
(
label
)
}
}
...
...
@@ -28,9 +28,9 @@
=
link_to
'Delete'
,
destroy_label_path
(
label
),
title:
'Delete'
,
method: :delete
,
remote:
true
,
data:
{
confirm:
'Remove this label? Are you sure?'
}
.pull-right.hidden-xs.hidden-sm.hidden-md
=
link_to_label
(
label
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action'
)
do
=
link_to_label
(
label
,
subject:
@project
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action'
)
do
=
pluralize
open_merge_requests_count
,
'merge request'
=
link_to_label
(
label
,
css_class:
'btn btn-transparent btn-action'
)
do
=
link_to_label
(
label
,
subject:
@project
,
css_class:
'btn btn-transparent btn-action'
)
do
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
...
...
app/views/shared/_label_row.html.haml
View file @
b654229d
...
...
@@ -9,7 +9,7 @@
%button
.remove-priority.btn.has-tooltip
{
title:
'Remove priority'
,
:'data-placement'
=>
'top'
}
=
icon
(
'star'
)
%span
.label-name
=
link_to_label
(
label
,
tooltip:
false
)
=
link_to_label
(
label
,
subject:
@project
,
tooltip:
false
)
-
if
can?
(
current_user
,
:admin_label
,
@project
)
=
label_type_icon
(
label
,
hidden:
label
.
priority
.
blank?
)
-
if
label
.
description
...
...
app/views/shared/_labels_row.html.haml
View file @
b654229d
-
labels
.
each
do
|
label
|
%span
.label-row.btn-group
{
role:
"group"
,
aria:
{
label:
label
.
name
},
style:
"color: #{text_color_for_bg(label.color)}"
}
=
link_to_label
(
label
,
css_class:
'btn btn-transparent'
)
=
link_to_label
(
label
,
subject:
@project
,
css_class:
'btn btn-transparent'
)
%button
.btn.btn-transparent.label-remove.js-label-filter-remove
{
type:
"button"
,
style:
"background-color: #{label.color};"
,
data:
{
label:
label
.
title
}
}
=
icon
(
"times"
)
spec/helpers/labels_helper_spec.rb
View file @
b654229d
...
...
@@ -5,27 +5,26 @@ describe LabelsHelper do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
)
}
context
'with @project set'
do
before
do
@project
=
project
end
it
'uses the instance variable'
do
expect
(
link_to_label
(
label
)).
to
match
%r{<a href="/
#{
@project
.
to_reference
}
/issues
\?
label_name%5B%5D=
#{
label
.
name
}
"><span class="[
\w\s\-
]*has-tooltip".*</span></a>}
context
'without subject'
do
it
"uses the label's project"
do
expect
(
link_to_label
(
label
)).
to
match
%r{<a href="/
#{
label
.
project
.
to_reference
}
/issues
\?
label_name%5B%5D=
#{
label
.
name
}
">.*</a>}
end
end
context
'without @project set'
do
it
"uses the label's project"
do
expect
(
link_to_label
(
label
)).
to
match
%r{<a href="/
#{
label
.
project
.
to_reference
}
/issues
\?
label_name%5B%5D=
#{
label
.
name
}
">.*</a>}
context
'with a project as subject'
do
let
(
:namespace
)
{
build
(
:namespace
,
name:
'foo3'
)
}
let
(
:another_project
)
{
build
(
:empty_project
,
namespace:
namespace
,
name:
'bar3'
)
}
it
'links to project issues page'
do
expect
(
link_to_label
(
label
,
subject:
another_project
)).
to
match
%r{<a href="/foo3/bar3/issues
\?
label_name%5B%5D=
#{
label
.
name
}
">.*</a>}
end
end
context
'with a
project argumen
t'
do
let
(
:
another_project
)
{
double
(
'project'
,
namespace:
'foo3'
,
to_param:
'bar3
'
)
}
context
'with a
group as subjec
t'
do
let
(
:
group
)
{
build
(
:group
,
name:
'bar
'
)
}
it
'links to
merge request
s page'
do
expect
(
link_to_label
(
label
,
project:
another_project
)).
to
match
%r{<a href="/foo3/bar3
/issues
\?
label_name%5B%5D=
#{
label
.
name
}
">.*</a>}
it
'links to
group issue
s page'
do
expect
(
link_to_label
(
label
,
subject:
group
)).
to
match
%r{<a href="/groups/bar
/issues
\?
label_name%5B%5D=
#{
label
.
name
}
">.*</a>}
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