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
Kazuhiko Shiozaki
gitlab-ce
Commits
7183a7da
Commit
7183a7da
authored
Feb 25, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional text prefix in cross project labels
parent
a472c1bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+9
-3
app/models/label.rb
app/models/label.rb
+2
-1
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+6
-2
No files found.
app/helpers/labels_helper.rb
View file @
7183a7da
...
...
@@ -50,7 +50,7 @@ module LabelsHelper
@project
.
labels
.
pluck
(
:title
)
end
def
render_colored_label
(
label
)
def
render_colored_label
(
label
,
label_prefix
=
''
)
label_color
=
label
.
color
||
Label
::
DEFAULT_COLOR
text_color
=
text_color_for_bg
(
label_color
)
...
...
@@ -58,11 +58,16 @@ module LabelsHelper
# by LabelReferenceFilter
span
=
%(<span class="label color-label")
+
%( style="background-color: #{label_color}; color: #{text_color}">)
+
escape_once
(
label
.
name
)
+
'</span>'
label_prefix
+
escape_once
(
label
.
name
)
+
'</span>'
span
.
html_safe
end
def
render_colored_cross_project_label
(
label
)
label_prefix
=
"
#{
label
.
project
.
path_with_namespace
}
» "
render_colored_label
(
label
,
label_prefix
)
end
def
suggested_colors
[
'#0033CC'
,
...
...
@@ -119,5 +124,6 @@ module LabelsHelper
end
# Required for Banzai::Filter::LabelReferenceFilter
module_function
:render_colored_label
,
:text_color_for_bg
,
:escape_once
module_function
:render_colored_label
,
:render_colored_cross_project_label
,
:text_color_for_bg
,
:escape_once
end
app/models/label.rb
View file @
7183a7da
...
...
@@ -67,6 +67,7 @@ class Label < ActiveRecord::Base
nil
end
##
# Returns the String necessary to reference this Label in Markdown
#
# format - Symbol format to use (default: :id, optional: :name)
...
...
@@ -78,6 +79,7 @@ class Label < ActiveRecord::Base
# Label.first.to_reference(project) # => "gitlab-org/gitlab-ce~1"
#
# Returns a String
#
def
to_reference
(
from_project
=
nil
,
format: :id
)
reference
=
label_format_reference
(
format
)
...
...
@@ -88,7 +90,6 @@ class Label < ActiveRecord::Base
end
end
def
open_issues_count
issues
.
opened
.
count
end
...
...
lib/banzai/filter/label_reference_filter.rb
View file @
7183a7da
...
...
@@ -40,8 +40,12 @@ module Banzai
only_path:
context
[
:only_path
])
end
def
object_link_text
(
object
,
_matches
)
LabelsHelper
.
render_colored_label
(
object
)
def
object_link_text
(
object
,
matches
)
if
context
[
:project
]
==
object
.
project
LabelsHelper
.
render_colored_label
(
object
)
else
LabelsHelper
.
render_colored_cross_project_label
(
object
)
end
end
# Parameters to pass to `Label.find_by` based on the given arguments
...
...
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