Commit b155302d authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'move-prepend-to-bottom-in-controllers' into 'master'

Move all the prepend in controllers to bottom

Closes #8598

See merge request gitlab-org/gitlab-ee!8921
parents 6844a092 caaa2387
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
# #
# Automatically sets the layout and ensures an administrator is logged in # Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController class Admin::ApplicationController < ApplicationController
prepend EE::Admin::ApplicationController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :authenticate_admin! before_action :authenticate_admin!
layout 'admin' layout 'admin'
...@@ -13,3 +11,5 @@ class Admin::ApplicationController < ApplicationController ...@@ -13,3 +11,5 @@ class Admin::ApplicationController < ApplicationController
render_404 unless current_user.admin? render_404 unless current_user.admin?
end end
end end
Admin::ApplicationController.prepend(EE::Admin::ApplicationController)
# frozen_string_literal: true # frozen_string_literal: true
class Admin::DashboardController < Admin::ApplicationController class Admin::DashboardController < Admin::ApplicationController
prepend ::EE::Admin::DashboardController # rubocop: disable Cop/InjectEnterpriseEditionModule
include CountHelper include CountHelper
COUNTED_ITEMS = [Project, User, Group, ForkNetworkMember, ForkNetwork, Issue, COUNTED_ITEMS = [Project, User, Group, ForkNetworkMember, ForkNetwork, Issue,
...@@ -17,3 +15,5 @@ class Admin::DashboardController < Admin::ApplicationController ...@@ -17,3 +15,5 @@ class Admin::DashboardController < Admin::ApplicationController
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
Admin::DashboardController.prepend(EE::Admin::DashboardController)
# frozen_string_literal: true # frozen_string_literal: true
class Admin::ProjectsController < Admin::ApplicationController class Admin::ProjectsController < Admin::ApplicationController
prepend EE::Admin::ProjectsController # rubocop: disable Cop/InjectEnterpriseEditionModule
include MembersPresentation include MembersPresentation
before_action :project, only: [:show, :transfer, :repository_check] before_action :project, only: [:show, :transfer, :repository_check]
...@@ -68,3 +67,5 @@ class Admin::ProjectsController < Admin::ApplicationController ...@@ -68,3 +67,5 @@ class Admin::ProjectsController < Admin::ApplicationController
@group ||= @project.group @group ||= @project.group
end end
end end
Admin::ProjectsController.prepend(EE::Admin::ProjectsController)
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
module Boards module Boards
class ListsController < Boards::ApplicationController class ListsController < Boards::ApplicationController
prepend ::EE::Boards::ListsController # rubocop: disable Cop/InjectEnterpriseEditionModule
include BoardsResponses include BoardsResponses
before_action :authorize_admin_list, only: [:create, :update, :destroy, :generate] before_action :authorize_admin_list, only: [:create, :update, :destroy, :generate]
...@@ -85,3 +83,5 @@ module Boards ...@@ -85,3 +83,5 @@ module Boards
end end
end end
end end
Boards::ListsController.prepend(EE::Boards::ListsController)
# frozen_string_literal: true # frozen_string_literal: true
class ConfirmationsController < Devise::ConfirmationsController class ConfirmationsController < Devise::ConfirmationsController
prepend ::EE::ConfirmationsController # rubocop: disable Cop/InjectEnterpriseEditionModule
include AcceptsPendingInvitations include AcceptsPendingInvitations
def almost_there def almost_there
...@@ -33,3 +31,5 @@ class ConfirmationsController < Devise::ConfirmationsController ...@@ -33,3 +31,5 @@ class ConfirmationsController < Devise::ConfirmationsController
after_sign_in_path_for(resource) after_sign_in_path_for(resource)
end end
end end
ConfirmationsController.prepend(EE::ConfirmationsController)
...@@ -6,6 +6,7 @@ class GroupsController < Groups::ApplicationController ...@@ -6,6 +6,7 @@ class GroupsController < Groups::ApplicationController
include MergeRequestsAction include MergeRequestsAction
include ParamsBackwardCompatibility include ParamsBackwardCompatibility
include PreviewMarkdown include PreviewMarkdown
respond_to :html respond_to :html
prepend_before_action(only: [:show, :issues]) { authenticate_sessionless_user!(:rss) } prepend_before_action(only: [:show, :issues]) { authenticate_sessionless_user!(:rss) }
......
# frozen_string_literal: true # frozen_string_literal: true
class Import::GithubController < Import::BaseController class Import::GithubController < Import::BaseController
prepend ::EE::Import::GithubController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :verify_import_enabled before_action :verify_import_enabled
before_action :provider_auth, only: [:status, :jobs, :create] before_action :provider_auth, only: [:status, :jobs, :create]
...@@ -127,3 +125,5 @@ class Import::GithubController < Import::BaseController ...@@ -127,3 +125,5 @@ class Import::GithubController < Import::BaseController
{} {}
end end
end end
Import::GithubController.prepend(EE::Import::GithubController)
...@@ -32,5 +32,4 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController ...@@ -32,5 +32,4 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
end end
end end
Ldap::OmniauthCallbacksController.prepend(EE::OmniauthCallbacksController) # rubocop: disable Cop/InjectEnterpriseEditionModule
Ldap::OmniauthCallbacksController.prepend(EE::Ldap::OmniauthCallbacksController) Ldap::OmniauthCallbacksController.prepend(EE::Ldap::OmniauthCallbacksController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::AutocompleteSourcesController < Projects::ApplicationController class Projects::AutocompleteSourcesController < Projects::ApplicationController
prepend EE::Projects::AutocompleteSourcesController # rubocop: disable Cop/InjectEnterpriseEditionModule
def members def members
render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target) render json: ::Projects::ParticipantsService.new(@project, current_user).execute(target)
end end
...@@ -43,3 +41,5 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController ...@@ -43,3 +41,5 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController
.execute(params[:type], params[:type_id]) .execute(params[:type], params[:type_id])
end end
end end
Projects::AutocompleteSourcesController.prepend(EE::Projects::AutocompleteSourcesController)
...@@ -15,8 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -15,8 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
push_frontend_feature_flag(:area_chart, project) push_frontend_feature_flag(:area_chart, project)
end end
prepend ::EE::Projects::EnvironmentsController # rubocop: disable Cop/InjectEnterpriseEditionModule
def index def index
@environments = project.environments @environments = project.environments
.with_state(params[:scope] || :available) .with_state(params[:scope] || :available)
...@@ -192,3 +190,5 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -192,3 +190,5 @@ class Projects::EnvironmentsController < Projects::ApplicationController
access_denied! unless can?(current_user, :stop_environment, environment) access_denied! unless can?(current_user, :stop_environment, environment)
end end
end end
Projects::EnvironmentsController.prepend(EE::Projects::EnvironmentsController)
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
class Projects::GitHttpClientController < Projects::ApplicationController class Projects::GitHttpClientController < Projects::ApplicationController
include ActionController::HttpAuthentication::Basic include ActionController::HttpAuthentication::Basic
include KerberosSpnegoHelper include KerberosSpnegoHelper
prepend ::EE::Projects::GitHttpClientController # rubocop: disable Cop/InjectEnterpriseEditionModule
attr_reader :authentication_result, :redirected_path attr_reader :authentication_result, :redirected_path
...@@ -110,3 +109,5 @@ class Projects::GitHttpClientController < Projects::ApplicationController ...@@ -110,3 +109,5 @@ class Projects::GitHttpClientController < Projects::ApplicationController
authentication_result.ci?(project) authentication_result.ci?(project)
end end
end end
Projects::GitHttpClientController.prepend(EE::Projects::GitHttpClientController)
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
class Projects::GitHttpController < Projects::GitHttpClientController class Projects::GitHttpController < Projects::GitHttpClientController
include WorkhorseRequest include WorkhorseRequest
prepend ::EE::Projects::GitHttpController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :access_check before_action :access_check
...@@ -97,3 +96,5 @@ class Projects::GitHttpController < Projects::GitHttpClientController ...@@ -97,3 +96,5 @@ class Projects::GitHttpController < Projects::GitHttpClientController
Users::ActivityService.new(user, 'pull').execute Users::ActivityService.new(user, 'pull').execute
end end
end end
Projects::GitHttpController.prepend(EE::Projects::GitHttpController)
...@@ -53,4 +53,4 @@ class Projects::GroupLinksController < Projects::ApplicationController ...@@ -53,4 +53,4 @@ class Projects::GroupLinksController < Projects::ApplicationController
end end
end end
Projects::GroupLinksController.prepend(::EE::Projects::GroupLinksController) Projects::GroupLinksController.prepend(EE::Projects::GroupLinksController)
...@@ -75,4 +75,4 @@ class Projects::ImportsController < Projects::ApplicationController ...@@ -75,4 +75,4 @@ class Projects::ImportsController < Projects::ApplicationController
end end
end end
Projects::ImportsController.prepend(::EE::Projects::ImportsController) Projects::ImportsController.prepend(EE::Projects::ImportsController)
...@@ -9,13 +9,11 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -9,13 +9,11 @@ class Projects::IssuesController < Projects::ApplicationController
include IssuesCalendar include IssuesCalendar
include SpammableActions include SpammableActions
prepend ::EE::Projects::IssuesController # rubocop: disable Cop/InjectEnterpriseEditionModule def issue_except_actions
def self.issue_except_actions
%i[index calendar new create bulk_update import_csv] %i[index calendar new create bulk_update import_csv]
end end
def self.set_issuables_index_only_actions def set_issuables_index_only_actions
%i[index calendar] %i[index calendar]
end end
...@@ -26,9 +24,9 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -26,9 +24,9 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update] before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update]
before_action :check_issues_available! before_action :check_issues_available!
before_action :issue, except: issue_except_actions before_action :issue, unless: ->(c) { c.issue_except_actions.include?(c.action_name.to_sym) }
before_action :set_issuables_index, only: set_issuables_index_only_actions before_action :set_issuables_index, if: ->(c) { c.set_issuables_index_only_actions.include?(c.action_name.to_sym) }
# Allow write(create) issue # Allow write(create) issue
before_action :authorize_create_issue!, only: [:new, :create] before_action :authorize_create_issue!, only: [:new, :create]
...@@ -287,3 +285,5 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -287,3 +285,5 @@ class Projects::IssuesController < Projects::ApplicationController
push_frontend_feature_flag(:graphql, default_enabled: true) push_frontend_feature_flag(:graphql, default_enabled: true)
end end
end end
Projects::IssuesController.prepend(EE::Projects::IssuesController)
...@@ -124,4 +124,4 @@ class Projects::LfsApiController < Projects::GitHttpClientController ...@@ -124,4 +124,4 @@ class Projects::LfsApiController < Projects::GitHttpClientController
end end
end end
Projects::LfsApiController.prepend(::EE::Projects::LfsApiController) Projects::LfsApiController.prepend(EE::Projects::LfsApiController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::MergeRequests::ApplicationController < Projects::ApplicationController class Projects::MergeRequests::ApplicationController < Projects::ApplicationController
prepend ::EE::Projects::MergeRequests::ApplicationController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :check_merge_requests_available! before_action :check_merge_requests_available!
before_action :merge_request before_action :merge_request
before_action :authorize_read_merge_request! before_action :authorize_read_merge_request!
...@@ -46,3 +44,5 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont ...@@ -46,3 +44,5 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
@statuses_count = @pipeline.present? ? @pipeline.statuses.relevant.count : 0 @statuses_count = @pipeline.present? ? @pipeline.statuses.relevant.count : 0
end end
end end
Projects::MergeRequests::ApplicationController.prepend(EE::Projects::MergeRequests::ApplicationController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::MergeRequests::DiffsController < Projects::MergeRequests::ApplicationController class Projects::MergeRequests::DiffsController < Projects::MergeRequests::ApplicationController
prepend ::EE::Projects::MergeRequests::DiffsController # rubocop: disable Cop/InjectEnterpriseEditionModule
include DiffForPath include DiffForPath
include DiffHelper include DiffHelper
include RendersNotes include RendersNotes
...@@ -120,3 +118,5 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic ...@@ -120,3 +118,5 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@notes @notes
end end
end end
Projects::MergeRequests::DiffsController.prepend(EE::Projects::MergeRequests::DiffsController)
...@@ -8,8 +8,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -8,8 +8,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
include ToggleAwardEmoji include ToggleAwardEmoji
include IssuableCollections include IssuableCollections
prepend ::EE::Projects::MergeRequestsController # rubocop: disable Cop/InjectEnterpriseEditionModule
skip_before_action :merge_request, only: [:index, :bulk_update] skip_before_action :merge_request, only: [:index, :bulk_update]
before_action :whitelist_query_limiting, only: [:assign_related_issues, :update] before_action :whitelist_query_limiting, only: [:assign_related_issues, :update]
before_action :authorize_update_issuable!, only: [:close, :edit, :update, :remove_wip, :sort] before_action :authorize_update_issuable!, only: [:close, :edit, :update, :remove_wip, :sort]
...@@ -349,3 +347,5 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -349,3 +347,5 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42438') Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42438')
end end
end end
Projects::MergeRequestsController.prepend(EE::Projects::MergeRequestsController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::PipelinesController < Projects::ApplicationController class Projects::PipelinesController < Projects::ApplicationController
prepend ::EE::Projects::PipelinesController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :whitelist_query_limiting, only: [:create, :retry] before_action :whitelist_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts] before_action :pipeline, except: [:index, :new, :create, :charts]
before_action :authorize_read_pipeline! before_action :authorize_read_pipeline!
...@@ -188,3 +186,5 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -188,3 +186,5 @@ class Projects::PipelinesController < Projects::ApplicationController
view_context.limited_counter_with_delimiter(finder.execute) view_context.limited_counter_with_delimiter(finder.execute)
end end
end end
Projects::PipelinesController.prepend(EE::Projects::PipelinesController)
...@@ -66,4 +66,4 @@ class Projects::ProtectedRefsController < Projects::ApplicationController ...@@ -66,4 +66,4 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
end end
end end
Projects::ProtectedRefsController.prepend(::EE::Projects::ProtectedRefsController) Projects::ProtectedRefsController.prepend(EE::Projects::ProtectedRefsController)
...@@ -6,8 +6,6 @@ module Projects ...@@ -6,8 +6,6 @@ module Projects
before_action :authorize_admin_pipeline! before_action :authorize_admin_pipeline!
before_action :define_variables before_action :define_variables
prepend ::EE::Projects::Settings::CiCdController # rubocop: disable Cop/InjectEnterpriseEditionModule
def show def show
end end
...@@ -121,3 +119,5 @@ module Projects ...@@ -121,3 +119,5 @@ module Projects
end end
end end
end end
Projects::Settings::CiCdController.prepend(EE::Projects::Settings::CiCdController)
...@@ -6,8 +6,6 @@ module Projects ...@@ -6,8 +6,6 @@ module Projects
before_action :authorize_admin_project! before_action :authorize_admin_project!
before_action :remote_mirror, only: [:show] before_action :remote_mirror, only: [:show]
prepend ::EE::Projects::Settings::RepositoryController # rubocop: disable Cop/InjectEnterpriseEditionModule
def show def show
render_show render_show
end end
...@@ -106,3 +104,5 @@ module Projects ...@@ -106,3 +104,5 @@ module Projects
end end
end end
end end
Projects::Settings::RepositoryController.prepend(EE::Projects::Settings::RepositoryController)
# frozen_string_literal: true # frozen_string_literal: true
class Projects::VariablesController < Projects::ApplicationController class Projects::VariablesController < Projects::ApplicationController
prepend ::EE::Projects::VariablesController # rubocop: disable Cop/InjectEnterpriseEditionModule
before_action :authorize_admin_build! before_action :authorize_admin_build!
def show def show
...@@ -43,3 +41,5 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -43,3 +41,5 @@ class Projects::VariablesController < Projects::ApplicationController
%i[id key secret_value protected _destroy] %i[id key secret_value protected _destroy]
end end
end end
Projects::VariablesController.prepend(EE::Projects::VariablesController)
...@@ -6,6 +6,7 @@ class SessionsController < Devise::SessionsController ...@@ -6,6 +6,7 @@ class SessionsController < Devise::SessionsController
include Devise::Controllers::Rememberable include Devise::Controllers::Rememberable
include Recaptcha::ClientHelper include Recaptcha::ClientHelper
include Recaptcha::Verify include Recaptcha::Verify
skip_before_action :check_two_factor_requirement, only: [:destroy] skip_before_action :check_two_factor_requirement, only: [:destroy]
prepend_before_action :check_initial_setup, only: [:new] prepend_before_action :check_initial_setup, only: [:new]
......
...@@ -4,6 +4,7 @@ class UsersController < ApplicationController ...@@ -4,6 +4,7 @@ class UsersController < ApplicationController
include RoutableActions include RoutableActions
include RendersMemberAccess include RendersMemberAccess
include ControllerWithCrossProjectAccessCheck include ControllerWithCrossProjectAccessCheck
requires_cross_project_access show: false, requires_cross_project_access show: false,
groups: false, groups: false,
projects: false, projects: false,
......
...@@ -29,7 +29,7 @@ module EE ...@@ -29,7 +29,7 @@ module EE
# git-lfs: https://github.com/git-lfs/git-lfs/blob/master/docs/api # git-lfs: https://github.com/git-lfs/git-lfs/blob/master/docs/api
# #
prepended do prepended do
before_action do prepend_before_action do
redirect_to(primary_full_url) if redirect? redirect_to(primary_full_url) if redirect?
end end
end end
......
...@@ -4,6 +4,7 @@ module EE ...@@ -4,6 +4,7 @@ module EE
module Projects module Projects
module IssuesController module IssuesController
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do prepended do
before_action :authenticate_user!, only: [:export_csv] before_action :authenticate_user!, only: [:export_csv]
...@@ -12,18 +13,14 @@ module EE ...@@ -12,18 +13,14 @@ module EE
before_action :whitelist_query_limiting_ee, only: [:update] before_action :whitelist_query_limiting_ee, only: [:update]
end end
class_methods do override :issue_except_actions
extend ::Gitlab::Utils::Override def issue_except_actions
super + %i[export_csv service_desk]
override :issue_except_actions end
def issue_except_actions
super + %i[export_csv service_desk]
end
override :set_issuables_index_only_actions override :set_issuables_index_only_actions
def set_issuables_index_only_actions def set_issuables_index_only_actions
super + %i[service_desk] super + %i[service_desk]
end
end end
def service_desk def service_desk
......
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