From e8ffecbd3606a1558563e0cb5f8ea296a6ab2ede Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Thu, 25 Oct 2018 07:10:01 +0900 Subject: [PATCH] Set @body_classes to admin layout (#9081) --- app/controllers/admin/base_controller.rb | 11 +++++++++-- app/controllers/filters_controller.rb | 5 +++++ app/controllers/invites_controller.rb | 5 +++++ app/controllers/settings/applications_controller.rb | 5 +++++ app/controllers/settings/deletes_controller.rb | 5 +++++ app/controllers/settings/exports_controller.rb | 7 +++++++ .../settings/follower_domains_controller.rb | 5 +++++ app/controllers/settings/imports_controller.rb | 5 +++++ app/controllers/settings/migrations_controller.rb | 5 +++++ app/controllers/settings/notifications_controller.rb | 5 +++++ app/controllers/settings/preferences_controller.rb | 5 +++++ app/controllers/settings/profiles_controller.rb | 5 +++++ app/controllers/settings/sessions_controller.rb | 5 +++++ .../confirmations_controller.rb | 5 +++++ .../recovery_codes_controller.rb | 7 +++++++ .../settings/two_factor_authentications_controller.rb | 5 +++++ app/views/layouts/admin.html.haml | 2 +- 17 files changed, 89 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 7fb69d5789..8593b582a6 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -5,8 +5,15 @@ module Admin include Authorization include AccountableConcern - before_action :require_staff! - layout 'admin' + + before_action :require_staff! + before_action :set_body_classes + + private + + def set_body_classes + @body_classes = 'admin' + end end end diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb index 175dbab072..d2e0fb7390 100644 --- a/app/controllers/filters_controller.rb +++ b/app/controllers/filters_controller.rb @@ -7,6 +7,7 @@ class FiltersController < ApplicationController before_action :set_filters, only: :index before_action :set_filter, only: [:edit, :update, :destroy] + before_action :set_body_classes def index @filters = current_account.custom_filters @@ -54,4 +55,8 @@ class FiltersController < ApplicationController def resource_params params.require(:custom_filter).permit(:phrase, :expires_in, :irreversible, :whole_word, context: []) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 3aaa2776ff..fdb3a0962a 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -6,6 +6,7 @@ class InvitesController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def index authorize :invite, :create? @@ -44,4 +45,8 @@ class InvitesController < ApplicationController def resource_params params.require(:invite).permit(:max_uses, :expires_in, :autofollow) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/applications_controller.rb b/app/controllers/settings/applications_controller.rb index 2a49623115..a1a2c57fa0 100644 --- a/app/controllers/settings/applications_controller.rb +++ b/app/controllers/settings/applications_controller.rb @@ -6,6 +6,7 @@ class Settings::ApplicationsController < ApplicationController before_action :authenticate_user! before_action :set_application, only: [:show, :update, :destroy, :regenerate] before_action :prepare_scopes, only: [:create, :update] + before_action :set_body_classes def index @applications = current_user.applications.order(id: :desc).page(params[:page]) @@ -69,4 +70,8 @@ class Settings::ApplicationsController < ApplicationController scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil) params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes.is_a? Array end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/deletes_controller.rb b/app/controllers/settings/deletes_controller.rb index 80002b995e..97f3946c87 100644 --- a/app/controllers/settings/deletes_controller.rb +++ b/app/controllers/settings/deletes_controller.rb @@ -5,6 +5,7 @@ class Settings::DeletesController < ApplicationController before_action :check_enabled_deletion before_action :authenticate_user! + before_action :set_body_classes def show @confirmation = Form::DeleteConfirmation.new @@ -29,4 +30,8 @@ class Settings::DeletesController < ApplicationController def delete_params params.require(:form_delete_confirmation).permit(:password) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/exports_controller.rb b/app/controllers/settings/exports_controller.rb index 869e11d3bf..3a2334ef00 100644 --- a/app/controllers/settings/exports_controller.rb +++ b/app/controllers/settings/exports_controller.rb @@ -6,6 +6,7 @@ class Settings::ExportsController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def show @export = Export.new(current_account) @@ -20,4 +21,10 @@ class Settings::ExportsController < ApplicationController redirect_to settings_export_path end + + private + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/follower_domains_controller.rb b/app/controllers/settings/follower_domains_controller.rb index a128bd1361..9c39e66bbb 100644 --- a/app/controllers/settings/follower_domains_controller.rb +++ b/app/controllers/settings/follower_domains_controller.rb @@ -4,6 +4,7 @@ class Settings::FollowerDomainsController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def show @account = current_account @@ -25,4 +26,8 @@ class Settings::FollowerDomainsController < ApplicationController def bulk_params params.permit(select: []) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/imports_controller.rb b/app/controllers/settings/imports_controller.rb index 0db13d1ca6..e9548ce629 100644 --- a/app/controllers/settings/imports_controller.rb +++ b/app/controllers/settings/imports_controller.rb @@ -5,6 +5,7 @@ class Settings::ImportsController < ApplicationController before_action :authenticate_user! before_action :set_account + before_action :set_body_classes def show @import = Import.new @@ -31,4 +32,8 @@ class Settings::ImportsController < ApplicationController def import_params params.require(:import).permit(:data, :type) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/migrations_controller.rb b/app/controllers/settings/migrations_controller.rb index bc6436b87a..bd4f9c87af 100644 --- a/app/controllers/settings/migrations_controller.rb +++ b/app/controllers/settings/migrations_controller.rb @@ -4,6 +4,7 @@ class Settings::MigrationsController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def show @migration = Form::Migration.new(account: current_account.moved_to_account) @@ -31,4 +32,8 @@ class Settings::MigrationsController < ApplicationController current_account.moved_to_account_id != @migration.account&.id && current_account.id != @migration.account&.id end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/notifications_controller.rb b/app/controllers/settings/notifications_controller.rb index fe45c17b22..d0754296cc 100644 --- a/app/controllers/settings/notifications_controller.rb +++ b/app/controllers/settings/notifications_controller.rb @@ -4,6 +4,7 @@ class Settings::NotificationsController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def show; end @@ -29,4 +30,8 @@ class Settings::NotificationsController < ApplicationController interactions: %i(must_be_follower must_be_following must_be_following_dm) ) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index b83900f07d..7bb5fb112a 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -4,6 +4,7 @@ class Settings::PreferencesController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def show; end @@ -51,4 +52,8 @@ class Settings::PreferencesController < ApplicationController interactions: %i(must_be_follower must_be_following) ) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index fe265c81d2..5b3bfd71fe 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -7,6 +7,7 @@ class Settings::ProfilesController < ApplicationController before_action :authenticate_user! before_action :set_account + before_action :set_body_classes obfuscate_filename [:account, :avatar] obfuscate_filename [:account, :header] @@ -34,4 +35,8 @@ class Settings::ProfilesController < ApplicationController def set_account @account = current_user.account end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/sessions_controller.rb b/app/controllers/settings/sessions_controller.rb index 0da1b027b8..74cebc07b6 100644 --- a/app/controllers/settings/sessions_controller.rb +++ b/app/controllers/settings/sessions_controller.rb @@ -2,6 +2,7 @@ class Settings::SessionsController < ApplicationController before_action :set_session, only: :destroy + before_action :set_body_classes def destroy @session.destroy! @@ -14,4 +15,8 @@ class Settings::SessionsController < ApplicationController def set_session @session = current_user.session_activations.find(params[:id]) end + + def set_body_classes + @body_classes = 'admin' + end end diff --git a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb index 8d534960d4..ee567c2a7c 100644 --- a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb +++ b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb @@ -7,6 +7,7 @@ module Settings before_action :authenticate_user! before_action :ensure_otp_secret + before_action :set_body_classes def new prepare_two_factor_form @@ -43,6 +44,10 @@ module Settings def ensure_otp_secret redirect_to settings_two_factor_authentication_path unless current_user.otp_secret end + + def set_body_classes + @body_classes = 'admin' + end end end end diff --git a/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb b/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb index e591e9502d..bfb103620b 100644 --- a/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb +++ b/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb @@ -6,6 +6,7 @@ module Settings layout 'admin' before_action :authenticate_user! + before_action :set_body_classes def create @recovery_codes = current_user.generate_otp_backup_codes! @@ -13,6 +14,12 @@ module Settings flash[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated') render :index end + + private + + def set_body_classes + @body_classes = 'admin' + end end end end diff --git a/app/controllers/settings/two_factor_authentications_controller.rb b/app/controllers/settings/two_factor_authentications_controller.rb index 863cc7351b..e4d8aed413 100644 --- a/app/controllers/settings/two_factor_authentications_controller.rb +++ b/app/controllers/settings/two_factor_authentications_controller.rb @@ -6,6 +6,7 @@ module Settings before_action :authenticate_user! before_action :verify_otp_required, only: [:create] + before_action :set_body_classes def show @confirmation = Form::TwoFactorConfirmation.new @@ -43,5 +44,9 @@ module Settings current_user.validate_and_consume_otp!(confirmation_params[:code]) || current_user.invalidate_otp_backup_code!(confirmation_params[:code]) end + + def set_body_classes + @body_classes = 'admin' + end end end diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index c98d85f7bf..6ce67d91e7 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -17,4 +17,4 @@ = yield -= render template: 'layouts/application', locals: { body_classes: 'admin' } += render template: 'layouts/application'