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
Kazuhiko Shiozaki
gitlab-ce
Commits
4c575b72
Commit
4c575b72
authored
Jun 23, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move checking of recepients to a service.
parent
8f0051e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
35 deletions
+49
-35
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-29
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+1
-1
app/services/projects/participants_service.rb
app/services/projects/participants_service.rb
+43
-0
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+3
-5
No files found.
app/controllers/projects_controller.rb
View file @
4c575b72
...
...
@@ -124,18 +124,12 @@ class ProjectsController < ApplicationController
def
autocomplete_sources
note_type
=
params
[
'type'
]
note_id
=
params
[
'type_id'
]
participating
=
if
note_type
&&
note_id
participants_in
(
note_type
,
note_id
)
else
[]
end
team_members
=
sorted
(
@project
.
team
.
members
)
participants
=
[{
username:
"all"
,
name:
"Project and Group Members"
}]
+
team_members
+
participating
participants
=
::
Projects
::
ParticipantsService
.
new
(
@project
).
execute
(
note_type
,
note_id
)
@suggestions
=
{
emojis:
Emoji
.
names
.
map
{
|
e
|
{
name:
e
,
path:
view_context
.
image_url
(
"emoji/
#{
e
}
.png"
)
}
},
issues:
@project
.
issues
.
select
([
:iid
,
:title
,
:description
]),
mergerequests:
@project
.
merge_requests
.
select
([
:iid
,
:title
,
:description
]),
members:
participants
.
uniq
members:
participants
}
respond_to
do
|
format
|
...
...
@@ -191,25 +185,4 @@ class ProjectsController < ApplicationController
def
user_layout
current_user
?
"projects"
:
"public_projects"
end
def
participants_in
(
type
,
id
)
users
=
case
type
when
"Issue"
issue
=
@project
.
issues
.
find_by_iid
(
id
)
issue
?
issue
.
participants
:
[]
when
"MergeRequest"
merge_request
=
@project
.
merge_requests
.
find_by_iid
(
id
)
merge_request
?
merge_request
.
participants
:
[]
when
"Commit"
author_ids
=
Note
.
for_commit_id
(
id
).
pluck
(
:author_id
).
uniq
User
.
where
(
id:
author_ids
)
else
[]
end
sorted
(
users
)
end
def
sorted
(
users
)
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
{
|
user
|
{
username:
user
.
username
,
name:
user
.
name
}
}
end
end
app/models/concerns/mentionable.rb
View file @
4c575b72
...
...
@@ -55,7 +55,7 @@ module Mentionable
if
has_project
id
=
project
.
team
.
members
.
find_by
(
username:
identifier
).
try
(
:id
)
else
id
=
User
.
where
(
username:
identifier
).
pluck
(
:id
).
first
id
=
User
.
find_by
(
username:
identifier
).
try
(
:id
)
end
users
<<
User
.
find
(
id
)
unless
id
.
blank?
end
...
...
app/services/projects/participants_service.rb
0 → 100644
View file @
4c575b72
module
Projects
class
ParticipantsService
<
BaseService
def
initialize
(
project
)
@project
=
project
end
def
execute
(
note_type
,
note_id
)
participating
=
if
note_type
&&
note_id
participants_in
(
note_type
,
note_id
)
else
[]
end
team_members
=
sorted
(
@project
.
team
.
members
)
participants
=
all_members
+
team_members
+
participating
participants
.
uniq
end
def
participants_in
(
type
,
id
)
users
=
case
type
when
"Issue"
issue
=
@project
.
issues
.
find_by_iid
(
id
)
issue
?
issue
.
participants
:
[]
when
"MergeRequest"
merge_request
=
@project
.
merge_requests
.
find_by_iid
(
id
)
merge_request
?
merge_request
.
participants
:
[]
when
"Commit"
author_ids
=
Note
.
for_commit_id
(
id
).
pluck
(
:author_id
).
uniq
User
.
where
(
id:
author_ids
)
else
[]
end
sorted
(
users
)
end
def
sorted
(
users
)
users
.
uniq
.
to_a
.
compact
.
sort_by
(
&
:username
).
map
{
|
user
|
{
username:
user
.
username
,
name:
user
.
name
}
}
end
def
all_members
[{
username:
"all"
,
name:
"Project and Group Members"
}]
end
end
end
lib/gitlab/markdown.rb
View file @
4c575b72
...
...
@@ -169,15 +169,13 @@ module Gitlab
end
def
reference_user
(
identifier
,
project
=
@project
)
if
identifier
==
"all"
options
=
html_options
.
merge
(
options
=
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
)
if
identifier
==
"all"
link_to
(
"@all"
,
project_url
(
project
),
options
)
elsif
user
=
User
.
find_by
(
username:
identifier
)
options
=
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
)
link_to
(
"@
#{
identifier
}
"
,
user_url
(
identifier
),
options
)
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