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
593df8e6
Unverified
Commit
593df8e6
authored
Jul 30, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve labels
* allow developers to manage labels * add ability to remove label Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
cc331684
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
37 deletions
+76
-37
issues.scss
app/assets/stylesheets/sections/issues.scss
+1
-1
labels.scss
app/assets/stylesheets/sections/labels.scss
+4
-0
labels_controller.rb
app/controllers/projects/labels_controller.rb
+9
-4
labels_helper.rb
app/helpers/labels_helper.rb
+1
-1
ability.rb
app/models/ability.rb
+1
-1
label.rb
app/models/label.rb
+5
-0
_label.html.haml
app/views/projects/labels/_label.html.haml
+7
-1
filter_labels.feature
features/project/issues/filter_labels.feature
+13
-9
filter_labels.rb
features/steps/project/filter_labels.rb
+33
-17
labels.rb
features/steps/project/labels.rb
+2
-3
No files found.
app/assets/stylesheets/sections/issues.scss
View file @
593df8e6
...
...
@@ -94,7 +94,7 @@
}
}
.issue-show-labels
.label
{
.issue-show-labels
.
color-
label
{
padding
:
6px
10px
;
}
...
...
app/assets/stylesheets/sections/labels.scss
View file @
593df8e6
...
...
@@ -15,3 +15,7 @@
font-size
:
14px
;
}
}
.color-label
{
padding
:
3px
4px
;
}
app/controllers/projects/labels_controller.rb
View file @
593df8e6
class
Projects
::
LabelsController
<
Projects
::
ApplicationController
before_filter
:module_enabled
before_filter
:label
,
only:
[
:edit
,
:update
]
before_filter
:label
,
only:
[
:edit
,
:update
,
:destroy
]
before_filter
:authorize_labels!
before_filter
:authorize_admin_labels!
,
only:
[
:edit
,
:update
,
:new
,
:create
,
:destroy
]
before_filter
:authorize_admin_labels!
,
except:
[
:index
]
respond_to
:js
,
:html
def
index
@labels
=
@project
.
labels
@labels
=
@project
.
labels
.
order
(
'title ASC'
).
page
(
params
[
:page
]).
per
(
20
)
end
def
new
@label
=
@project
.
labels
.
new
end
def
create
...
...
@@ -48,6 +47,12 @@ class Projects::LabelsController < Projects::ApplicationController
end
end
def
destroy
@label
.
destroy
redirect_to
project_labels_path
(
@project
),
notice:
'Label was removed'
end
protected
def
module_enabled
...
...
app/helpers/labels_helper.rb
View file @
593df8e6
...
...
@@ -13,7 +13,7 @@ module LabelsHelper
text_color
=
"#FFF"
end
content_tag
:span
,
class:
'label'
,
style:
"background:
#{
label_color
}
;color:
#{
text_color
}
"
do
content_tag
:span
,
class:
'label
color-label
'
,
style:
"background:
#{
label_color
}
;color:
#{
text_color
}
"
do
label
.
name
end
end
...
...
app/models/ability.rb
View file @
593df8e6
...
...
@@ -142,6 +142,7 @@ class Ability
:write_wiki
,
:modify_issue
,
:admin_issue
,
:admin_label
,
:push_code
]
end
...
...
@@ -164,7 +165,6 @@ class Ability
:modify_merge_request
,
:admin_issue
,
:admin_milestone
,
:admin_label
,
:admin_project_snippet
,
:admin_team_member
,
:admin_merge_request
,
...
...
app/models/label.rb
View file @
593df8e6
class
Label
<
ActiveRecord
::
Base
belongs_to
:project
has_many
:label_links
,
dependent: :destroy
has_many
:issues
,
through: :label_links
,
source: :target
,
source_type:
'Issue'
validates
:color
,
format:
{
with:
/\A\#[0-9A-Fa-f]{6}+\Z/
},
allow_blank:
true
validates
:project
,
presence:
true
...
...
@@ -11,4 +12,8 @@ class Label < ActiveRecord::Base
def
name
title
end
def
open_issues_count
issues
.
opened
.
count
end
end
app/views/projects/labels/_label.html.haml
View file @
593df8e6
%li
=
render_colored_label
(
label
)
.pull-right
=
link_to
'Edit'
,
edit_project_label_path
(
@project
,
label
),
class:
'btn'
%strong
.append-right-20
=
link_to
project_issues_path
(
@project
,
label_name:
label
.
name
)
do
=
pluralize
label
.
open_issues_count
,
'open issue'
-
if
can?
current_user
,
:admin_label
,
@project
=
link_to
'Edit'
,
edit_project_label_path
(
@project
,
label
),
class:
'btn'
=
link_to
'Remove'
,
project_label_path
(
@project
,
label
),
class:
'btn btn-remove'
,
method: :delete
,
data:
{
confirm:
"Remove this label? Are you sure?"
}
features/project/issues/filter_labels.feature
View file @
593df8e6
...
...
@@ -2,9 +2,10 @@ Feature: Project Filter Labels
Background
:
Given
I sign in as a user
And
I own project
"Shop"
And project "Shop" has issue "Bugfix1" with tags
:
"bug",
"feature"
And project "Shop" has issue "Bugfix2" with tags
:
"bug",
"enhancement"
And project "Shop" has issue "Feature1" with tags
:
"feature"
And project "Shop" has labels
:
"bug",
"feature",
"enhancement"
And project "Shop" has issue "Bugfix1" with labels
:
"bug",
"feature"
And project "Shop" has issue "Bugfix2" with labels
:
"bug",
"enhancement"
And project "Shop" has issue "Feature1" with labels
:
"feature"
Given
I visit project
"Shop"
issues page
Scenario
:
I
should see project issues
...
...
@@ -18,9 +19,12 @@ Feature: Project Filter Labels
And
I should see
"Bugfix2"
in issues list
And
I should not see
"Feature1"
in issues list
Scenario
:
I
filter by two labels
Given
I click link
"bug"
And
I click link
"feature"
Then
I should see
"Bugfix1"
in issues list
And
I should not see
"Bugfix2"
in issues list
And
I should not see
"Feature1"
in issues list
# TODO: make labels filter works according to this scanario
# right now it looks for label 1 OR label 2. Old behaviour (this test) was
# all issues that have both label 1 AND label 2
#Scenario: I filter by two labels
#Given I click link "bug"
#And I click link "feature"
#Then I should see "Bugfix1" in issues list
#And I should not see "Bugfix2" in issues list
#And I should not see "Feature1" in issues list
features/steps/project/filter_labels.rb
View file @
593df8e6
...
...
@@ -3,68 +3,84 @@ class ProjectFilterLabels < Spinach::FeatureSteps
include
SharedProject
include
SharedPaths
Then
'I should see "bug" in labels filter'
do
step
'project "Shop" has labels: "bug", "feature", "enhancement"'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
create
(
:label
,
project:
project
,
title:
'bug'
)
create
(
:label
,
project:
project
,
title:
'feature'
)
create
(
:label
,
project:
project
,
title:
'enhancement'
)
end
step
'I should see "bug" in labels filter'
do
within
".labels-filter"
do
page
.
should
have_content
"bug"
end
end
And
'I should see "feature" in labels filter'
do
step
'I should see "feature" in labels filter'
do
within
".labels-filter"
do
page
.
should
have_content
"feature"
end
end
And
'I should see "enhancement" in labels filter'
do
step
'I should see "enhancement" in labels filter'
do
within
".labels-filter"
do
page
.
should
have_content
"enhancement"
end
end
Then
'I should see "Bugfix1" in issues list'
do
step
'I should see "Bugfix1" in issues list'
do
within
".issues-list"
do
page
.
should
have_content
"Bugfix1"
end
end
And
'I should see "Bugfix2" in issues list'
do
step
'I should see "Bugfix2" in issues list'
do
within
".issues-list"
do
page
.
should
have_content
"Bugfix2"
end
end
And
'I should not see "Bugfix2" in issues list'
do
step
'I should not see "Bugfix2" in issues list'
do
within
".issues-list"
do
page
.
should_not
have_content
"Bugfix2"
end
end
And
'I should not see "Feature1" in issues list'
do
step
'I should not see "Feature1" in issues list'
do
within
".issues-list"
do
page
.
should_not
have_content
"Feature1"
end
end
Given
'I click link "bug"'
do
click_link
"bug"
step
'I click link "bug"'
do
within
".labels-filter"
do
click_link
"bug"
end
end
Given
'I click link "feature"'
do
click_link
"feature"
step
'I click link "feature"'
do
within
".labels-filter"
do
click_link
"feature"
end
end
And
'project "Shop" has issue "Bugfix1" with tag
s: "bug", "feature"'
do
step
'project "Shop" has issue "Bugfix1" with label
s: "bug", "feature"'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
create
(
:issue
,
title:
"Bugfix1"
,
project:
project
,
label_list:
[
'bug'
,
'feature'
])
issue
=
create
(
:issue
,
title:
"Bugfix1"
,
project:
project
)
issue
.
labels
<<
project
.
labels
.
find_by
(
title:
'bug'
)
issue
.
labels
<<
project
.
labels
.
find_by
(
title:
'feature'
)
end
And
'project "Shop" has issue "Bugfix2" with tag
s: "bug", "enhancement"'
do
step
'project "Shop" has issue "Bugfix2" with label
s: "bug", "enhancement"'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
create
(
:issue
,
title:
"Bugfix2"
,
project:
project
,
label_list:
[
'bug'
,
'enhancement'
])
issue
=
create
(
:issue
,
title:
"Bugfix2"
,
project:
project
)
issue
.
labels
<<
project
.
labels
.
find_by
(
title:
'bug'
)
issue
.
labels
<<
project
.
labels
.
find_by
(
title:
'enhancement'
)
end
And
'project "Shop" has issue "Feature1" with tag
s: "feature"'
do
step
'project "Shop" has issue "Feature1" with label
s: "feature"'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
create
(
:issue
,
title:
"Feature1"
,
project:
project
,
label_list:
'feature'
)
issue
=
create
(
:issue
,
title:
"Feature1"
,
project:
project
)
issue
.
labels
<<
project
.
labels
.
find_by
(
title:
'feature'
)
end
end
features/steps/project/labels.rb
View file @
593df8e6
...
...
@@ -17,8 +17,7 @@ class ProjectLabels < Spinach::FeatureSteps
And
'project "Shop" have issues tags: "bug", "feature"'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
[
'bug'
,
'feature'
].
each
do
|
label
|
create
(
:issue
,
project:
project
,
label_list:
label
)
end
label1
=
create
(
:label
,
project:
project
,
title:
'bug'
)
label2
=
create
(
:label
,
project:
project
,
title:
'feature'
)
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