A platform for community discussion. Free, open, simple.
UX: Improve safe-mode usability (#17929)
David Taylor64a66cf82bb1
diff --git a/app/assets/javascripts/discourse/app/lib/source-identifier.js b/app/assets/javascripts/discourse/app/lib/source-identifier.jsindex 1294fec6d39..555c1cac8c0 100644--- a/app/assets/javascripts/discourse/app/lib/source-identifier.js+++ b/app/assets/javascripts/discourse/app/lib/source-identifier.js@@ -58,7 +58,7 @@ export function getThemeInfo(id) {return {id,name,- path: getURL(`/admin/customize/themes/${id}?safe_mode=no_custom`),+ path: getURL(`/admin/customize/themes/${id}?safe_mode=no_themes`),};}diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 94e3808bc1d..7e6857625b8 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -444,19 +444,23 @@ class ApplicationController < ActionController::Basesession[:mobile_view] = params[:mobile_view] if params.has_key?(:mobile_view)end- NO_CUSTOM = "no_custom"+ NO_THEMES = "no_themes"NO_PLUGINS = "no_plugins"- ONLY_OFFICIAL = "only_official"+ NO_UNOFFICIAL_PLUGINS = "no_unofficial_plugins"SAFE_MODE = "safe_mode"+ LEGACY_NO_THEMES = "no_custom"+ LEGACY_NO_UNOFFICIAL_PLUGINS = "only_official"+def resolve_safe_modereturn unless guardian.can_enable_safe_mode?safe_mode = params[SAFE_MODE]- if safe_mode- request.env[NO_CUSTOM] = !!safe_mode.include?(NO_CUSTOM)- request.env[NO_PLUGINS] = !!safe_mode.include?(NO_PLUGINS)- request.env[ONLY_OFFICIAL] = !!safe_mode.include?(ONLY_OFFICIAL)+ if safe_mode&.is_a?(String)+ safe_mode = safe_mode.split(",")+ request.env[NO_THEMES] = safe_mode.include?(NO_THEMES) || safe_mode.include?(LEGACY_NO_THEMES)+ request.env[NO_PLUGINS] = safe_mode.include?(NO_PLUGINS)+ request.env[NO_UNOFFICIAL_PLUGINS] = safe_mode.include?(NO_UNOFFICIAL_PLUGINS) || safe_mode.include?(LEGACY_NO_UNOFFICIAL_PLUGINS)endend@@ -464,7 +468,7 @@ class ApplicationController < ActionController::Basereturn if request.format == "js"resolve_safe_mode- return if request.env[NO_CUSTOM]+ return if request.env[NO_THEMES]theme_id = nildiff --git a/app/controllers/safe_mode_controller.rb b/app/controllers/safe_mode_controller.rbindex d0742eba102..3ffe891d173 100644--- a/app/controllers/safe_mode_controller.rb+++ b/app/controllers/safe_mode_controller.rb@@ -12,12 +12,17 @@ class SafeModeController < ApplicationControllerdef entersafe_mode = []- safe_mode << "no_custom" if params["no_customizations"] == "true"- safe_mode << "no_plugins" if params["no_plugins"] == "true"- safe_mode << "only_official" if params["only_official"] == "true"++ 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"+ endif safe_mode.length > 0- redirect_to path("/?safe_mode=#{safe_mode.join("%2C")}")+ redirect_to path("/?safe_mode=#{safe_mode.join(",")}")elseflash[:must_select] = trueredirect_to safe_mode_path@@ -31,7 +36,7 @@ class SafeModeController < ApplicationControllerenddef force_safe_mode_for_route- request.env[ApplicationController::NO_CUSTOM] = true+ request.env[ApplicationController::NO_THEMES] = truerequest.env[ApplicationController::NO_PLUGINS] = trueenddiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex b478e56a309..43c5418baf9 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -418,7 +418,7 @@ module ApplicationHelperenddef customization_disabled?- request.env[ApplicationController::NO_CUSTOM]+ request.env[ApplicationController::NO_THEMES]enddef include_ios_native_app_banner?@@ -441,15 +441,15 @@ module ApplicationHelperenddef allow_third_party_plugins?- allow_plugins? && !request.env[ApplicationController::ONLY_OFFICIAL]+ allow_plugins? && !request.env[ApplicationController::NO_UNOFFICIAL_PLUGINS]enddef normalized_safe_modesafe_mode = []- safe_mode << ApplicationController::NO_CUSTOM if customization_disabled?+ safe_mode << ApplicationController::NO_THEMES if customization_disabled?safe_mode << ApplicationController::NO_PLUGINS if !allow_plugins?- safe_mode << ApplicationController::ONLY_OFFICIAL if !allow_third_party_plugins?+ safe_mode << ApplicationController::NO_UNOFFICIAL_PLUGINS if !allow_third_party_plugins?safe_mode.join(",")enddiff --git a/app/views/safe_mode/index.html.erb b/app/views/safe_mode/index.html.erbindex 0405a079462..c6ee82531f6 100644--- a/app/views/safe_mode/index.html.erb+++ b/app/views/safe_mode/index.html.erb@@ -6,14 +6,14 @@</p><p><label>- <%= check_box_tag 'no_customizations', true, !flash[:must_select]%>- <%= t 'safe_mode.no_customizations' %>+ <%= check_box_tag 'no_themes', true, !flash[:must_select]%>+ <%= t 'safe_mode.no_themes' %></label></p><p><label>- <%= check_box_tag 'only_official', true, !flash[:must_select] %>- <%= t 'safe_mode.only_official' %>+ <%= check_box_tag 'no_unofficial_plugins', true, !flash[:must_select] %>+ <%= t 'safe_mode.no_unofficial_plugins' %></label></p><p>diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 23d38246a53..c966b7c8097 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -4885,9 +4885,9 @@ en:safe_mode:title: "Enter safe mode"- description: "Safe mode allows you to test your site without loading plugins or site customizations."- no_customizations: "Disable current theme"- only_official: "Disable unofficial plugins"+ description: "Safe mode allows you to test your site without loading plugins or themes."+ no_themes: "Disable themes and theme components"+ no_unofficial_plugins: "Disable unofficial plugins"no_plugins: "Disable all plugins"enter: "Enter Safe Mode"must_select: "You must select at least one option to enter safe mode."