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
Boxiang Sun
gitlab-ce
Commits
55734453
Commit
55734453
authored
Mar 08, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helpers for labels dropdown
parent
afd2d381
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
0 deletions
+105
-0
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+33
-0
spec/helpers/labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+72
-0
No files found.
app/helpers/labels_helper.rb
View file @
55734453
...
...
@@ -174,6 +174,39 @@ module LabelsHelper
end
end
def
create_label_title
(
subject
)
case
subject
when
Group
_
(
'Create group label'
)
when
Project
_
(
'Create project label'
)
else
_
(
'Create new label'
)
end
end
def
manage_labels_title
(
subject
)
case
subject
when
Group
_
(
'Manage group labels'
)
when
Project
_
(
'Manage project labels'
)
else
_
(
'Manage labels'
)
end
end
def
view_labels_title
(
subject
)
case
subject
when
Group
_
(
'View group labels'
)
when
Project
_
(
'View project labels'
)
else
_
(
'View labels'
)
end
end
# Required for Banzai::Filter::LabelReferenceFilter
module_function
:render_colored_label
,
:text_color_for_bg
,
:escape_once
end
spec/helpers/labels_helper_spec.rb
View file @
55734453
...
...
@@ -139,4 +139,76 @@ describe LabelsHelper do
expect
(
text_color_for_bg
(
'#000'
)).
to
eq
'#FFFFFF'
end
end
describe
'create_label_title'
do
set
(
:group
)
{
create
(
:group
)
}
context
'with a group as subject'
do
it
'returns "Create group label"'
do
expect
(
create_label_title
(
group
)).
to
eq
'Create group label'
end
end
context
'with a project as subject'
do
set
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
it
'returns "Create project label"'
do
expect
(
create_label_title
(
project
)).
to
eq
'Create project label'
end
end
context
'with no subject'
do
it
'returns "Create new label"'
do
expect
(
create_label_title
(
nil
)).
to
eq
'Create new label'
end
end
end
describe
'manage_labels_title'
do
set
(
:group
)
{
create
(
:group
)
}
context
'with a group as subject'
do
it
'returns "Manage group labels"'
do
expect
(
manage_labels_title
(
group
)).
to
eq
'Manage group labels'
end
end
context
'with a project as subject'
do
set
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
it
'returns "Manage project labels"'
do
expect
(
manage_labels_title
(
project
)).
to
eq
'Manage project labels'
end
end
context
'with no subject'
do
it
'returns "Manage labels"'
do
expect
(
manage_labels_title
(
nil
)).
to
eq
'Manage labels'
end
end
end
describe
'view_labels_title'
do
set
(
:group
)
{
create
(
:group
)
}
context
'with a group as subject'
do
it
'returns "View group labels"'
do
expect
(
view_labels_title
(
group
)).
to
eq
'View group labels'
end
end
context
'with a project as subject'
do
set
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
it
'returns "View project labels"'
do
expect
(
view_labels_title
(
project
)).
to
eq
'View project labels'
end
end
context
'with no subject'
do
it
'returns "View labels"'
do
expect
(
view_labels_title
(
nil
)).
to
eq
'View labels'
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