Skip to content

Commit cf13198

Browse files
authored
Hide public config state panel (#30)
1 parent 9d37817 commit cf13198

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

tests/strategy_switch_worker_validation.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ assert.equal(indexHtml.includes(".innerHTML"), false);
1313
assert.ok(indexHtml.includes('<body class="app-loading">'));
1414
assert.ok(indexHtml.includes('id="boot-screen"'));
1515
assert.ok(indexHtml.includes('id="app-shell"'));
16-
assert.ok(indexHtml.includes('publicSummary: "公开预览"'));
16+
assert.ok(indexHtml.includes(".switch-surface.summary-hidden"));
17+
assert.ok(indexHtml.includes('summaryPanel.hidden = !showSummary'));
18+
assert.ok(indexHtml.includes('switchSurface.classList.toggle("summary-hidden", !showSummary)'));
19+
assert.equal(indexHtml.includes("publicSummary"), false);
1720
assert.match(indexHtml, /body\.app-loading \.shell\s*\{\s*display: none;/);
1821

1922
const headers = __test.responseHeaders({ "Content-Type": "text/html; charset=utf-8" });

web/strategy-switch-console/index.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@
363363
align-items: stretch;
364364
}
365365

366+
.switch-surface.summary-hidden {
367+
grid-template-columns: minmax(0, 1fr);
368+
}
369+
366370
.switch-panel,
367371
.summary-panel {
368372
min-width: 0;
@@ -845,7 +849,6 @@ <h2 data-i18n="summary">切换摘要</h2>
845849
live: "实盘",
846850
paper: "Dry run",
847851
summary: "当前配置状态",
848-
publicSummary: "公开预览",
849852
copySummary: "复制状态",
850853
loginToRun: "登录后切换",
851854
loadingConfig: "读取配置中",
@@ -872,8 +875,6 @@ <h2 data-i18n="summary">切换摘要</h2>
872875
currentStrategy: "当前策略",
873876
nextStrategy: "选择策略",
874877
notRead: "未读取",
875-
publicPreview: "公开示例",
876-
accountConfigLoaded: "账号配置已加载",
877878
},
878879
en: {
879880
appTitle: "Strategy Switch",
@@ -895,7 +896,6 @@ <h2 data-i18n="summary">切换摘要</h2>
895896
live: "Live",
896897
paper: "Dry run",
897898
summary: "Current Config",
898-
publicSummary: "Public Preview",
899899
copySummary: "Copy state",
900900
loginToRun: "Sign in to switch",
901901
loadingConfig: "Loading config",
@@ -922,8 +922,6 @@ <h2 data-i18n="summary">切换摘要</h2>
922922
currentStrategy: "Current strategy",
923923
nextStrategy: "Selected strategy",
924924
notRead: "Not read",
925-
publicPreview: "Public preview",
926-
accountConfigLoaded: "Account config loaded",
927925
},
928926
};
929927

@@ -1294,10 +1292,17 @@ <h2 data-i18n="summary">切换摘要</h2>
12941292
}
12951293

12961294
function renderSummary() {
1295+
const showSummary = Boolean(state.auth.allowed);
1296+
const summaryPanel = document.querySelector(".summary-panel");
1297+
const switchSurface = document.querySelector(".switch-surface");
1298+
summaryPanel.hidden = !showSummary;
1299+
switchSurface.classList.toggle("summary-hidden", !showSummary);
1300+
if (!showSummary) return;
1301+
12971302
const inputs = buildInputs();
12981303
const list = el("summary-list");
12991304
list.replaceChildren();
1300-
document.querySelector(".summary-head h2").textContent = state.auth.allowed ? t("summary") : t("publicSummary");
1305+
document.querySelector(".summary-head h2").textContent = t("summary");
13011306
for (const [label, value] of summaryRows(inputs)) {
13021307
const row = document.createElement("div");
13031308
row.className = "summary-row";
@@ -1309,7 +1314,10 @@ <h2 data-i18n="summary">切换摘要</h2>
13091314
list.appendChild(row);
13101315
}
13111316

1312-
el("mode-pill").textContent = modeLabel(inputs.execution_mode);
1317+
const account = selectedAccount();
1318+
const currentEntry = currentEntryForAccount(state.selected, account);
1319+
const currentMode = normalizeExecutionMode(currentEntry?.execution_mode, currentEntry?.dry_run_only);
1320+
el("mode-pill").textContent = currentMode ? modeLabel(currentMode) : t("notRead");
13131321
}
13141322

13151323
function renderAuth() {

web/strategy-switch-console/page_asset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)