diff options
Diffstat (limited to 'app/controllers/admin')
10 files changed, 26 insertions, 23 deletions
diff --git a/app/controllers/admin/application_settings/appearances_controller.rb b/app/controllers/admin/application_settings/appearances_controller.rb index 1a8447185a7..3cb31ff756f 100644 --- a/app/controllers/admin/application_settings/appearances_controller.rb +++ b/app/controllers/admin/application_settings/appearances_controller.rb @@ -68,7 +68,7 @@ class Admin::ApplicationSettings::AppearancesController < Admin::ApplicationCont def allowed_appearance_params %i[ title - short_title + pwa_short_name description logo logo_cache diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index b8c1bc266f7..ade58ca0970 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -137,8 +137,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController unless job_id.length <= PARAM_JOB_ID_MAX_SIZE return render status: :bad_request, json: { - message: _('Parameter "job_id" cannot exceed length of %{job_id_max_size}' % - { job_id_max_size: PARAM_JOB_ID_MAX_SIZE }) + message: format(_('Parameter "job_id" cannot exceed length of %{job_id_max_size}'), job_id_max_size: PARAM_JOB_ID_MAX_SIZE) } end @@ -174,8 +173,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController unless job_id.length <= PARAM_JOB_ID_MAX_SIZE return render status: :bad_request, json: { - message: _('Parameter "job_id" cannot exceed length of %{job_id_max_size}' % - { job_id_max_size: PARAM_JOB_ID_MAX_SIZE }) + message: format(_('Parameter "job_id" cannot exceed length of %{job_id_max_size}'), job_id_max_size: PARAM_JOB_ID_MAX_SIZE) } end diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb index 093c5667a24..d641a26c9fb 100644 --- a/app/controllers/admin/broadcast_messages_controller.rb +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -99,7 +99,6 @@ module Admin end def push_features - push_frontend_feature_flag(:vue_broadcast_messages, current_user) push_frontend_feature_flag(:role_targeted_broadcast_messages, current_user) end end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 37dde065e70..dab0f3e870a 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -2,6 +2,7 @@ class Admin::DashboardController < Admin::ApplicationController include CountHelper + helper Admin::ComponentsHelper COUNTED_ITEMS = [Project, User, Group].freeze diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 8005babe19e..e3a33bafb62 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -41,7 +41,7 @@ class Admin::GroupsController < Admin::ApplicationController @group = ::Groups::CreateService.new(current_user, group_params).execute if @group.persisted? - redirect_to [:admin, @group], notice: _('Group %{group_name} was successfully created.') % { group_name: @group.name } + redirect_to [:admin, @group], notice: format(_('Group %{group_name} was successfully created.'), group_name: @group.name) else render "new" end @@ -66,7 +66,7 @@ class Admin::GroupsController < Admin::ApplicationController redirect_to admin_groups_path, status: :found, - alert: _('Group %{group_name} was scheduled for deletion.') % { group_name: @group.name } + alert: format(_('Group %{group_name} was scheduled for deletion.'), group_name: @group.name) end private diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb index 9d884478e98..ddc555add5c 100644 --- a/app/controllers/admin/impersonation_tokens_controller.rb +++ b/app/controllers/admin/impersonation_tokens_controller.rb @@ -25,9 +25,9 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController @impersonation_token = finder.find(params[:id]) if @impersonation_token.revoke! - flash[:notice] = _("Revoked impersonation token %{token_name}!") % { token_name: @impersonation_token.name } + flash[:notice] = format(_("Revoked impersonation token %{token_name}!"), token_name: @impersonation_token.name) else - flash[:alert] = _("Could not revoke impersonation token %{token_name}.") % { token_name: @impersonation_token.name } + flash[:alert] = format(_("Could not revoke impersonation token %{token_name}."), token_name: @impersonation_token.name) end redirect_to admin_user_impersonation_tokens_path diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 9e841487508..5d37bd27302 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -43,7 +43,7 @@ class Admin::ProjectsController < Admin::ApplicationController def destroy ::Projects::DestroyService.new(@project, current_user, {}).async_execute - flash[:notice] = _("Project '%{project_name}' is in the process of being deleted.") % { project_name: @project.full_name } + flash[:notice] = format(_("Project '%{project_name}' is in the process of being deleted."), project_name: @project.full_name) redirect_to admin_projects_path, status: :found rescue Projects::DestroyService::DestroyError => e diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb index 180f4634136..984ae736697 100644 --- a/app/controllers/admin/spam_logs_controller.rb +++ b/app/controllers/admin/spam_logs_controller.rb @@ -16,7 +16,7 @@ class Admin::SpamLogsController < Admin::ApplicationController spam_log.remove_user(deleted_by: current_user) redirect_to admin_spam_logs_path, status: :found, - notice: _('User %{username} was successfully removed.') % { username: spam_log.user.username } + 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 e97ead12f71..345a778772d 100644 --- a/app/controllers/admin/topics_controller.rb +++ b/app/controllers/admin/topics_controller.rb @@ -23,7 +23,7 @@ class Admin::TopicsController < Admin::ApplicationController @topic = Projects::Topic.new(topic_params) if @topic.save - redirect_to edit_admin_topic_path(@topic), notice: _('Topic %{topic_name} was successfully created.') % { topic_name: @topic.name } + redirect_to edit_admin_topic_path(@topic), notice: format(_('Topic %{topic_name} was successfully created.'), topic_name: @topic.name) else render "new" end @@ -42,7 +42,7 @@ class Admin::TopicsController < Admin::ApplicationController redirect_to admin_topics_path, status: :found, - notice: _('Topic %{topic_name} was successfully removed.') % { topic_name: @topic.title_or_name } + notice: format(_('Topic %{topic_name} was successfully removed.'), topic_name: @topic.title_or_name) end def merge @@ -53,7 +53,7 @@ class Admin::TopicsController < Admin::ApplicationController return render status: :bad_request, json: { type: :alert, message: response.message } if response.error? message = _('Topic %{source_topic} was successfully merged into topic %{target_topic}.') - flash[:toast] = message % { source_topic: source_topic.name, target_topic: target_topic.name } + flash[:toast] = format(message, source_topic: source_topic.name, target_topic: target_topic.name) redirect_to admin_topics_path, status: :found end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 5f6e3f0062f..4f379d8a75b 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -57,7 +57,7 @@ class Admin::UsersController < Admin::ApplicationController log_impersonation_event - flash[:alert] = _("You are now impersonating %{username}") % { username: user.username } + flash[:alert] = format(_("You are now impersonating %{username}"), username: user.username) redirect_to root_path else @@ -81,7 +81,7 @@ class Admin::UsersController < Admin::ApplicationController result = Users::RejectService.new(current_user).execute(user) if result[:status] == :success - redirect_back_or_admin_user(notice: _("You've rejected %{user}" % { user: user.name })) + redirect_back_or_admin_user(notice: format(_("You've rejected %{user}"), user: user.name)) else redirect_back_or_admin_user(alert: result[:message]) end @@ -105,7 +105,7 @@ class Admin::UsersController < Admin::ApplicationController return redirect_back_or_admin_user(notice: _("Internal users cannot be deactivated")) if user.internal? unless user.can_be_deactivated? - return redirect_back_or_admin_user(notice: _("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 }) + 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)) end user.deactivate @@ -124,8 +124,12 @@ class Admin::UsersController < Admin::ApplicationController def unblock if user.ldap_blocked? - redirect_back_or_admin_user(alert: _("This user cannot be unlocked manually from GitLab")) - elsif update_user { |user| user.activate } + return redirect_back_or_admin_user(alert: _("This user cannot be unlocked manually from GitLab")) + end + + result = Users::UnblockService.new(current_user).execute(user) + + if result.success? redirect_back_or_admin_user(notice: _("Successfully unblocked")) else redirect_back_or_admin_user(alert: _("Error occurred. User was not unblocked")) @@ -153,7 +157,7 @@ class Admin::UsersController < Admin::ApplicationController end def unlock - if update_user { |user| user.unlock_access! } + if update_user(&:unlock_access!) redirect_back_or_admin_user(notice: _("Successfully unlocked")) else redirect_back_or_admin_user(alert: _("Error occurred. User was not unlocked")) @@ -161,7 +165,7 @@ class Admin::UsersController < Admin::ApplicationController end def confirm - if update_user { |user| user.force_confirm } + if update_user(&:force_confirm) redirect_back_or_admin_user(notice: _("Successfully confirmed")) else redirect_back_or_admin_user(alert: _("Error occurred. User was not confirmed")) @@ -358,6 +362,7 @@ class Admin::UsersController < Admin::ApplicationController :username, :website_url, :note, + :private_profile, credit_card_validation_attributes: [:credit_card_validated_at] ] end @@ -377,7 +382,7 @@ class Admin::UsersController < Admin::ApplicationController end def log_impersonation_event - Gitlab::AppLogger.info(_("User %{current_user_username} has started impersonating %{username}") % { current_user_username: current_user.username, username: user.username }) + Gitlab::AppLogger.info(format(_("User %{current_user_username} has started impersonating %{username}"), current_user_username: current_user.username, username: user.username)) end def can_impersonate_user |