Commit eb7a9868002a3d96675a1509d75be52cfe43fa2f
Exists in
spb-stable
and in
3 other branches
Merge branch 'improve_at_mentions' into 'master'
Allow at mentions for people who are not members of the project
Showing
5 changed files
with
44 additions
and
5 deletions
Show diff stats
CHANGELOG
1 | +v 6.8.0 | ||
2 | + - Ability to at mention users that are participating in issue and merge req. discussion | ||
3 | + | ||
4 | +v 6.7.2 | ||
5 | + - Fix upgrader script | ||
6 | + | ||
7 | +v 6.7.1 | ||
8 | + - Fix GitLab CI integration | ||
9 | + | ||
1 | v 6.7.0 | 10 | v 6.7.0 |
2 | - Increased the example Nginx client_max_body_size from 5MB to 20MB, consider updating it manually on existing installations | 11 | - Increased the example Nginx client_max_body_size from 5MB to 20MB, consider updating it manually on existing installations |
3 | - Add support for Gemnasium as a Project Service (Olivier Gonzalez) | 12 | - Add support for Gemnasium as a Project Service (Olivier Gonzalez) |
VERSION
app/controllers/projects_controller.rb
@@ -123,11 +123,20 @@ class ProjectsController < ApplicationController | @@ -123,11 +123,20 @@ class ProjectsController < ApplicationController | ||
123 | end | 123 | end |
124 | 124 | ||
125 | def autocomplete_sources | 125 | def autocomplete_sources |
126 | + note_type = params['type'] | ||
127 | + note_id = params['type_id'] | ||
128 | + participating = if note_type && note_id | ||
129 | + participants_in(note_type, note_id) | ||
130 | + else | ||
131 | + [] | ||
132 | + end | ||
133 | + team_members = sorted(@project.team.members) | ||
134 | + participants = team_members + participating | ||
126 | @suggestions = { | 135 | @suggestions = { |
127 | emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, | 136 | emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, |
128 | issues: @project.issues.select([:iid, :title, :description]), | 137 | issues: @project.issues.select([:iid, :title, :description]), |
129 | mergerequests: @project.merge_requests.select([:iid, :title, :description]), | 138 | mergerequests: @project.merge_requests.select([:iid, :title, :description]), |
130 | - members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } | 139 | + members: participants.uniq |
131 | } | 140 | } |
132 | 141 | ||
133 | respond_to do |format| | 142 | respond_to do |format| |
@@ -162,4 +171,25 @@ class ProjectsController < ApplicationController | @@ -162,4 +171,25 @@ class ProjectsController < ApplicationController | ||
162 | def user_layout | 171 | def user_layout |
163 | current_user ? "projects" : "public_projects" | 172 | current_user ? "projects" : "public_projects" |
164 | end | 173 | end |
174 | + | ||
175 | + def participants_in(type, id) | ||
176 | + users = case type | ||
177 | + when "Issue" | ||
178 | + issue = @project.issues.find_by_iid(id) | ||
179 | + issue ? issue.participants : [] | ||
180 | + when "MergeRequest" | ||
181 | + merge_request = @project.merge_requests.find_by_iid(id) | ||
182 | + merge_request ? merge_request.participants : [] | ||
183 | + when "Commit" | ||
184 | + author_ids = Note.for_commit_id(id).pluck(:author_id).uniq | ||
185 | + User.where(id: author_ids) | ||
186 | + else | ||
187 | + [] | ||
188 | + end | ||
189 | + sorted(users) | ||
190 | + end | ||
191 | + | ||
192 | + def sorted(users) | ||
193 | + users.uniq.sort_by(&:username).map { |user| { username: user.username, name: user.name } } | ||
194 | + end | ||
165 | end | 195 | end |
app/views/layouts/_init_auto_complete.html.haml
1 | :javascript | 1 | :javascript |
2 | - GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" | 2 | + GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project, type: @noteable.class, type_id: params[:id])}" |
3 | GitLab.GfmAutoComplete.setup(); | 3 | GitLab.GfmAutoComplete.setup(); |
lib/gitlab/markdown.rb
@@ -166,8 +166,8 @@ module Gitlab | @@ -166,8 +166,8 @@ module Gitlab | ||
166 | end | 166 | end |
167 | 167 | ||
168 | def reference_user(identifier) | 168 | def reference_user(identifier) |
169 | - if member = @project.team_members.find { |user| user.username == identifier } | ||
170 | - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member | 169 | + if user = User.find_by_username(identifier) |
170 | + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) | ||
171 | end | 171 | end |
172 | end | 172 | end |
173 | 173 |