summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/runners_controller.rb10
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/clusters/applications_controller.rb2
-rw-r--r--app/controllers/concerns/enforces_two_factor_authentication.rb8
-rw-r--r--app/controllers/concerns/integrations_actions.rb4
-rw-r--r--app/controllers/dashboard/projects_controller.rb16
-rw-r--r--app/controllers/explore/projects_controller.rb17
-rw-r--r--app/controllers/groups/milestones_controller.rb3
-rw-r--r--app/controllers/groups/settings/ci_cd_controller.rb4
-rw-r--r--app/controllers/projects/forks_controller.rb19
-rw-r--r--app/controllers/projects/import/jira_controller.rb13
-rw-r--r--app/controllers/projects/issues_controller.rb11
-rw-r--r--app/controllers/projects/merge_requests_controller.rb7
-rw-r--r--app/controllers/projects/milestones_controller.rb3
-rw-r--r--app/controllers/projects/settings/ci_cd_controller.rb3
-rw-r--r--app/controllers/projects_controller.rb4
-rw-r--r--app/controllers/repositories/git_http_controller.rb12
-rw-r--r--app/controllers/users_controller.rb7
18 files changed, 100 insertions, 45 deletions
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 9eaa55039c8..4639d8adfe0 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -61,7 +61,15 @@ class Admin::RunnersController < Admin::ApplicationController
end
def runner_params
- params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
+ params.require(:runner).permit(permitted_attrs)
+ end
+
+ def permitted_attrs
+ if Gitlab.com?
+ Ci::Runner::FORM_EDITABLE + Ci::Runner::MINUTES_COST_FACTOR_FIELDS
+ else
+ Ci::Runner::FORM_EDITABLE
+ end
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b2496427924..26ef6117e1c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -150,7 +150,7 @@ class ApplicationController < ActionController::Base
payload[:username] = logged_user.try(:username)
end
- payload[:queue_duration] = request.env[::Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY]
+ payload[:queue_duration_s] = request.env[::Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY]
end
##
diff --git a/app/controllers/clusters/applications_controller.rb b/app/controllers/clusters/applications_controller.rb
index 3ebd248c29e..de14bd319e0 100644
--- a/app/controllers/clusters/applications_controller.rb
+++ b/app/controllers/clusters/applications_controller.rb
@@ -47,7 +47,7 @@ class Clusters::ApplicationsController < Clusters::BaseController
end
def cluster_application_params
- params.permit(:application, :hostname, :pages_domain_id, :email, :stack, :modsecurity_enabled, :modsecurity_mode)
+ params.permit(:application, :hostname, :pages_domain_id, :email, :stack, :modsecurity_enabled, :modsecurity_mode, :host, :port, :protocol)
end
def cluster_application_destroy_params
diff --git a/app/controllers/concerns/enforces_two_factor_authentication.rb b/app/controllers/concerns/enforces_two_factor_authentication.rb
index 825181568ad..d486d734db8 100644
--- a/app/controllers/concerns/enforces_two_factor_authentication.rb
+++ b/app/controllers/concerns/enforces_two_factor_authentication.rb
@@ -16,7 +16,7 @@ module EnforcesTwoFactorAuthentication
end
def check_two_factor_requirement
- if two_factor_authentication_required? && current_user && !current_user.temp_oauth_email? && !current_user.two_factor_enabled? && !skip_two_factor?
+ if two_factor_authentication_required? && current_user_requires_two_factor?
redirect_to profile_two_factor_auth_path
end
end
@@ -27,6 +27,10 @@ module EnforcesTwoFactorAuthentication
current_user.try(:ultraauth_user?)
end
+ def current_user_requires_two_factor?
+ current_user && !current_user.temp_oauth_email? && !current_user.two_factor_enabled? && !skip_two_factor?
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def two_factor_authentication_reason(global: -> {}, group: -> {})
if two_factor_authentication_required?
@@ -61,3 +65,5 @@ module EnforcesTwoFactorAuthentication
session[:skip_two_factor] && session[:skip_two_factor] > Time.current
end
end
+
+EnforcesTwoFactorAuthentication.prepend_if_ee('EE::EnforcesTwoFactorAuthentication')
diff --git a/app/controllers/concerns/integrations_actions.rb b/app/controllers/concerns/integrations_actions.rb
index 4c998055a5d..ff283f9bb62 100644
--- a/app/controllers/concerns/integrations_actions.rb
+++ b/app/controllers/concerns/integrations_actions.rb
@@ -15,9 +15,7 @@ module IntegrationsActions
end
def update
- integration.attributes = service_params[:service]
-
- saved = integration.save(context: :manual_change)
+ saved = integration.update(service_params[:service])
respond_to do |format|
format.html do
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb
index 039991e07a2..c173d7d2310 100644
--- a/app/controllers/dashboard/projects_controller.rb
+++ b/app/controllers/dashboard/projects_controller.rb
@@ -61,22 +61,24 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
end
- # rubocop: disable CodeReuse/ActiveRecord
def load_projects(finder_params)
@total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute
@total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
finder_params[:use_cte] = true if use_cte_for_finder?
- projects = ProjectsFinder
- .new(params: finder_params, current_user: current_user)
- .execute
- .includes(:route, :creator, :group, namespace: [:route, :owner])
- .preload(:project_feature)
- .page(finder_params[:page])
+ projects = ProjectsFinder.new(params: finder_params, current_user: current_user).execute
+
+ projects = preload_associations(projects)
+ projects = projects.page(finder_params[:page])
prepare_projects_for_rendering(projects)
end
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def preload_associations(projects)
+ projects.includes(:route, :creator, :group, namespace: [:route, :owner]).preload(:project_feature)
+ end
# rubocop: enable CodeReuse/ActiveRecord
def use_cte_for_finder?
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb
index a8a76b47bbe..705a586d614 100644
--- a/app/controllers/explore/projects_controller.rb
+++ b/app/controllers/explore/projects_controller.rb
@@ -66,18 +66,21 @@ class Explore::ProjectsController < Explore::ApplicationController
@total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
end
- # rubocop: disable CodeReuse/ActiveRecord
def load_projects
load_project_counts
- projects = ProjectsFinder.new(current_user: current_user, params: params)
- .execute
- .includes(:route, :creator, :group, namespace: [:route, :owner])
- .page(params[:page])
- .without_count
+ projects = ProjectsFinder.new(current_user: current_user, params: params).execute
+
+ projects = preload_associations(projects)
+ projects = projects.page(params[:page]).without_count
prepare_projects_for_rendering(projects)
end
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def preload_associations(projects)
+ projects.includes(:route, :creator, :group, namespace: [:route, :owner])
+ end
# rubocop: enable CodeReuse/ActiveRecord
def set_sorting
@@ -110,3 +113,5 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
end
+
+Explore::ProjectsController.prepend_if_ee('EE::Explore::ProjectsController')
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index a478e9fffb8..8cfbd293597 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -5,6 +5,9 @@ class Groups::MilestonesController < Groups::ApplicationController
before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy]
before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy]
+ before_action do
+ push_frontend_feature_flag(:burnup_charts)
+ end
def index
respond_to do |format|
diff --git a/app/controllers/groups/settings/ci_cd_controller.rb b/app/controllers/groups/settings/ci_cd_controller.rb
index 6b842fc9fe1..bfe7987176a 100644
--- a/app/controllers/groups/settings/ci_cd_controller.rb
+++ b/app/controllers/groups/settings/ci_cd_controller.rb
@@ -7,7 +7,7 @@ module Groups
before_action :authorize_admin_group!
before_action :authorize_update_max_artifacts_size!, only: [:update]
before_action do
- push_frontend_feature_flag(:new_variables_ui, @group)
+ push_frontend_feature_flag(:new_variables_ui, @group, default_enabled: true)
push_frontend_feature_flag(:ajax_new_deploy_token, @group)
end
before_action :define_variables, only: [:show, :create_deploy_token]
@@ -43,7 +43,7 @@ module Groups
end
def create_deploy_token
- result = Projects::DeployTokens::CreateService.new(@group, current_user, deploy_token_params).execute
+ result = Groups::DeployTokens::CreateService.new(@group, current_user, deploy_token_params).execute
@new_deploy_token = result[:deploy_token]
if result[:status] == :success
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 248b75d16ed..ebc81976529 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -13,16 +13,13 @@ class Projects::ForksController < Projects::ApplicationController
before_action :authorize_fork_project!, only: [:new, :create]
before_action :authorize_fork_namespace!, only: [:create]
- # rubocop: disable CodeReuse/ActiveRecord
def index
@total_forks_count = project.forks.size
@public_forks_count = project.forks.public_only.size
@private_forks_count = @total_forks_count - project.forks.public_and_internal_only.size
@internal_forks_count = @total_forks_count - @public_forks_count - @private_forks_count
- @forks = ForkProjectsFinder.new(project, params: params.merge(search: params[:filter_projects]), current_user: current_user).execute
- @forks = @forks.includes(:route, :creator, :group, namespace: [:route, :owner])
- .page(params[:page])
+ @forks = load_forks.page(params[:page])
prepare_projects_for_rendering(@forks)
@@ -36,7 +33,6 @@ class Projects::ForksController < Projects::ApplicationController
end
end
end
- # rubocop: enable CodeReuse/ActiveRecord
def new
@namespaces = fork_service.valid_fork_targets - [project.namespace]
@@ -59,10 +55,19 @@ class Projects::ForksController < Projects::ApplicationController
redirect_to project_path(@forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
end
end
- # rubocop: enable CodeReuse/ActiveRecord
private
+ def load_forks
+ forks = ForkProjectsFinder.new(
+ project,
+ params: params.merge(search: params[:filter_projects]),
+ current_user: current_user
+ ).execute
+
+ forks.includes(:route, :creator, :group, namespace: [:route, :owner])
+ end
+
def fork_service
strong_memoize(:fork_service) do
::Projects::ForkService.new(project, current_user, namespace: fork_namespace)
@@ -83,3 +88,5 @@ class Projects::ForksController < Projects::ApplicationController
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42335')
end
end
+
+Projects::ForksController.prepend_if_ee('EE::Projects::ForksController')
diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb
index 26d9b4b223f..4a70ed45404 100644
--- a/app/controllers/projects/import/jira_controller.rb
+++ b/app/controllers/projects/import/jira_controller.rb
@@ -11,11 +11,10 @@ module Projects
before_action :authorize_admin_project!, only: [:import]
def show
- @is_jira_configured = @project.jira_service.present?
- return if Feature.enabled?(:jira_issue_import_vue, @project)
+ jira_service = @project.jira_service
- if !@project.latest_jira_import&.in_progress? && current_user&.can?(:admin_project, @project)
- jira_client = @project.jira_service.client
+ if jira_service.present? && !@project.latest_jira_import&.in_progress? && current_user&.can?(:admin_project, @project)
+ jira_client = jira_service.client
jira_projects = jira_client.Project.all
if jira_projects.present?
@@ -25,7 +24,9 @@ module Projects
end
end
- flash[:notice] = _("Import %{status}") % { status: @project.jira_import_status } unless @project.latest_jira_import&.initial?
+ unless Feature.enabled?(:jira_issue_import_vue, @project, default_enabled: true)
+ flash[:notice] = _("Import %{status}") % { status: @project.jira_import_status } unless @project.latest_jira_import&.initial?
+ end
end
def import
@@ -50,7 +51,7 @@ module Projects
end
def jira_integration_configured?
- return if Feature.enabled?(:jira_issue_import_vue, @project)
+ return if Feature.enabled?(:jira_issue_import_vue, @project, default_enabled: true)
return if @project.jira_service
flash[:notice] = _("Configure the Jira integration first on your project's %{strong_start} Settings > Integrations > Jira%{strong_end} page." %
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 51ad8edb012..3aae8990f07 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -11,7 +11,7 @@ class Projects::IssuesController < Projects::ApplicationController
include RecordUserLastActivity
def issue_except_actions
- %i[index calendar new create bulk_update import_csv]
+ %i[index calendar new create bulk_update import_csv export_csv]
end
def set_issuables_index_only_actions
@@ -20,7 +20,7 @@ class Projects::IssuesController < Projects::ApplicationController
prepend_before_action(only: [:index]) { authenticate_sessionless_user!(:rss) }
prepend_before_action(only: [:calendar]) { authenticate_sessionless_user!(:ics) }
- prepend_before_action :authenticate_user!, only: [:new]
+ prepend_before_action :authenticate_user!, only: [:new, :export_csv]
# designs is only applicable to EE, but defining a prepend_before_action in EE code would overwrite this
prepend_before_action :store_uri, only: [:new, :show, :designs]
@@ -189,6 +189,13 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
+ def export_csv
+ ExportCsvWorker.perform_async(current_user.id, project.id, finder_options.to_h) # rubocop:disable CodeReuse/Worker
+
+ index_path = project_issues_path(project)
+ redirect_to(index_path, notice: "Your CSV export has started. It will be emailed to #{current_user.notification_email} when complete.")
+ end
+
def import_csv
if uploader = UploadService.new(project, params[:file]).execute
ImportIssuesCsvWorker.perform_async(current_user.id, project.id, uploader.upload.id) # rubocop:disable CodeReuse/Worker
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 89de40006ff..cbab68b2827 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -25,6 +25,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:suggest_pipeline) if experiment_enabled?(:suggest_pipeline)
push_frontend_feature_flag(:code_navigation, @project)
push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true)
+ push_frontend_feature_flag(:merge_ref_head_comments, @project)
end
before_action do
@@ -339,11 +340,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
def serialize_widget(merge_request)
- serializer.represent(merge_request, serializer: 'widget')
+ cached_data = serializer.represent(merge_request, serializer: 'poll_cached_widget')
+ widget_data = serializer.represent(merge_request, serializer: 'poll_widget')
+ cached_data.merge!(widget_data)
end
def serializer
- MergeRequestSerializer.new(current_user: current_user, project: merge_request.project)
+ @serializer ||= MergeRequestSerializer.new(current_user: current_user, project: merge_request.project)
end
def define_edit_vars
diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb
index d301a5be391..56f1f1a1019 100644
--- a/app/controllers/projects/milestones_controller.rb
+++ b/app/controllers/projects/milestones_controller.rb
@@ -6,6 +6,9 @@ class Projects::MilestonesController < Projects::ApplicationController
before_action :check_issuables_available!
before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote]
+ before_action do
+ push_frontend_feature_flag(:burnup_charts)
+ end
# Allow read any milestone
before_action :authorize_read_milestone!
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index a0f98d8f1d2..c7cd9649dac 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -6,8 +6,9 @@ module Projects
before_action :authorize_admin_pipeline!
before_action :define_variables
before_action do
- push_frontend_feature_flag(:new_variables_ui, @project)
+ push_frontend_feature_flag(:new_variables_ui, @project, default_enabled: true)
push_frontend_feature_flag(:ajax_new_deploy_token, @project)
+ push_frontend_feature_flag(:ci_key_autocomplete, default_enabled: true)
end
def show
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 045aa38230c..bb20ea1de49 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -36,6 +36,10 @@ class ProjectsController < Projects::ApplicationController
layout :determine_layout
+ before_action do
+ push_frontend_feature_flag(:metrics_dashboard_visibility_switching_available)
+ end
+
def index
redirect_to(current_user ? root_path : explore_root_path)
end
diff --git a/app/controllers/repositories/git_http_controller.rb b/app/controllers/repositories/git_http_controller.rb
index 9e134ba9526..118036de230 100644
--- a/app/controllers/repositories/git_http_controller.rb
+++ b/app/controllers/repositories/git_http_controller.rb
@@ -23,7 +23,7 @@ module Repositories
# POST /foo/bar.git/git-upload-pack (git pull)
def git_upload_pack
- enqueue_fetch_statistics_update
+ update_fetch_statistics
render_ok
end
@@ -76,12 +76,16 @@ module Repositories
render plain: exception.message, status: :service_unavailable
end
- def enqueue_fetch_statistics_update
+ def update_fetch_statistics
+ return unless project
return if Gitlab::Database.read_only?
return unless repo_type.project?
- return unless project&.daily_statistics_enabled?
- ProjectDailyStatisticsWorker.perform_async(project.id) # rubocop:disable CodeReuse/Worker
+ if Feature.enabled?(:project_statistics_sync, project, default_enabled: true)
+ Projects::FetchStatisticsIncrementService.new(project).execute
+ else
+ ProjectDailyStatisticsWorker.perform_async(project.id) # rubocop:disable CodeReuse/Worker
+ end
end
def access
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 06374736dcf..5ee97885071 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -128,6 +128,10 @@ class UsersController < ApplicationController
@user ||= find_routable!(User, params[:username])
end
+ def personal_projects
+ PersonalProjectsFinder.new(user).execute(current_user)
+ end
+
def contributed_projects
ContributedProjectsFinder.new(user).execute(current_user)
end
@@ -147,8 +151,7 @@ class UsersController < ApplicationController
end
def load_projects
- @projects =
- PersonalProjectsFinder.new(user).execute(current_user)
+ @projects = personal_projects
.page(params[:page])
.per(params[:limit])