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
62dcdef9
Commit
62dcdef9
authored
Feb 26, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve cross project label look and feel
parent
7183a7da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+6
-5
spec/lib/banzai/filter/label_reference_filter_spec.rb
spec/lib/banzai/filter/label_reference_filter_spec.rb
+8
-2
No files found.
app/helpers/labels_helper.rb
View file @
62dcdef9
...
@@ -50,22 +50,23 @@ module LabelsHelper
...
@@ -50,22 +50,23 @@ module LabelsHelper
@project
.
labels
.
pluck
(
:title
)
@project
.
labels
.
pluck
(
:title
)
end
end
def
render_colored_label
(
label
,
label_
pre
fix
=
''
)
def
render_colored_label
(
label
,
label_
suf
fix
=
''
)
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
)
# Intentionally not using content_tag here so that this method can be called
# Intentionally not using content_tag here so that this method can be called
# 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}">)
+
label_prefix
+
escape_once
(
label
.
name
)
+
'</span>'
%(#{escape_once(label.name)}#{label_suffix}</span>)
span
.
html_safe
span
.
html_safe
end
end
def
render_colored_cross_project_label
(
label
)
def
render_colored_cross_project_label
(
label
)
label_prefix
=
"
#{
label
.
project
.
path_with_namespace
}
» "
label_suffix
=
label
.
project
.
name
render_colored_label
(
label
,
label_prefix
)
label_suffix
=
" <i>«
#{
label_suffix
}
</i>"
render_colored_label
(
label
,
label_suffix
)
end
end
def
suggested_colors
def
suggested_colors
...
...
spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
62dcdef9
...
@@ -178,7 +178,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
...
@@ -178,7 +178,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
end
describe
'cross project label references'
do
describe
'cross project label references'
do
let
(
:another_project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:project_name
)
{
'Some project'
}
let
(
:another_project
)
{
create
(
:empty_project
,
:public
,
name:
project_name
)
}
let
(
:label
)
{
create
(
:label
,
project:
another_project
,
color:
'#00ff00'
)
}
let
(
:label
)
{
create
(
:label
,
project:
another_project
,
color:
'#00ff00'
)
}
let
(
:reference
)
{
label
.
to_reference
(
project
)
}
let
(
:reference
)
{
label
.
to_reference
(
project
)
}
...
@@ -192,7 +193,12 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
...
@@ -192,7 +193,12 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
end
it
'has valid color'
do
it
'has valid color'
do
expect
(
result
.
css
(
'a span'
).
first
.
attr
(
'style'
)).
to
match
/background-color: #00ff00/
expect
(
result
.
css
(
'a span'
).
first
.
attr
(
'style'
))
.
to
match
/background-color: #00ff00/
end
it
'contains cross project content'
do
expect
(
result
.
css
(
'a'
).
first
.
text
).
to
eq
"
#{
label
.
name
}
«
#{
project_name
}
"
end
end
end
end
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