diff --git a/lib/common/static/instance_embed.js b/lib/common/static/instance_embed.js
index cfe57d8..2c88701 100644
--- a/lib/common/static/instance_embed.js
+++ b/lib/common/static/instance_embed.js
@@ -235,9 +235,57 @@
const parts = [];
if (qs) parts.push(qs);
parts.push("embed=1");
+ if (tab === "settings") {
+ try {
+ const st = new URLSearchParams(location.search).get("settings_tab");
+ if (st) parts.push("settings_tab=" + encodeURIComponent(st));
+ } catch (_) {}
+ }
return url + "?" + parts.join("&");
}
+ function setSettingsSubTabInUrl(key) {
+ if (!key) return;
+ try {
+ const q = new URLSearchParams(location.search);
+ q.set("tab", "settings");
+ q.set("settings_tab", key);
+ q.set("embed", "1");
+ history.replaceState(null, "", "/embed?" + q.toString());
+ } catch (_) {}
+ }
+
+ function activateSettingsSubTab(key) {
+ if (!key) return;
+ setSettingsSubTabInUrl(key);
+ const pane = tabPanes.get("settings") || document;
+ const radio = pane.querySelector(
+ 'input.env-tab-radio[data-settings-tab="' + key + '"]'
+ );
+ if (radio) radio.checked = true;
+ }
+
+ function formActionPath(form) {
+ try {
+ return new URL(form.action || "", location.href).pathname.replace(/\/$/, "") || "/";
+ } catch (_) {
+ return "";
+ }
+ }
+
+ function maybeKeepSettingsSubTabAfterForm(form) {
+ const path = formActionPath(form);
+ if (path === "/manual_transfer") {
+ setSettingsSubTabInUrl("transfer");
+ return "transfer";
+ }
+ if (path.indexOf("/api/options/transfer") >= 0 || path.indexOf("/api/options/cross-transfer") >= 0) {
+ setSettingsSubTabInUrl("options_transfer");
+ return "options_transfer";
+ }
+ return "";
+ }
+
async function fetchTabHtml(tab) {
const r = await fetch(embedPageUrl(tab), {
credentials: "same-origin",
@@ -400,14 +448,15 @@
}
}
const fd = new FormData(form);
+ const keepSub = maybeKeepSettingsSubTabAfterForm(form);
return fetch(form.action, {
method: form.method || "POST",
body: fd,
credentials: "same-origin",
redirect: "manual",
})
- .then(() => reloadCurrentTab())
- .catch(() => reloadCurrentTab());
+ .then(() => reloadCurrentTab().then(() => activateSettingsSubTab(keepSub)))
+ .catch(() => reloadCurrentTab().then(() => activateSettingsSubTab(keepSub)));
}
function patchApplyListWindow() {
@@ -466,14 +515,15 @@
if (CUSTOM_SUBMIT_FORM_IDS.has(form.id)) return;
ev.preventDefault();
const fd = new FormData(form);
+ const keepSub = maybeKeepSettingsSubTabAfterForm(form);
fetch(form.action, {
method: form.method || "POST",
body: fd,
credentials: "same-origin",
redirect: "manual",
})
- .then(() => reloadCurrentTab())
- .catch(() => reloadCurrentTab());
+ .then(() => reloadCurrentTab().then(() => activateSettingsSubTab(keepSub)))
+ .catch(() => reloadCurrentTab().then(() => activateSettingsSubTab(keepSub)));
},
true
);
diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html
index f3e756f..e140d89 100644
--- a/lib/instance/templates/embed_shell.html
+++ b/lib/instance/templates/embed_shell.html
@@ -120,6 +120,6 @@ window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
-
+