diff options
| author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 21:56:38 +0100 |
|---|---|---|
| committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 21:56:38 +0100 |
| commit | 778b5a5a04c4861c84408c944fa8dc01411cbf55 (patch) | |
| tree | 04027e55d3dfdfb35c521577c8f28db09a394ee6 /app/controllers | |
| parent | 166ee0965bacc20e2ad1187321654499a9b0f825 (diff) | |
| parent | da57eb39cd2e5d8dd92b05d16f49681f1677f3e8 (diff) | |
| download | gitlab-ce-778b5a5a04c4861c84408c944fa8dc01411cbf55.tar.gz | |
Merge remote-tracking branch 'origin/master' into zj-slash-commands-mattermost
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/autocomplete_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/concerns/toggle_subscription_action.rb | 6 | ||||
| -rw-r--r-- | app/controllers/groups/labels_controller.rb | 7 | ||||
| -rw-r--r-- | app/controllers/profiles/chat_names_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/projects/blob_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/projects/forks_controller.rb | 1 | ||||
| -rw-r--r-- | app/controllers/projects/labels_controller.rb | 7 | ||||
| -rw-r--r-- | app/controllers/projects_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/sent_notifications_controller.rb | 2 |
9 files changed, 32 insertions, 13 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index daa82336208..fcfa508128e 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -55,7 +55,13 @@ class AutocompleteController < ApplicationController def find_users @users = if @project - @project.team.users + user_ids = @project.team.users.map(&:id) + + if params[:author_id].present? + user_ids << params[:author_id] + end + + User.where(id: user_ids) elsif params[:group_id].present? group = Group.find(params[:group_id]) return render_404 unless can?(current_user, :read_group, group) diff --git a/app/controllers/concerns/toggle_subscription_action.rb b/app/controllers/concerns/toggle_subscription_action.rb index 9e3b9be2ff4..92cb534343e 100644 --- a/app/controllers/concerns/toggle_subscription_action.rb +++ b/app/controllers/concerns/toggle_subscription_action.rb @@ -4,13 +4,17 @@ module ToggleSubscriptionAction def toggle_subscription return unless current_user - subscribable_resource.toggle_subscription(current_user) + subscribable_resource.toggle_subscription(current_user, subscribable_project) head :ok end private + def subscribable_project + @project || raise(NotImplementedError) + end + def subscribable_resource raise NotImplementedError end diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb index 29528b2cfaa..587898a8634 100644 --- a/app/controllers/groups/labels_controller.rb +++ b/app/controllers/groups/labels_controller.rb @@ -1,4 +1,6 @@ class Groups::LabelsController < Groups::ApplicationController + include ToggleSubscriptionAction + before_action :label, only: [:edit, :update, :destroy] before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :destroy] before_action :save_previous_label_path, only: [:edit] @@ -69,6 +71,11 @@ class Groups::LabelsController < Groups::ApplicationController def label @label ||= @group.labels.find(params[:id]) end + alias_method :subscribable_resource, :label + + def subscribable_project + nil + end def label_params params.require(:label).permit(:title, :description, :color) diff --git a/app/controllers/profiles/chat_names_controller.rb b/app/controllers/profiles/chat_names_controller.rb index 0d3bdeff416..6a1f468ba5a 100644 --- a/app/controllers/profiles/chat_names_controller.rb +++ b/app/controllers/profiles/chat_names_controller.rb @@ -1,9 +1,9 @@ class Profiles::ChatNamesController < Profiles::ApplicationController - before_action :chat_names, only: [:index] before_action :chat_name_token, only: [:new] before_action :chat_name_params, only: [:new, :create, :deny] def index + @chat_names = current_user.chat_names end def new @@ -13,7 +13,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController new_chat_name = current_user.chat_names.new(chat_name_params) if new_chat_name.save - flash[:notice] = "Authorized chat nickname #{new_chat_name.chat_name}" + flash[:notice] = "Authorized #{new_chat_name.chat_name}" else flash[:alert] = "Could not authorize chat nickname. Try again!" end @@ -25,7 +25,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController def deny delete_chat_name_token - flash[:alert] = "Denied authorization of chat nickname #{chat_name_params[:user_name]}" + flash[:notice] = "Denied authorization of chat nickname #{chat_name_params[:user_name]}." redirect_to profile_chat_names_path end @@ -34,7 +34,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController @chat_name = chat_names.find(params[:id]) if @chat_name.destroy - flash[:notice] = "Delete chat nickname: #{@chat_name.chat_name}!" + flash[:notice] = "Deleted chat nickname: #{@chat_name.chat_name}!" else flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}." end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index b78cc6585ba..56ced786311 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -42,7 +42,7 @@ class Projects::BlobController < Projects::ApplicationController after_edit_path = if from_merge_request && @target_branch == @ref diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) + - "#file-path-#{hexdigest(@path)}" + "##{hexdigest(@path)}" else namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @path)) end diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index ade01c706a7..ba46e2528e6 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -4,6 +4,7 @@ class Projects::ForksController < Projects::ApplicationController # Authorize before_action :require_non_empty_project before_action :authorize_download_code! + before_action :authenticate_user!, only: [:new, :create] def index base_query = project.forks.includes(:creator) diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 42fd09e9b7e..824ed7be73e 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -3,7 +3,7 @@ class Projects::LabelsController < Projects::ApplicationController before_action :module_enabled before_action :label, only: [:edit, :update, :destroy] - before_action :find_labels, only: [:index, :set_priorities, :remove_priority] + before_action :find_labels, only: [:index, :set_priorities, :remove_priority, :toggle_subscription] before_action :authorize_read_label! before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :generate, :destroy, :remove_priority, @@ -123,7 +123,10 @@ class Projects::LabelsController < Projects::ApplicationController def label @label ||= @project.labels.find(params[:id]) end - alias_method :subscribable_resource, :label + + def subscribable_resource + @available_labels.find(params[:id]) + end def find_labels @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7376c2bfeb7..a8a18b4fa16 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -144,15 +144,13 @@ class ProjectsController < Projects::ApplicationController autocomplete = ::Projects::AutocompleteService.new(@project, current_user) participants = ::Projects::ParticipantsService.new(@project, current_user).execute(noteable) - unlabels = autocomplete.unlabels(noteable) @suggestions = { emojis: Gitlab::AwardEmoji.urls, issues: autocomplete.issues, milestones: autocomplete.milestones, mergerequests: autocomplete.merge_requests, - labels: autocomplete.labels - unlabels, - unlabels: unlabels, + labels: autocomplete.labels, members: participants, commands: autocomplete.commands(noteable, params[:type]) } diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb index 3085ff33aba..04c36b3ebfe 100644 --- a/app/controllers/sent_notifications_controller.rb +++ b/app/controllers/sent_notifications_controller.rb @@ -12,7 +12,7 @@ class SentNotificationsController < ApplicationController def unsubscribe_and_redirect noteable = @sent_notification.noteable - noteable.unsubscribe(@sent_notification.recipient) + noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project) flash[:notice] = "You have been unsubscribed from this thread." |
