diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js index f89a37ae1..f6390de78 100644 --- a/internal/gui/assets/plugins/library/client.js +++ b/internal/gui/assets/plugins/library/client.js @@ -5791,7 +5791,14 @@ magpie.plugin("library", (ctx) => { } nm.append(b); } else if (c?.status === "unknown") { - nm.append(tag(t("Not checked"), "lib-unchecked", checkError(c))); + const b = tag(t("Not checked"), "lib-unchecked", checkError(c)); + // GitHub's limit without a token: the tag leads to where one is + // added, Settings › Network and sharing's GitHub row + if (c.limited && !c.limited.token) { + b.classList.add("link"); + b.onclick = (e) => { e.stopPropagation(); openSettingsAt(e, "network", "#githubList .row"); }; + } + nm.append(b); } // changed here since it was fetched from GitHub (#1449): an update asks // before it replaces that diff --git a/internal/gui/assets/plugins/library/library.css b/internal/gui/assets/plugins/library/library.css index d8712d4a3..b229ebb7f 100644 --- a/internal/gui/assets/plugins/library/library.css +++ b/internal/gui/assets/plugins/library/library.css @@ -234,6 +234,8 @@ button.row.lib-hubfolded:hover { background: var(--pill); } .lib-tag.lib-new.link { cursor: pointer; } .lib-tag.lib-new.link:hover { background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft)); } .lib-tag.lib-unchecked { color: var(--faint); font-weight: 400; } +.lib-tag.lib-unchecked.link { cursor: pointer; } +.lib-tag.lib-unchecked.link:hover { color: var(--fg-2); } .lib-tag.lib-signed { color: var(--green); background: var(--green-soft); } .lib-tag.lib-signed::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; } diff --git a/internal/gui/tests/github-token.test.cjs b/internal/gui/tests/github-token.test.cjs index f3b962311..393372ea5 100644 --- a/internal/gui/tests/github-token.test.cjs +++ b/internal/gui/tests/github-token.test.cjs @@ -4,7 +4,8 @@ // row: a token typed is saved on its own and shown masked, with Remove; one // GITHUB_TOKEN / GH_TOKEN gives is said; one refused is said in the row, // what was typed kept; nothing scrolls. And a check GitHub limited says so -// in the page's words: until when, and that a token in Settings raises it. +// in the page's words: until when, and that a token in Settings raises it, +// and its tag opens the token's row there. // In English and Chinese, with the API faked. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); @@ -134,7 +135,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const errors = []; page.on("pageerror", (e) => errors.push(e.message)); for (const st of [{ mask: "", from: "" }, { mask: "ghp_…0123", from: "settings" }]) { - await page.unroute("**/*"); + // a click before can leave a file being served: let it go + await page.unrouteAll({ behavior: "ignoreErrors" }); await page.route("**/*", serve(lang, [], st)); await watchSettingsReads(page); await page.goto("http://magpie.test/?view=library"); @@ -149,6 +151,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const want = (st.from ? w.withToken : w.limited).replace("{time}", time); assert((await page.locator("#status").textContent()).includes(want), `status: ${await page.locator("#status").textContent()}`); assert.equal(await page.locator("#view-library .lib-unchecked").getAttribute("title"), want); + // without a token the tag leads to the GitHub token's row + if (!st.from) { + await page.locator("#view-library .lib-unchecked").click(); + await page.locator("#view-settings #githubList .row.flash").waitFor(); + } else assert.equal(await page.locator("#view-library .lib-unchecked.link").count(), 0, "a token's own limit has nothing to add"); } assert.deepEqual(errors, []); });