BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b2a6f4e1
Unverified
Commit
b2a6f4e1
authored
Jul 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor label rendering and default label set generation
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d79c0ea2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
65 deletions
+44
-65
labels_controller.rb
app/controllers/projects/labels_controller.rb
+1
-1
labels_helper.rb
app/helpers/labels_helper.rb
+11
-19
_issue.html.haml
app/views/projects/issues/_issue.html.haml
+1
-3
show.html.haml
app/views/projects/issues/show.html.haml
+1
-4
_merge_request.html.haml
app/views/projects/merge_requests/_merge_request.html.haml
+1
-3
_participants.html.haml
...iews/projects/merge_requests/show/_participants.html.haml
+1
-4
_project_filter.html.haml
app/views/shared/_project_filter.html.haml
+10
-12
issues_labels.rb
lib/gitlab/issues_labels.rb
+18
-19
No files found.
app/controllers/projects/labels_controller.rb
View file @
b2a6f4e1
...
...
@@ -6,7 +6,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to
:js
,
:html
def
index
@labels
=
@project
.
issues_
labels
@labels
=
@project
.
labels
end
def
generate
...
...
app/helpers/labels_helper.rb
View file @
b2a6f4e1
module
LabelsHelper
def
issue
_label_names
def
project
_label_names
@project
.
labels
.
pluck
(
:title
)
end
def
labels_autocomplete_source
labels
=
@project
.
labels
labels
=
labels
.
map
{
|
l
|
{
label:
l
.
name
,
value:
l
.
name
}
}
labels
.
to_json
end
def
label_css_class
(
name
)
klass
=
Gitlab
::
IssuesLabels
def
render_colored_label
(
label
)
label_color
=
label
.
color
||
"#428bca"
r
,
g
,
b
=
label_color
.
slice
(
1
,
7
).
scan
(
/.{2}/
).
map
(
&
:hex
)
case
name
.
downcase
when
*
klass
.
warning_labels
'label-warning'
when
*
klass
.
neutral_labels
'label-primary'
when
*
klass
.
positive_labels
'label-success'
when
*
klass
.
important_labels
'label-danger'
if
(
r
+
g
+
b
)
>
500
text_color
=
"#333"
else
'label-info'
text_color
=
"#FFF"
end
content_tag
:span
,
class:
'label'
,
style:
"background:
#{
label_color
}
;color:
#{
text_color
}
"
do
label
.
name
end
end
end
app/views/projects/issues/_issue.html.haml
View file @
b2a6f4e1
...
...
@@ -31,9 +31,7 @@
.issue-labels
-
issue
.
labels
.
each
do
|
label
|
%span
{
class:
"label #{label_css_class(label.name)}"
}
%i
.icon-tag
=
label
.
name
=
render_colored_label
(
label
)
.issue-actions
-
if
can?
current_user
,
:modify_issue
,
issue
...
...
app/views/projects/issues/show.html.haml
View file @
b2a6f4e1
...
...
@@ -68,9 +68,6 @@
.issue-show-labels.pull-right
-
@issue
.
labels
.
each
do
|
label
|
%span
{
class:
"label #{label_css_class(label.name)}"
}
%i
.icon-tag
=
label
.
name
=
render_colored_label
(
label
)
.voting_notes
#notes
=
render
"projects/notes/notes_with_form"
app/views/projects/merge_requests/_merge_request.html.haml
View file @
b2a6f4e1
...
...
@@ -34,6 +34,4 @@
.merge-request-labels
-
merge_request
.
labels
.
each
do
|
label
|
%span
{
class:
"label #{label_css_class(label.name)}"
}
%i
.icon-tag
=
label
.
name
=
render_colored_label
(
label
)
app/views/projects/merge_requests/show/_participants.html.haml
View file @
b2a6f4e1
...
...
@@ -5,7 +5,4 @@
.merge-request-show-labels.pull-right
-
@merge_request
.
labels
.
each
do
|
label
|
%span
{
class:
"label #{label_css_class(label.name)}"
}
%i
.icon-tag
=
label
.
name
=
render_colored_label
(
label
)
app/views/shared/_project_filter.html.haml
View file @
b2a6f4e1
...
...
@@ -36,21 +36,19 @@
%fieldset
%legend
Labels
%ul
.nav.nav-pills.nav-stacked.nav-small.labels-filter
-
issue_label_names
.
each
do
|
label_name
|
%li
{
class:
label_filter_class
(
label_name
)}
=
link_to
labels_filter_path
(
label_name
)
do
%span
{
class:
"label #{label_css_class(label_name)}"
}
%i
.icon-tag
=
label_name
-
if
selected_label?
(
label_name
)
-
@project
.
labels
.
each
do
|
label
|
%li
{
class:
label_filter_class
(
label
.
name
)}
=
link_to
labels_filter_path
(
label
.
name
)
do
=
render_colored_label
(
label
)
-
if
selected_label?
(
label
.
name
)
.pull-right
%i
.icon-remove
-
if
issue_label_name
s
.
empty?
.light-well
Add first label to your issues
%br
or
#{
link_to
'generate'
,
generate_project_labels_path
(
@project
,
redirect:
redirect
),
method: :post
}
default set of labels
-
if
@project
.
label
s
.
empty?
.light-well
Add first label to your issues
%br
or
#{
link_to
'generate'
,
generate_project_labels_path
(
@project
,
redirect:
redirect
),
method: :post
}
default set of labels
%fieldset
-
if
%w(state scope milestone_id assignee_id label_name)
.
select
{
|
k
|
params
[
k
].
present?
}.
any?
...
...
lib/gitlab/issues_labels.rb
View file @
b2a6f4e1
module
Gitlab
class
IssuesLabels
class
<<
self
def
important_labels
%w(bug critical confirmed)
end
def
warning_labels
%w(documentation support)
end
def
neutral_labels
%w(discussion suggestion)
end
def
positive_labels
%w(feature enhancement)
end
def
generate
(
project
)
label_names
=
important_labels
+
warning_labels
+
neutral_labels
+
positive_labels
red
=
'#d9534f'
yellow
=
'#f0ad4e'
blue
=
'#428bca'
green
=
'#5cb85c'
labels
=
[
{
title:
"bug"
,
color:
red
},
{
title:
"critical"
,
color:
red
},
{
title:
"confirmed"
,
color:
red
},
{
title:
"documentation"
,
color:
yellow
},
{
title:
"support"
,
color:
yellow
},
{
title:
"discussion"
,
color:
blue
},
{
title:
"suggestion"
,
color:
blue
},
{
title:
"feature"
,
color:
green
},
{
title:
"enhancement"
,
color:
green
}
]
label
_names
.
each
do
|
label_name
|
project
.
labels
.
create
(
title:
label_name
)
label
s
.
each
do
|
label
|
project
.
labels
.
create
(
label
)
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