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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
fd3d60de
Commit
fd3d60de
authored
Sep 03, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add search to group labels page [ci skip]
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
471c799b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
9 deletions
+71
-9
app/controllers/groups/labels_controller.rb
app/controllers/groups/labels_controller.rb
+3
-3
app/views/groups/labels/index.html.haml
app/views/groups/labels/index.html.haml
+20
-6
spec/features/groups/labels/search_labels_spec.rb
spec/features/groups/labels/search_labels_spec.rb
+48
-0
No files found.
app/controllers/groups/labels_controller.rb
View file @
fd3d60de
...
@@ -11,7 +11,7 @@ class Groups::LabelsController < Groups::ApplicationController
...
@@ -11,7 +11,7 @@ class Groups::LabelsController < Groups::ApplicationController
def
index
def
index
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
@labels
=
@
group
.
labels
.
page
(
params
[
:page
])
@labels
=
@
available_
labels
.
page
(
params
[
:page
])
end
end
format
.
json
do
format
.
json
do
render
json:
LabelSerializer
.
new
.
represent_appearance
(
@available_labels
)
render
json:
LabelSerializer
.
new
.
represent_appearance
(
@available_labels
)
...
@@ -113,7 +113,7 @@ class Groups::LabelsController < Groups::ApplicationController
...
@@ -113,7 +113,7 @@ class Groups::LabelsController < Groups::ApplicationController
group_id:
@group
.
id
,
group_id:
@group
.
id
,
only_group_labels:
params
[
:only_group_labels
],
only_group_labels:
params
[
:only_group_labels
],
include_ancestor_groups:
params
[
:include_ancestor_groups
],
include_ancestor_groups:
params
[
:include_ancestor_groups
],
include_descendant_groups:
params
[
:include_descendant_groups
]
include_descendant_groups:
params
[
:include_descendant_groups
]
,
).
execute
search:
params
[
:search
]
).
execute
end
end
end
end
app/views/groups/labels/index.html.haml
View file @
fd3d60de
-
page_title
'Labels'
-
page_title
'Labels'
-
can_admin_label
=
can?
(
current_user
,
:admin_label
,
@group
)
-
can_admin_label
=
can?
(
current_user
,
:admin_label
,
@group
)
-
hide
=
@available_labels
.
empty?
||
(
params
[
:page
].
present?
&&
params
[
:page
]
!=
'1'
)
-
issuables
=
[
'issues'
,
'merge requests'
]
+
(
@group
&
.
feature_available?
(
:epics
)
?
[
'epics'
]
:
[])
-
issuables
=
[
'issues'
,
'merge requests'
]
+
(
@group
&
.
feature_available?
(
:epics
)
?
[
'epics'
]
:
[])
-
search
=
params
[
:search
]
-
if
can_admin_label
-
if
can_admin_label
-
content_for
(
:header_content
)
do
-
content_for
(
:header_content
)
do
.nav-controls
.nav-controls
=
link_to
_
(
'New label'
),
new_group_label_path
(
@group
),
class:
"btn btn-new"
=
link_to
_
(
'New label'
),
new_group_label_path
(
@group
),
class:
"btn btn-new"
-
if
@labels
.
exists?
-
if
@labels
.
exists?
||
search
.
present?
#promote-label-modal
#promote-label-modal
%div
{
class:
container_class
}
%div
{
class:
container_class
}
.top-area.adjust
.top-area.adjust
.nav-text
.nav-text
=
_
(
'Labels can be applied to %{features}. Group labels are available for any project within the group.'
)
%
{
features:
issuables
.
to_sentence
}
=
_
(
'Labels can be applied to %{features}. Group labels are available for any project within the group.'
)
%
{
features:
issuables
.
to_sentence
}
.nav-controls
=
form_tag
group_labels_path
(
@group
),
method: :get
do
.input-group
=
search_field_tag
:search
,
params
[
:search
],
{
placeholder:
_
(
'Filter'
),
id:
'label-search'
,
class:
'form-control search-text-input input-short'
,
spellcheck:
false
}
%span
.input-group-append
%button
.btn.btn-default
{
type:
"submit"
,
"aria-label"
=>
_
(
'Submit search'
)
}
=
icon
(
"search"
)
.labels-container.prepend-top-5
.labels-container.prepend-top-5
.other-labels
-
if
@labels
.
any?
%h5
Labels
.other-labels
%ul
.content-list.manage-labels-list.js-other-labels
-
if
can_admin_label
=
render
partial:
'shared/label'
,
subject:
@group
,
collection:
@labels
,
as: :label
,
locals:
{
use_label_priority:
false
}
%h5
{
class:
(
'hide'
if
hide
)
}
Labels
=
paginate
@labels
,
theme:
'gitlab'
%ul
.content-list.manage-labels-list.js-other-labels
=
render
partial:
'shared/label'
,
subject:
@group
,
collection:
@labels
,
as: :label
,
locals:
{
use_label_priority:
false
}
=
paginate
@labels
,
theme:
'gitlab'
-
elsif
search
.
present?
.nothing-here-block
=
_
(
'No labels with such name or description'
)
-
else
-
else
=
render
'shared/empty_states/labels'
=
render
'shared/empty_states/labels'
...
...
spec/features/groups/labels/search_labels_spec.rb
0 → 100644
View file @
fd3d60de
# frozen_string_literal: true
require
'spec_helper'
describe
'Search for labels'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let!
(
:label1
)
{
create
(
:group_label
,
title:
'Foo'
,
description:
'Lorem ipsum'
,
group:
group
)
}
let!
(
:label2
)
{
create
(
:group_label
,
title:
'Bar'
,
description:
'Fusce consequat'
,
group:
group
)
}
before
do
group
.
add_maintainer
(
user
)
sign_in
(
user
)
visit
group_labels_path
(
group
)
end
it
'searches for label by title'
do
fill_in
'label-search'
,
with:
'Bar'
find
(
'#label-search'
).
native
.
send_keys
(
:enter
)
expect
(
page
).
to
have_content
(
label2
.
title
)
expect
(
page
).
to
have_content
(
label2
.
description
)
expect
(
page
).
not_to
have_content
(
label1
.
title
)
expect
(
page
).
not_to
have_content
(
label1
.
description
)
end
it
'searches for label by description'
do
fill_in
'label-search'
,
with:
'Lorem'
find
(
'#label-search'
).
native
.
send_keys
(
:enter
)
expect
(
page
).
to
have_content
(
label1
.
title
)
expect
(
page
).
to
have_content
(
label1
.
description
)
expect
(
page
).
not_to
have_content
(
label2
.
title
)
expect
(
page
).
not_to
have_content
(
label2
.
description
)
end
it
'shows nothing found message'
do
fill_in
'label-search'
,
with:
'nonexistent'
find
(
'#label-search'
).
native
.
send_keys
(
:enter
)
expect
(
page
).
to
have_content
(
'No labels with such name or description'
)
expect
(
page
).
not_to
have_content
(
label1
.
title
)
expect
(
page
).
not_to
have_content
(
label1
.
description
)
expect
(
page
).
not_to
have_content
(
label2
.
title
)
expect
(
page
).
not_to
have_content
(
label2
.
description
)
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