Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /app/controllers/admin
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/abuse_reports_controller.rb29
-rw-r--r--app/controllers/admin/application_settings_controller.rb104
-rw-r--r--app/controllers/admin/applications_controller.rb28
-rw-r--r--app/controllers/admin/background_migrations_controller.rb1
-rw-r--r--app/controllers/admin/broadcast_messages_controller.rb26
-rw-r--r--app/controllers/admin/ci/variables_controller.rb7
-rw-r--r--app/controllers/admin/cohorts_controller.rb2
-rw-r--r--app/controllers/admin/dev_ops_report_controller.rb2
-rw-r--r--app/controllers/admin/groups_controller.rb6
-rw-r--r--app/controllers/admin/hooks_controller.rb6
-rw-r--r--app/controllers/admin/identities_controller.rb2
-rw-r--r--app/controllers/admin/impersonation_tokens_controller.rb2
-rw-r--r--app/controllers/admin/impersonations_controller.rb2
-rw-r--r--app/controllers/admin/instance_review_controller.rb2
-rw-r--r--app/controllers/admin/keys_controller.rb2
-rw-r--r--app/controllers/admin/plan_limits_controller.rb1
-rw-r--r--app/controllers/admin/projects_controller.rb32
-rw-r--r--app/controllers/admin/runner_projects_controller.rb8
-rw-r--r--app/controllers/admin/runners_controller.rb9
-rw-r--r--app/controllers/admin/sessions_controller.rb2
-rw-r--r--app/controllers/admin/spam_logs_controller.rb6
-rw-r--r--app/controllers/admin/topics_controller.rb4
-rw-r--r--app/controllers/admin/usage_trends_controller.rb2
-rw-r--r--app/controllers/admin/users_controller.rb31
24 files changed, 137 insertions, 179 deletions
diff --git a/app/controllers/admin/abuse_reports_controller.rb b/app/controllers/admin/abuse_reports_controller.rb
index 5357558434e..84e5cc430ef 100644
--- a/app/controllers/admin/abuse_reports_controller.rb
+++ b/app/controllers/admin/abuse_reports_controller.rb
@@ -3,16 +3,37 @@
class Admin::AbuseReportsController < Admin::ApplicationController
feature_category :insider_threat
+ before_action :set_status_param, only: :index, if: -> { Feature.enabled?(:abuse_reports_list) }
+ before_action :find_abuse_report, only: [:show, :update, :destroy]
+
def index
@abuse_reports = AbuseReportsFinder.new(params).execute
end
- def destroy
- abuse_report = AbuseReport.find(params[:id])
+ def show; end
+
+ def update
+ Admin::AbuseReportUpdateService.new(@abuse_report, current_user, permitted_params).execute
+ end
- abuse_report.remove_user(deleted_by: current_user) if params[:remove_user]
- abuse_report.destroy
+ def destroy
+ @abuse_report.remove_user(deleted_by: current_user) if params[:remove_user]
+ @abuse_report.destroy
head :ok
end
+
+ private
+
+ def find_abuse_report
+ @abuse_report = AbuseReport.find(params[:id])
+ end
+
+ def set_status_param
+ params[:status] ||= 'open'
+ end
+
+ def permitted_params
+ params.permit(:user_action, :close, :reason, :comment)
+ end
end
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index ade58ca0970..dff1c04311d 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -13,22 +13,16 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :disable_query_limiting, only: [:usage_data]
+ before_action do
+ push_frontend_feature_flag(:ci_variables_pages, current_user)
+ end
+
feature_category :not_owned, [ # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
:general, :reporting, :metrics_and_profiling, :network,
:preferences, :update, :reset_health_check_token
]
- feature_category :metrics, [
- :create_self_monitoring_project,
- :status_create_self_monitoring_project,
- :delete_self_monitoring_project,
- :status_delete_self_monitoring_project
- ]
urgency :low, [
- :create_self_monitoring_project,
- :status_create_self_monitoring_project,
- :delete_self_monitoring_project,
- :status_delete_self_monitoring_project,
:reset_error_tracking_access_token
]
@@ -101,8 +95,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
def reset_error_tracking_access_token
@application_setting.reset_error_tracking_access_token!
- redirect_to general_admin_application_settings_path,
- notice: _('New error tracking access token has been generated!')
+ redirect_to general_admin_application_settings_path, notice: _('New error tracking access token has been generated!')
end
def clear_repository_check_states
@@ -121,91 +114,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
redirect_to ::Gitlab::LetsEncrypt.terms_of_service_url
end
- # Specs are in spec/requests/self_monitoring_project_spec.rb
- def create_self_monitoring_project
- job_id = SelfMonitoringProjectCreateWorker.with_status.perform_async # rubocop:disable CodeReuse/Worker
-
- render status: :accepted, json: {
- job_id: job_id,
- monitor_status: status_create_self_monitoring_project_admin_application_settings_path
- }
- end
-
- # Specs are in spec/requests/self_monitoring_project_spec.rb
- def status_create_self_monitoring_project
- job_id = params[:job_id].to_s
-
- unless job_id.length <= PARAM_JOB_ID_MAX_SIZE
- return render status: :bad_request, json: {
- message: format(_('Parameter "job_id" cannot exceed length of %{job_id_max_size}'), job_id_max_size: PARAM_JOB_ID_MAX_SIZE)
- }
- end
-
- if SelfMonitoringProjectCreateWorker.in_progress?(job_id) # rubocop:disable CodeReuse/Worker
- ::Gitlab::PollingInterval.set_header(response, interval: 3_000)
-
- return render status: :accepted, json: {
- message: _('Job to create self-monitoring project is in progress')
- }
- end
-
- return render status: :ok, json: self_monitoring_data if @application_setting.self_monitoring_project_id.present?
-
- render status: :bad_request, json: {
- message: _('Self-monitoring project does not exist. Please check logs ' \
- 'for any error messages')
- }
- end
-
- # Specs are in spec/requests/self_monitoring_project_spec.rb
- def delete_self_monitoring_project
- job_id = SelfMonitoringProjectDeleteWorker.with_status.perform_async # rubocop:disable CodeReuse/Worker
-
- render status: :accepted, json: {
- job_id: job_id,
- monitor_status: status_delete_self_monitoring_project_admin_application_settings_path
- }
- end
-
- # Specs are in spec/requests/self_monitoring_project_spec.rb
- def status_delete_self_monitoring_project
- job_id = params[:job_id].to_s
-
- unless job_id.length <= PARAM_JOB_ID_MAX_SIZE
- return render status: :bad_request, json: {
- message: format(_('Parameter "job_id" cannot exceed length of %{job_id_max_size}'), job_id_max_size: PARAM_JOB_ID_MAX_SIZE)
- }
- end
-
- if SelfMonitoringProjectDeleteWorker.in_progress?(job_id) # rubocop:disable CodeReuse/Worker
- ::Gitlab::PollingInterval.set_header(response, interval: 3_000)
-
- return render status: :accepted, json: {
- message: _('Job to delete self-monitoring project is in progress')
- }
- end
-
- if @application_setting.self_monitoring_project_id.nil?
- return render status: :ok, json: {
- message: _('Self-monitoring project has been successfully deleted')
- }
- end
-
- render status: :bad_request, json: {
- message: _('Self-monitoring project was not deleted. Please check logs ' \
- 'for any error messages')
- }
- end
-
private
- def self_monitoring_data
- {
- project_id: @application_setting.self_monitoring_project_id,
- project_full_path: @application_setting.self_monitoring_project&.full_path
- }
- end
-
def set_application_setting
@application_setting = ApplicationSetting.current_without_cache
@plans = Plan.all
@@ -231,6 +141,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
params[:application_setting][:valid_runner_registrars]&.delete("")
params[:application_setting][:restricted_visibility_levels]&.delete("")
+ params[:application_setting][:package_metadata_purl_types]&.delete("")
+ params[:application_setting][:package_metadata_purl_types]&.map!(&:to_i)
+
if params[:application_setting].key?(:required_instance_ci_template)
if params[:application_setting][:required_instance_ci_template].empty?
params[:application_setting][:required_instance_ci_template] = nil
@@ -273,6 +186,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:default_branch_name,
disabled_oauth_sign_in_sources: [],
import_sources: [],
+ package_metadata_purl_types: [],
restricted_visibility_levels: [],
repository_storages_weighted: {},
valid_runner_registrars: []
diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb
index d66b3cb4366..d97fcc5df74 100644
--- a/app/controllers/admin/applications_controller.rb
+++ b/app/controllers/admin/applications_controller.rb
@@ -3,19 +3,17 @@
class Admin::ApplicationsController < Admin::ApplicationController
include OauthApplications
- before_action :set_application, only: [:show, :edit, :update, :destroy]
+ before_action :set_application, only: [:show, :edit, :update, :renew, :destroy]
before_action :load_scopes, only: [:new, :create, :edit, :update]
- feature_category :authentication_and_authorization
+ feature_category :system_access
def index
applications = ApplicationsFinder.new.execute
@applications = Kaminari.paginate_array(applications).page(params[:page])
end
- def show
- @created = get_created_session if Feature.disabled?('hash_oauth_secrets')
- end
+ def show; end
def new
@application = Doorkeeper::Application.new
@@ -30,14 +28,8 @@ class Admin::ApplicationsController < Admin::ApplicationController
if @application.persisted?
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
- if Feature.enabled?('hash_oauth_secrets')
- @created = true
- render :show
- else
- set_created_session
-
- redirect_to admin_application_url(@application)
- end
+ @created = true
+ render :show
else
render :new
end
@@ -51,6 +43,16 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
end
+ def renew
+ @application.renew_secret
+
+ if @application.save
+ render json: { secret: @application.plaintext_secret }
+ else
+ render json: { errors: @application.errors }, status: :unprocessable_entity
+ end
+ end
+
def destroy
@application.destroy
redirect_to admin_applications_url, status: :found, notice: _('Application was successfully destroyed.')
diff --git a/app/controllers/admin/background_migrations_controller.rb b/app/controllers/admin/background_migrations_controller.rb
index b904196c5ab..a5211961d81 100644
--- a/app/controllers/admin/background_migrations_controller.rb
+++ b/app/controllers/admin/background_migrations_controller.rb
@@ -10,6 +10,7 @@ module Admin
def index
@relations_by_tab = {
'queued' => batched_migration_class.queued.queue_order,
+ 'finalizing' => batched_migration_class.finalizing.queue_order,
'failed' => batched_migration_class.with_status(:failed).queue_order,
'finished' => batched_migration_class.with_status(:finished).queue_order.reverse_order
}
diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb
index d641a26c9fb..821c3cc1635 100644
--- a/app/controllers/admin/broadcast_messages_controller.rb
+++ b/app/controllers/admin/broadcast_messages_controller.rb
@@ -6,7 +6,6 @@ module Admin
before_action :find_broadcast_message, only: [:edit, :update, :destroy]
before_action :find_broadcast_messages, only: [:index, :create]
- before_action :push_features, only: [:index, :edit]
feature_category :onboarding
urgency :low
@@ -15,8 +14,7 @@ module Admin
@broadcast_message = BroadcastMessage.new
end
- def edit
- end
+ def edit; end
def create
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
@@ -72,7 +70,7 @@ module Admin
def preview
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
- render partial: 'admin/broadcast_messages/preview'
+ render plain: render_broadcast_message(@broadcast_message), status: :ok
end
protected
@@ -88,18 +86,14 @@ module Admin
def broadcast_message_params
params.require(:broadcast_message)
.permit(%i[
- theme
- ends_at
- message
- starts_at
- target_path
- broadcast_type
- dismissable
- ], target_access_levels: []).reverse_merge!(target_access_levels: [])
- end
-
- def push_features
- push_frontend_feature_flag(:role_targeted_broadcast_messages, current_user)
+ theme
+ ends_at
+ message
+ starts_at
+ target_path
+ broadcast_type
+ dismissable
+ ], target_access_levels: []).reverse_merge!(target_access_levels: [])
end
end
end
diff --git a/app/controllers/admin/ci/variables_controller.rb b/app/controllers/admin/ci/variables_controller.rb
index ef50d7362c4..4ab67e54766 100644
--- a/app/controllers/admin/ci/variables_controller.rb
+++ b/app/controllers/admin/ci/variables_controller.rb
@@ -3,7 +3,7 @@
module Admin
module Ci
class VariablesController < ApplicationController
- feature_category :pipeline_authoring
+ feature_category :secrets_management
def show
respond_to do |format|
@@ -32,10 +32,7 @@ module Admin
end
def render_instance_variables
- render status: :ok,
- json: {
- variables: ::Ci::InstanceVariableSerializer.new.represent(variables)
- }
+ render status: :ok, json: { variables: ::Ci::InstanceVariableSerializer.new.represent(variables) }
end
def render_error(errors)
diff --git a/app/controllers/admin/cohorts_controller.rb b/app/controllers/admin/cohorts_controller.rb
index ce3d769f35e..3948d3635fe 100644
--- a/app/controllers/admin/cohorts_controller.rb
+++ b/app/controllers/admin/cohorts_controller.rb
@@ -7,7 +7,7 @@ class Admin::CohortsController < Admin::ApplicationController
urgency :low
- track_custom_event :index,
+ track_event :index,
name: 'i_analytics_cohorts',
action: 'perform_analytics_usage_action',
label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly',
diff --git a/app/controllers/admin/dev_ops_report_controller.rb b/app/controllers/admin/dev_ops_report_controller.rb
index 71ee19ddf39..2e47dfcb0db 100644
--- a/app/controllers/admin/dev_ops_report_controller.rb
+++ b/app/controllers/admin/dev_ops_report_controller.rb
@@ -5,7 +5,7 @@ class Admin::DevOpsReportController < Admin::ApplicationController
helper_method :show_adoption?
- track_custom_event :show,
+ track_event :show,
name: 'i_analytics_dev_ops_score',
action: 'perform_analytics_usage_action',
label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly',
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index e3a33bafb62..0f9ecc60648 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -5,7 +5,7 @@ class Admin::GroupsController < Admin::ApplicationController
before_action :group, only: [:edit, :update, :destroy, :project_update, :members_update]
- feature_category :subgroups
+ feature_category :subgroups, [:create, :destroy, :edit, :index, :members_update, :new, :show, :update]
def index
@groups = groups.sort_by_attribute(@sort = params[:sort])
@@ -65,8 +65,8 @@ class Admin::GroupsController < Admin::ApplicationController
Groups::DestroyService.new(@group, current_user).async_execute
redirect_to admin_groups_path,
- status: :found,
- alert: format(_('Group %{group_name} was scheduled for deletion.'), group_name: @group.name)
+ status: :found,
+ alert: format(_('Group %{group_name} was scheduled for deletion.'), group_name: @group.name)
end
private
diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb
index 1dc6c68d8ca..57ef75f12e9 100644
--- a/app/controllers/admin/hooks_controller.rb
+++ b/app/controllers/admin/hooks_controller.rb
@@ -3,8 +3,6 @@
class Admin::HooksController < Admin::ApplicationController
include ::WebHooks::HookActions
- before_action :hook_logs, only: :edit
-
feature_category :integrations
urgency :low, [:test]
@@ -26,10 +24,6 @@ class Admin::HooksController < Admin::ApplicationController
@hook ||= SystemHook.find(params[:id])
end
- def hook_logs
- @hook_logs ||= hook.web_hook_logs.recent.page(params[:page]).without_count
- end
-
def hook_param_names
%i[enable_ssl_verification token url]
end
diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb
index dcec50e882d..0745ba328c6 100644
--- a/app/controllers/admin/identities_controller.rb
+++ b/app/controllers/admin/identities_controller.rb
@@ -4,7 +4,7 @@ class Admin::IdentitiesController < Admin::ApplicationController
before_action :user
before_action :identity, except: [:index, :new, :create]
- feature_category :authentication_and_authorization
+ feature_category :system_access
def new
@identity = Identity.new
diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb
index ddc555add5c..dae3337d19b 100644
--- a/app/controllers/admin/impersonation_tokens_controller.rb
+++ b/app/controllers/admin/impersonation_tokens_controller.rb
@@ -4,7 +4,7 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
before_action :user
before_action :verify_impersonation_enabled!
- feature_category :authentication_and_authorization
+ feature_category :user_management
def index
set_index_vars
diff --git a/app/controllers/admin/impersonations_controller.rb b/app/controllers/admin/impersonations_controller.rb
index 6c45b03455e..c1a6cb350ec 100644
--- a/app/controllers/admin/impersonations_controller.rb
+++ b/app/controllers/admin/impersonations_controller.rb
@@ -4,7 +4,7 @@ class Admin::ImpersonationsController < Admin::ApplicationController
skip_before_action :authenticate_admin!
before_action :authenticate_impersonator!
- feature_category :authentication_and_authorization
+ feature_category :user_management
def destroy
original_user = stop_impersonation
diff --git a/app/controllers/admin/instance_review_controller.rb b/app/controllers/admin/instance_review_controller.rb
index cc801bce5b7..87fb1fa1a66 100644
--- a/app/controllers/admin/instance_review_controller.rb
+++ b/app/controllers/admin/instance_review_controller.rb
@@ -5,7 +5,7 @@ class Admin::InstanceReviewController < Admin::ApplicationController
urgency :low
def index
- redirect_to("#{Gitlab::SubscriptionPortal.subscriptions_instance_review_url}?#{instance_review_params}")
+ redirect_to("#{subscription_portal_instance_review_url}?#{instance_review_params}")
end
def instance_review_params
diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb
index 03383604e30..e4a756ec12d 100644
--- a/app/controllers/admin/keys_controller.rb
+++ b/app/controllers/admin/keys_controller.rb
@@ -3,7 +3,7 @@
class Admin::KeysController < Admin::ApplicationController
before_action :user, only: [:show, :destroy]
- feature_category :authentication_and_authorization
+ feature_category :user_management
def show
@key = user.keys.find(params[:id])
diff --git a/app/controllers/admin/plan_limits_controller.rb b/app/controllers/admin/plan_limits_controller.rb
index ea52198432c..b8608390d4d 100644
--- a/app/controllers/admin/plan_limits_controller.rb
+++ b/app/controllers/admin/plan_limits_controller.rb
@@ -41,7 +41,6 @@ class Admin::PlanLimitsController < Admin::ApplicationController
generic_packages_max_file_size
ci_pipeline_size
ci_active_jobs
- ci_active_pipelines
ci_project_subscriptions
ci_pipeline_schedules
ci_needs_size_limit
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index 5d37bd27302..84eb90ce334 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -3,10 +3,10 @@
class Admin::ProjectsController < Admin::ApplicationController
include MembersPresentation
- before_action :project, only: [:show, :transfer, :repository_check, :destroy]
+ before_action :project, only: [:show, :transfer, :repository_check, :destroy, :edit, :update]
before_action :group, only: [:show, :transfer]
- feature_category :projects, [:index, :show, :transfer, :destroy]
+ feature_category :projects, [:index, :show, :transfer, :destroy, :edit, :update]
feature_category :source_code_management, [:repository_check]
def index
@@ -62,6 +62,22 @@ class Admin::ProjectsController < Admin::ApplicationController
end
# rubocop: enable CodeReuse/ActiveRecord
+ def edit; end
+
+ def update
+ result = ::Projects::UpdateService.new(@project, current_user, project_params).execute
+
+ if result[:status] == :success
+ unless Gitlab::Utils.to_boolean(project_params['runner_registration_enabled'])
+ Ci::Runners::ResetRegistrationTokenService.new(@project, current_user).execute
+ end
+
+ redirect_to [:admin, @project], notice: format(_("Project '%{project_name}' was successfully updated."), project_name: @project.name)
+ else
+ render "edit"
+ end
+ end
+
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id) # rubocop:disable CodeReuse/Worker
@@ -83,6 +99,18 @@ class Admin::ProjectsController < Admin::ApplicationController
def group
@group ||= @project.group
end
+
+ def project_params
+ params.require(:project).permit(allowed_project_params)
+ end
+
+ def allowed_project_params
+ [
+ :description,
+ :name,
+ :runner_registration_enabled
+ ]
+ end
end
Admin::ProjectsController.prepend_mod_with('Admin::ProjectsController')
diff --git a/app/controllers/admin/runner_projects_controller.rb b/app/controllers/admin/runner_projects_controller.rb
index 7dbae565d07..79a31331374 100644
--- a/app/controllers/admin/runner_projects_controller.rb
+++ b/app/controllers/admin/runner_projects_controller.rb
@@ -10,9 +10,10 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
if ::Ci::Runners::AssignRunnerService.new(@runner, @project, current_user).execute.success?
- redirect_to edit_admin_runner_url(@runner), notice: s_('Runners|Runner assigned to project.')
+ flash[:success] = s_('Runners|Runner assigned to project.')
+ redirect_to edit_admin_runner_url(@runner)
else
- redirect_to edit_admin_runner_url(@runner), alert: 'Failed adding runner to project'
+ redirect_to edit_admin_runner_url(@runner), alert: s_('Runners|Failed adding runner to project')
end
end
@@ -22,7 +23,8 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
::Ci::Runners::UnassignRunnerService.new(rp, current_user).execute
- redirect_to edit_admin_runner_url(runner), status: :found, notice: s_('Runners|Runner unassigned from project.')
+ flash[:success] = s_('Runners|Runner unassigned from project.')
+ redirect_to edit_admin_runner_url(runner), status: :found
end
private
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 21a3a0aea0b..f63616a2bea 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -6,7 +6,7 @@ class Admin::RunnersController < Admin::ApplicationController
before_action :runner, except: [:index, :new, :tag_list, :runner_setup_scripts]
before_action only: [:index] do
- push_frontend_feature_flag(:create_runner_workflow, current_user)
+ push_frontend_feature_flag(:create_runner_workflow_for_admin, current_user)
end
feature_category :runner
@@ -23,7 +23,12 @@ class Admin::RunnersController < Admin::ApplicationController
end
def new
- render_404 unless Feature.enabled?(:create_runner_workflow, current_user)
+ render_404 unless Feature.enabled?(:create_runner_workflow_for_admin, current_user)
+ end
+
+ def register
+ render_404 unless Feature.enabled?(:create_runner_workflow_for_admin, current_user) &&
+ runner.registration_available?
end
def update
diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb
index 63579421573..bb275532170 100644
--- a/app/controllers/admin/sessions_controller.rb
+++ b/app/controllers/admin/sessions_controller.rb
@@ -7,7 +7,7 @@ class Admin::SessionsController < ApplicationController
before_action :user_is_admin!
- feature_category :authentication_and_authorization
+ feature_category :system_access
def new
if current_user_mode.admin_mode?
diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb
index 984ae736697..b27185a6add 100644
--- a/app/controllers/admin/spam_logs_controller.rb
+++ b/app/controllers/admin/spam_logs_controller.rb
@@ -5,7 +5,7 @@ class Admin::SpamLogsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
- @spam_logs = SpamLog.includes(:user).order(id: :desc).page(params[:page])
+ @spam_logs = SpamLog.includes(:user).order(id: :desc).page(params[:page]).without_count
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -15,8 +15,8 @@ class Admin::SpamLogsController < Admin::ApplicationController
if params[:remove_user]
spam_log.remove_user(deleted_by: current_user)
redirect_to admin_spam_logs_path,
- status: :found,
- notice: format(_('User %{username} was successfully removed.'), username: spam_log.user.username)
+ status: :found,
+ notice: format(_('User %{username} was successfully removed.'), username: spam_log.user.username)
else
spam_log.destroy
head :ok
diff --git a/app/controllers/admin/topics_controller.rb b/app/controllers/admin/topics_controller.rb
index 345a778772d..94d084932ad 100644
--- a/app/controllers/admin/topics_controller.rb
+++ b/app/controllers/admin/topics_controller.rb
@@ -41,8 +41,8 @@ class Admin::TopicsController < Admin::ApplicationController
@topic.destroy!
redirect_to admin_topics_path,
- status: :found,
- notice: format(_('Topic %{topic_name} was successfully removed.'), topic_name: @topic.title_or_name)
+ status: :found,
+ notice: format(_('Topic %{topic_name} was successfully removed.'), topic_name: @topic.title_or_name)
end
def merge
diff --git a/app/controllers/admin/usage_trends_controller.rb b/app/controllers/admin/usage_trends_controller.rb
index 082b38ac3a8..f88028535c1 100644
--- a/app/controllers/admin/usage_trends_controller.rb
+++ b/app/controllers/admin/usage_trends_controller.rb
@@ -3,7 +3,7 @@
class Admin::UsageTrendsController < Admin::ApplicationController
include ProductAnalyticsTracking
- track_custom_event :index,
+ track_event :index,
name: 'i_analytics_instance_statistics',
action: 'perform_analytics_usage_action',
label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly',
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 00b17bf381f..45a7901b2c4 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -96,28 +96,29 @@ class Admin::UsersController < Admin::ApplicationController
end
def deactivate
- if user.blocked?
- return redirect_back_or_admin_user(notice: _("Error occurred. A blocked user cannot be deactivated"))
- end
-
- return redirect_back_or_admin_user(notice: _("Successfully deactivated")) if user.deactivated?
- return redirect_back_or_admin_user(notice: _("Internal users cannot be deactivated")) if user.internal?
+ deactivate_service = Users::DeactivateService.new(current_user, skip_authorization: true)
+ result = deactivate_service.execute(user)
- unless user.can_be_deactivated?
- return redirect_back_or_admin_user(notice: format(_("The user you are trying to deactivate has been active in the past %{minimum_inactive_days} days and cannot be deactivated"), minimum_inactive_days: Gitlab::CurrentSettings.deactivate_dormant_users_period))
+ if result.success?
+ redirect_back_or_admin_user(notice: _("Successfully deactivated"))
+ else
+ redirect_back_or_admin_user(alert: result.message)
end
-
- user.deactivate
- redirect_back_or_admin_user(notice: _("Successfully deactivated"))
end
def block
result = Users::BlockService.new(current_user).execute(user)
- if result[:status] == :success
- redirect_back_or_admin_user(notice: _("Successfully blocked"))
- else
- redirect_back_or_admin_user(alert: _("Error occurred. User was not blocked"))
+ respond_to do |format|
+ if result[:status] == :success
+ notice = _("Successfully blocked")
+ format.json { render json: { notice: notice } }
+ format.html { redirect_back_or_admin_user(notice: notice) }
+ else
+ alert = _("Error occurred. User was not blocked")
+ format.json { render json: { error: alert } }
+ format.html { redirect_back_or_admin_user(alert: alert) }
+ end
end
end