diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-18 17:58:22 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-18 17:58:22 +0300 |
commit | f5f0ed55bd7bf7d034282c5b3e7f02ca725a4ffa (patch) | |
tree | a71f62ba4b8af746a38f135de8383e2a9c403b06 /app | |
parent | 307a6ba57f20f7a0ac02bbf9f7a50edff04cf6e5 (diff) | |
parent | f93190429743f66d2a085891d51d004b390b4491 (diff) | |
download | gitlab-ce-f5f0ed55bd7bf7d034282c5b3e7f02ca725a4ffa.tar.gz |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/application.js.coffee | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/projects.scss | 2 | ||||
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 10 | ||||
-rw-r--r-- | app/models/concerns/participable.rb | 20 | ||||
-rw-r--r-- | app/services/notification_service.rb | 23 | ||||
-rw-r--r-- | app/views/shared/_visibility_radios.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/snippets/_form.html.haml | 2 |
8 files changed, 52 insertions, 21 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index bb9da147018..caf18c0d860 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -140,8 +140,8 @@ $ -> # Place the logo tooltip on the right when collapsed, bottom when expanded $el.parents('header').hasClass('header-collapsed') and 'right' or 'bottom' else - # Otherwise use the data-placement attribute like normal - $el.data('placement') + # Otherwise use the data-placement attribute, or 'bottom' if undefined + $el.data('placement') or 'bottom' }) # Form submitter diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 49e5aad1f67..16b9814a0fc 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -129,7 +129,7 @@ } .option-descr { - margin-left: 24px; + margin-left: 36px; color: $gray; } } diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index c524e1a0ea3..7d168aa827b 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -19,7 +19,15 @@ class Projects::IssuesController < Projects::ApplicationController def index terms = params['issue_search'] @issues = get_issues_collection - @issues = @issues.full_search(terms) if terms.present? + + if terms.present? + if terms =~ /\A#(\d+)\z/ + @issues = @issues.where(iid: $1) + else + @issues = @issues.full_search(terms) + end + end + @issues = @issues.page(params[:page]).per(PER_PAGE) respond_to do |format| diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 5b93e95866a..c7467e9b2f5 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -19,7 +19,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController def index terms = params['issue_search'] @merge_requests = get_merge_requests_collection - @merge_requests = @merge_requests.full_search(terms) if terms.present? + + if terms.present? + if terms =~ /\A[#!](\d+)\z/ + @merge_requests = @merge_requests.where(iid: $1) + else + @merge_requests = @merge_requests.full_search(terms) + end + end + @merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE) respond_to do |format| diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb index a4832204f7b..9f667f47e0d 100644 --- a/app/models/concerns/participable.rb +++ b/app/models/concerns/participable.rb @@ -35,8 +35,8 @@ module Participable end end - def participants(current_user = self.author) - self.class.participant_attrs.flat_map do |attr| + def participants(current_user = self.author, project = self.project) + participants = self.class.participant_attrs.flat_map do |attr| meth = method(attr) value = @@ -46,20 +46,28 @@ module Participable meth.call end - participants_for(value, current_user) + participants_for(value, current_user, project) end.compact.uniq + + if project + participants.select! do |user| + user.can?(:read_project, project) + end + end + + participants end private - def participants_for(value, current_user = nil) + def participants_for(value, current_user = nil, project = nil) case value when User [value] when Enumerable, ActiveRecord::Relation - value.flat_map { |v| participants_for(v, current_user) } + value.flat_map { |v| participants_for(v, current_user, project) } when Participable - value.participants(current_user) + value.participants(current_user, project) end end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 0d7ffbeebd9..312b56eb87b 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -91,10 +91,14 @@ class NotificationService # * project team members with notification level higher then Participating # def merge_mr(merge_request, current_user) - recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project) + recipients = [merge_request.author, merge_request.assignee] + + recipients = add_project_watchers(recipients, merge_request.target_project) + recipients = reject_muted_users(recipients, merge_request.target_project) + recipients = add_subscribed_users(recipients, merge_request) recipients = reject_unsubscribed_users(recipients, merge_request) - recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq + recipients.delete(current_user) recipients.each do |recipient| @@ -137,20 +141,17 @@ class NotificationService recipients = recipients.concat(participants) # Merge project watchers - recipients = recipients.concat(project_watchers(note.project)).compact.uniq + recipients = add_project_watchers(recipients, note.project) # Reject users with Mention notification level, except those mentioned in _this_ note. recipients = reject_mention_users(recipients - note.mentioned_users, note.project) recipients = recipients + note.mentioned_users - # Reject mutes users recipients = reject_muted_users(recipients, note.project) recipients = add_subscribed_users(recipients, note.noteable) - recipients = reject_unsubscribed_users(recipients, note.noteable) - # Reject author recipients.delete(note.author) # build notify method like 'note_commit_email' @@ -287,6 +288,10 @@ class NotificationService users end + def add_project_watchers(recipients, project) + recipients.concat(project_watchers(project)).compact.uniq + end + # Remove users with disabled notifications from array # Also remove duplications and nil recipients def reject_muted_users(users, project = nil) @@ -403,11 +408,13 @@ class NotificationService [target.author, target.assignee] end - recipients = reject_muted_users(recipients, project) + recipients = add_project_watchers(recipients, project) recipients = reject_mention_users(recipients, project) + recipients = reject_muted_users(recipients, project) + recipients = add_subscribed_users(recipients, target) - recipients = recipients.concat(project_watchers(project)).uniq recipients = reject_unsubscribed_users(recipients, target) + recipients end diff --git a/app/views/shared/_visibility_radios.html.haml b/app/views/shared/_visibility_radios.html.haml index b07c4d20f12..02416125a72 100644 --- a/app/views/shared/_visibility_radios.html.haml +++ b/app/views/shared/_visibility_radios.html.haml @@ -1,7 +1,7 @@ - Gitlab::VisibilityLevel.values.each do |level| .radio - restricted = restricted_visibility_levels.include?(level) - = label model_method, level do + = form.label "#{model_method}_#{level}" do = form.radio_button model_method, level, checked: (selected_level == level), disabled: restricted = visibility_level_icon(level) .option-title diff --git a/app/views/shared/snippets/_form.html.haml b/app/views/shared/snippets/_form.html.haml index 6783587bda9..9610f9ce414 100644 --- a/app/views/shared/snippets/_form.html.haml +++ b/app/views/shared/snippets/_form.html.haml @@ -11,7 +11,7 @@ .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true = render 'shared/visibility_level', f: f, visibility_level: visibility_level, can_change_visibility_level: true, form_model: @snippet - + .form-group .file-editor = f.label :file_name, "File", class: 'control-label' |