Once the Agents page's Get started card was hidden (POST
/api/settings/guide {hidden:true}) nothing in the app brought it back.
Hiding it now says where it comes back ("Get started hidden; Settings ›
General brings it back"), and General has a Get started row with Show,
only while the card is hidden and would otherwise show (setup not done,
not gateway mode). Show posts {hidden:false}, redraws the Agents page and
says so; the row goes. The row lives in guideback.js, imported by
navpages.js beside the sidebar's pages, so the core grows by one status
line. Settings' search finds it by its name.
Run (mote, at this tree):
- getting-started, nav-pages-hidden, nav-pages-order, settings-general,
settings-search, i18n-keys, gui-de, Chromium and WebKit, every
language: 117 tests, all pass after the fake server answered
/api/settings with the guide flag as the real one does.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.
Broken by hand, each red, then put back:
- renderNavPages not calling guideBack: getting-started 20 of 60 red
(the row never shows).
- the hide's status line removed: getting-started 30 of 60 red.
Not tried: the real app window.
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
// Settings › General › Get started: the Agents page's card, once its ×
|
||
// put it away, brought back (nothing did, and a user who hid it before
|
||
// setting up had no guide left). The row shows only while the card is
|
||
// hidden and would show otherwise, so it is seldom there. navpages.js
|
||
// imports this when Settings draws, so it weighs nothing on the core.
|
||
window.guideBack = function () {
|
||
const row = $("#guideBackRow");
|
||
if (!row || !state) return;
|
||
const set = ((state.served || 0) > 0 || anyMagpieModels()) && state.agents.some((a) => a.wired);
|
||
row.hidden = gatewayMode || !state.settings?.guideHidden || set;
|
||
if (row.hidden || row.querySelector("button")) return;
|
||
const b = el("button", "text", t("Show"));
|
||
b.type = "button";
|
||
b.onclick = async () => {
|
||
b.disabled = true;
|
||
try {
|
||
prefs = await writingPrefs(api("settings/guide", { hidden: false }));
|
||
state.settings = prefs;
|
||
renderAgents();
|
||
status(t("Get started is back on the Agents page"), "ok");
|
||
} catch (err) {
|
||
statusTErr(err);
|
||
}
|
||
b.disabled = false;
|
||
window.guideBack();
|
||
};
|
||
row.append(b);
|
||
};
|