GitLab steht Mittwoch, den 23. September, zwischen 10:00 und 12:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit c98089b2 authored by Rémy Coutable's avatar Rémy Coutable

Move the #toggle_subscription controller method to a concern

parent 54ec7e95
class Projects::IssuesController < Projects::ApplicationController
include ToggleSubscriptionAction
before_action :module_enabled
before_action :issue, only: [:edit, :update, :show, :toggle_subscription]
before_action :issue, only: [:edit, :update, :show]
# Allow read any issue
before_action :authorize_read_issue!
......@@ -110,14 +112,6 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_back_or_default(default: { action: 'index' }, options: { notice: "#{result[:count]} issues updated" })
end
def toggle_subscription
return unless current_user
@issue.toggle_subscription(current_user)
render nothing: true
end
def closed_by_merge_requests
@closed_by_merge_requests ||= @issue.closed_by_merge_requests(current_user)
end
......@@ -131,6 +125,7 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_old
end
end
alias_method :subscribable_resource, :issue
def authorize_update_issue!
return render_404 unless can?(current_user, :update_issue, @issue)
......
class Projects::LabelsController < Projects::ApplicationController
include ToggleSubscriptionAction
before_action :module_enabled
before_action :label, only: [:edit, :update, :destroy, :toggle_subscription]
before_action :label, only: [:edit, :update, :destroy]
before_action :authorize_read_label!
before_action :authorize_admin_labels!, except: [:index, :toggle_subscription]
before_action :authorize_admin_labels!, only: [
:new, :create, :edit, :update, :generate, :destroy
]
respond_to :js, :html
......@@ -60,13 +64,6 @@ class Projects::LabelsController < Projects::ApplicationController
end
end
def toggle_subscription
return unless current_user
@label.toggle_subscription(current_user)
render nothing: true
end
protected
def module_enabled
......@@ -80,8 +77,9 @@ class Projects::LabelsController < Projects::ApplicationController
end
def label
@label = @project.labels.find(params[:id])
@label ||= @project.labels.find(params[:id])
end
alias_method :subscribable_resource, :label
def authorize_admin_labels!
return render_404 unless can?(current_user, :admin_label, @project)
......
class Projects::MergeRequestsController < Projects::ApplicationController
include ToggleSubscriptionAction
include DiffHelper
before_action :module_enabled
before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :builds, :merge, :merge_check,
:ci_status, :toggle_subscription, :cancel_merge_when_build_succeeds
:ci_status, :cancel_merge_when_build_succeeds
]
before_action :closes_issues, only: [:edit, :update, :show, :diffs, :commits, :builds]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :builds]
......@@ -233,14 +234,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render json: response
end
def toggle_subscription
return unless current_user
@merge_request.toggle_subscription(current_user)
render nothing: true
end
protected
def selected_target_project
......@@ -254,6 +247,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def merge_request
@merge_request ||= @project.merge_requests.find_by!(iid: params[:id])
end
alias_method :subscribable_resource, :merge_request
def closes_issues
@closes_issues ||= @merge_request.closes_issues
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment