mirror of
https://github.com/discourse/discourse.git
synced 2024-12-27 05:23:53 +08:00
fadcfd1451
This commit adds an additional toggle to our safe-mode system. When enabled, it will cause all deprecation messages to become exceptions. This gives admins a way to test their themes/plugins against upcoming Discourse changes without needing to use the browser developer tools.
45 lines
1.0 KiB
Ruby
45 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SafeModeController < ApplicationController
|
|
layout "no_ember"
|
|
before_action :ensure_safe_mode_enabled
|
|
before_action :force_safe_mode_for_route
|
|
|
|
skip_before_action :preload_json, :check_xhr
|
|
|
|
def index
|
|
end
|
|
|
|
def enter
|
|
safe_mode = []
|
|
|
|
safe_mode << "no_themes" if params["no_themes"] == "true"
|
|
|
|
if params["no_plugins"] == "true"
|
|
safe_mode << "no_plugins"
|
|
elsif params["no_unofficial_plugins"] == "true"
|
|
safe_mode << "no_unofficial_plugins"
|
|
elsif params["deprecation_errors"] == "true"
|
|
safe_mode << "deprecation_errors"
|
|
end
|
|
|
|
if safe_mode.length > 0
|
|
redirect_to path("/?safe_mode=#{safe_mode.join(",")}")
|
|
else
|
|
flash[:must_select] = true
|
|
redirect_to safe_mode_path
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def ensure_safe_mode_enabled
|
|
raise Discourse::NotFound unless guardian.can_enable_safe_mode?
|
|
end
|
|
|
|
def force_safe_mode_for_route
|
|
request.env[ApplicationController::NO_THEMES] = true
|
|
request.env[ApplicationController::NO_PLUGINS] = true
|
|
end
|
|
end
|