diff --git a/app/assets/javascripts/discourse/app/instance-initializers/live-development.js b/app/assets/javascripts/discourse/app/instance-initializers/live-development.js index 132ad0782ce..16d630955ba 100644 --- a/app/assets/javascripts/discourse/app/instance-initializers/live-development.js +++ b/app/assets/javascripts/discourse/app/instance-initializers/live-development.js @@ -9,21 +9,20 @@ export default { this.messageBus = owner.lookup("service:message-bus"); this.session = owner.lookup("service:session"); - // Preserve preview_theme_id=## and pp=async-flamegraph parameters across pages + const PRESERVED_QUERY_PARAMS = ["preview_theme_id", "pp", "safe_mode"]; const params = new URLSearchParams(window.location.search); - const previewThemeId = params.get("preview_theme_id"); - const flamegraph = params.get("pp") === "async-flamegraph"; - if (flamegraph || previewThemeId !== null) { + const preservedParamValues = PRESERVED_QUERY_PARAMS.map((p) => [ + p, + params.get(p), + ]).filter(([, v]) => v); + if (preservedParamValues.length) { ["replaceState", "pushState"].forEach((funcName) => { const originalFunc = window.history[funcName]; window.history[funcName] = (stateObj, name, rawUrl) => { const url = new URL(rawUrl, window.location); - if (previewThemeId !== null) { - url.searchParams.set("preview_theme_id", previewThemeId); - } - if (flamegraph) { - url.searchParams.set("pp", "async-flamegraph"); + for (const [param, value] of preservedParamValues) { + url.searchParams.set(param, value); } return originalFunc.call(window.history, stateObj, name, url.href); diff --git a/app/views/safe_mode/index.html.erb b/app/views/safe_mode/index.html.erb index c6ee82531f6..d5d8cc0728f 100644 --- a/app/views/safe_mode/index.html.erb +++ b/app/views/safe_mode/index.html.erb @@ -26,10 +26,7 @@ <%= submit_tag t('safe_mode.enter'), class: 'btn btn-danger' %> <%- if flash[:must_select] %> - - - - <%= t 'safe_mode.must_select' %> + ⚠️ <%= t 'safe_mode.must_select' %> <%- end %>