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
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
...
@@ -50,7 +50,7 @@ module LabelsHelper
@project
.
labels
.
pluck
(
:title
)
@project
.
labels
.
pluck
(
:title
)
end
end
def
render_colored_label
(
label
)
def
render_colored_label
(
label
,
label_prefix
=
''
)
label_color
=
label
.
color
||
Label
::
DEFAULT_COLOR
label_color
=
label
.
color
||
Label
::
DEFAULT_COLOR
text_color
=
text_color_for_bg
(
label_color
)
text_color
=
text_color_for_bg
(
label_color
)
...
@@ -58,11 +58,16 @@ module LabelsHelper
...
@@ -58,11 +58,16 @@ module LabelsHelper
# by LabelReferenceFilter
# by LabelReferenceFilter
span
=
%(<span class="label color-label")
+
span
=
%(<span class="label color-label")
+
%( style="background-color: #{label_color}; color: #{text_color}">)
+
%( style="background-color: #{label_color}; color: #{text_color}">)
+
escape_once
(
label
.
name
)
+
'</span>'
label_prefix
+
escape_once
(
label
.
name
)
+
'</span>'
span
.
html_safe
span
.
html_safe
end
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
def
suggested_colors
[
[
'#0033CC'
,
'#0033CC'
,
...
@@ -119,5 +124,6 @@ module LabelsHelper
...
@@ -119,5 +124,6 @@ module LabelsHelper
end
end
# Required for Banzai::Filter::LabelReferenceFilter
# 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
end
app/models/label.rb
View file @
7183a7da
...
@@ -67,6 +67,7 @@ class Label < ActiveRecord::Base
...
@@ -67,6 +67,7 @@ class Label < ActiveRecord::Base
nil
nil
end
end
##
# Returns the String necessary to reference this Label in Markdown
# Returns the String necessary to reference this Label in Markdown
#
#
# format - Symbol format to use (default: :id, optional: :name)
# format - Symbol format to use (default: :id, optional: :name)
...
@@ -78,6 +79,7 @@ class Label < ActiveRecord::Base
...
@@ -78,6 +79,7 @@ class Label < ActiveRecord::Base
# Label.first.to_reference(project) # => "gitlab-org/gitlab-ce~1"
# Label.first.to_reference(project) # => "gitlab-org/gitlab-ce~1"
#
#
# Returns a String
# Returns a String
#
def
to_reference
(
from_project
=
nil
,
format: :id
)
def
to_reference
(
from_project
=
nil
,
format: :id
)
reference
=
label_format_reference
(
format
)
reference
=
label_format_reference
(
format
)
...
@@ -88,7 +90,6 @@ class Label < ActiveRecord::Base
...
@@ -88,7 +90,6 @@ class Label < ActiveRecord::Base
end
end
end
end
def
open_issues_count
def
open_issues_count
issues
.
opened
.
count
issues
.
opened
.
count
end
end
...
...
lib/banzai/filter/label_reference_filter.rb
View file @
7183a7da
...
@@ -40,8 +40,12 @@ module Banzai
...
@@ -40,8 +40,12 @@ module Banzai
only_path:
context
[
:only_path
])
only_path:
context
[
:only_path
])
end
end
def
object_link_text
(
object
,
_matches
)
def
object_link_text
(
object
,
matches
)
LabelsHelper
.
render_colored_label
(
object
)
if
context
[
:project
]
==
object
.
project
LabelsHelper
.
render_colored_label
(
object
)
else
LabelsHelper
.
render_colored_cross_project_label
(
object
)
end
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
...
...
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