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
27c5f8bd
Commit
27c5f8bd
authored
Jun 20, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add label autocomplete for groups
parent
5e699c98
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
1 deletion
+31
-1
config/routes/group.rb
config/routes/group.rb
+1
-0
ee/app/controllers/groups/autocomplete_sources_controller.rb
ee/app/controllers/groups/autocomplete_sources_controller.rb
+4
-0
ee/app/helpers/ee/application_helper.rb
ee/app/helpers/ee/application_helper.rb
+1
-0
ee/app/services/groups/autocomplete_service.rb
ee/app/services/groups/autocomplete_service.rb
+24
-0
ee/spec/helpers/application_helper_spec.rb
ee/spec/helpers/application_helper_spec.rb
+1
-1
No files found.
config/routes/group.rb
View file @
27c5f8bd
...
...
@@ -90,6 +90,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resources
:autocomplete_sources
,
only:
[]
do
collection
do
get
'members'
get
'labels'
get
'epics'
end
end
...
...
ee/app/controllers/groups/autocomplete_sources_controller.rb
View file @
27c5f8bd
...
...
@@ -5,6 +5,10 @@ class Groups::AutocompleteSourcesController < Groups::ApplicationController
render
json:
::
Groups
::
ParticipantsService
.
new
(
@group
,
current_user
).
execute
(
target
)
end
def
labels
render
json:
@autocomplete_service
.
labels
(
target
)
end
def
epics
render
json:
@autocomplete_service
.
epics
end
...
...
ee/app/helpers/ee/application_helper.rb
View file @
27c5f8bd
...
...
@@ -67,6 +67,7 @@ module EE
{
members:
members_group_autocomplete_sources_path
(
object
,
type:
noteable_type
,
type_id:
params
[
:id
]),
labels:
labels_group_autocomplete_sources_path
(
object
),
epics:
epics_group_autocomplete_sources_path
(
object
)
}
end
...
...
ee/app/services/groups/autocomplete_service.rb
View file @
27c5f8bd
module
Groups
class
AutocompleteService
<
BaseService
def
labels
(
target
=
nil
)
labels
=
LabelsFinder
.
new
(
current_user
,
group_id:
group
.
id
,
include_ancestor_groups:
true
,
only_group_labels:
true
).
execute
.
select
([
:color
,
:title
])
return
labels
unless
target
&
.
respond_to?
(
:labels
)
issuable_label_titles
=
target
.
labels
.
pluck
(
:title
)
if
issuable_label_titles
labels
=
labels
.
as_json
(
only:
[
:title
,
:color
])
issuable_label_titles
.
each
do
|
issuable_label_title
|
found_label
=
labels
.
find
{
|
label
|
label
[
'title'
]
==
issuable_label_title
}
found_label
[
:set
]
=
true
if
found_label
end
end
labels
end
def
epics
EpicsFinder
.
new
(
current_user
,
group_id:
group
.
id
).
execute
end
...
...
ee/spec/helpers/application_helper_spec.rb
View file @
27c5f8bd
...
...
@@ -6,7 +6,7 @@ describe ApplicationHelper do
let
(
:noteable_type
)
{
Epic
}
it
'returns paths for autocomplete_sources_controller'
do
sources
=
helper
.
autocomplete_data_sources
(
object
,
noteable_type
)
expect
(
sources
.
keys
).
to
match_array
([
:members
])
expect
(
sources
.
keys
).
to
match_array
([
:members
,
:labels
,
:epics
])
sources
.
keys
.
each
do
|
key
|
expect
(
sources
[
key
]).
not_to
be_nil
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