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
9b95fe78
Commit
9b95fe78
authored
Jul 28, 2018
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move finding autocompletion targets into AutocompleteService
parent
19f97d2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
app/controllers/projects/autocomplete_sources_controller.rb
app/controllers/projects/autocomplete_sources_controller.rb
+2
-9
app/services/projects/autocomplete_service.rb
app/services/projects/autocomplete_service.rb
+11
-0
No files found.
app/controllers/projects/autocomplete_sources_controller.rb
View file @
9b95fe78
class
Projects::AutocompleteSourcesController
<
Projects
::
ApplicationController
before_action
:load_autocomplete_service
,
except:
[
:members
]
before_action
:load_autocomplete_service
def
members
render
json:
::
Projects
::
ParticipantsService
.
new
(
@project
,
current_user
).
execute
(
target
)
...
...
@@ -32,13 +32,6 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController
end
def
target
case
params
[
:type
]
&
.
downcase
when
'issue'
IssuesFinder
.
new
(
current_user
,
project_id:
@project
.
id
).
find_by
(
iid:
params
[
:type_id
])
||
@project
.
issues
.
build
when
'mergerequest'
MergeRequestsFinder
.
new
(
current_user
,
project_id:
@project
.
id
).
find_by
(
iid:
params
[
:type_id
])
||
@project
.
merge_requests
.
build
when
'commit'
@project
.
commit
(
params
[
:type_id
])
end
@autocomplete_service
.
target
(
params
[
:type
],
params
[
:type_id
])
end
end
app/services/projects/autocomplete_service.rb
View file @
9b95fe78
...
...
@@ -51,5 +51,16 @@ module Projects
QuickActions
::
InterpretService
.
new
(
project
,
current_user
).
available_commands
(
noteable
)
end
def
target
(
type
,
type_id
)
case
type
&
.
downcase
when
'issue'
IssuesFinder
.
new
(
current_user
,
project_id:
project
.
id
).
find_by
(
iid:
type_id
)
||
project
.
issues
.
build
when
'mergerequest'
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
find_by
(
iid:
type_id
)
||
project
.
merge_requests
.
build
when
'commit'
project
.
commit
(
type_id
)
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