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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
476c26de
Commit
476c26de
authored
Sep 20, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace label references with links for group labels
parent
7f2e29ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+13
-3
No files found.
lib/banzai/filter/label_reference_filter.rb
View file @
476c26de
...
@@ -9,7 +9,7 @@ module Banzai
...
@@ -9,7 +9,7 @@ module Banzai
end
end
def
find_object
(
project
,
id
)
def
find_object
(
project
,
id
)
project
.
labels
.
find
(
id
)
find_labels
(
project
)
.
find
(
id
)
end
end
def
self
.
references_in
(
text
,
pattern
=
Label
.
reference_pattern
)
def
self
.
references_in
(
text
,
pattern
=
Label
.
reference_pattern
)
...
@@ -35,7 +35,17 @@ module Banzai
...
@@ -35,7 +35,17 @@ module Banzai
return
unless
project
return
unless
project
label_params
=
label_params
(
label_id
,
label_name
)
label_params
=
label_params
(
label_id
,
label_name
)
project
.
labels
.
find_by
(
label_params
)
find_labels
(
project
).
find_by
(
label_params
)
end
def
find_labels
(
project
)
label_ids
=
[]
label_ids
<<
project
.
group
.
labels
.
select
(
:id
)
if
project
.
group
.
present?
label_ids
<<
project
.
labels
.
select
(
:id
)
union
=
Gitlab
::
SQL
::
Union
.
new
(
label_ids
)
object_class
.
where
(
"labels.id IN (
#{
union
.
to_sql
}
)"
)
end
end
# Parameters to pass to `Label.find_by` based on the given arguments
# Parameters to pass to `Label.find_by` based on the given arguments
...
@@ -60,7 +70,7 @@ module Banzai
...
@@ -60,7 +70,7 @@ module Banzai
end
end
def
object_link_text
(
object
,
matches
)
def
object_link_text
(
object
,
matches
)
if
context
[
:project
]
==
object
.
project
if
object
.
project
.
nil?
||
object
.
project
==
context
[
:project
]
LabelsHelper
.
render_colored_label
(
object
)
LabelsHelper
.
render_colored_label
(
object
)
else
else
LabelsHelper
.
render_colored_cross_project_label
(
object
)
LabelsHelper
.
render_colored_cross_project_label
(
object
)
...
...
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