WJaunita45604 on X asked for the Installed tab to be filtered by Discover's categories, and by whether a plugin is official, with Discover's own categorisation. Installed now has the same strip and menu as Discover: - the kinds strip (All, Subscriptions, Middleware, Agents, Tools, Pages), each with how many are installed; - the Origin menu (magpie community, other authors, unofficial on GitHub), without Discover's "Not installed only". browseBar's strip and Origin button are split out (kindStrip, originButton) so both tabs draw the same component. The rest is in plugininstalled.js, imported when Plugins first draws, as plugingrid.js is (old-webkit lists it); until it is in, the list is drawn whole. What is left in the core is 674 bytes, within its budget's room. A plugin Discover lists is put where its card is (kindOf, srcOf). One it doesn't list (a folder, an unlisted npm package) is put by what it is: middleware or gateway, agent, tools only, a page, else a subscription; from GitHub, @magpie-community, else other authors. The strip shows only when two or more kinds are installed, and the menu only when two or more origins are. A pick that leaves nothing says "No plugin matches" with Show all. Installed keeps its pick across tabs and Discover keeps its own. The list head grows when it wraps (.pm-listhead.pm-bar), so a narrow row doesn't run under the list. There are no new strings, no native select (the app menu), and no left-border accents. New plugin-installed-filter.test.cjs: seven installed plugins of every kind and origin, two of them GitHub repos from fixtures/plugins-github-31. It runs in every language, both engines, at 1100px and 420px. Run (on mote, Playwright 1.62.0, chromium + webkit): the new test, 20 of 20. Red on origin/main005178104(no strip on Installed: waitFor .pm-listhead .pm-kinds times out). On mote, both engines: at base077421733, go test -tags nogui ./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs, old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and the two the scroll buttons' commit fixes. Rebased on origin/main6e03b746bwith that commit: TestCoreScriptBudget ok with no raise; add-sheet*, provider-env-paste, plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt, the eight plugin files red before, old-webkit, i18n-keys and the scroll files that commit names: green but the reds below. Reds that fail the same on origin/main6e03b746b, run alone there: old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved (#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938), plugin-page-foreign-error (#6117), plugin-option-placement (#6559), rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de 375 (#5869). The whole GUI suite was not run: mote's and mica's loads were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12). Rebased on origin/main1730c75b9, the pushed head (mote): go test -tags nogui ./internal/gui ok; add-sheet*, provider-env-paste, plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt, i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.a82bae2bd, landed on top since, changes the routing plugin, the gateway and i18n.js keys of its own, none of these files; the core measure at the pushed head is 1,267,635 of 1,268,961.
40 lines
2.4 KiB
JavaScript
40 lines
2.4 KiB
JavaScript
// Installed narrowed as Discover is (WJaunita45604 on X): the same strip of
|
|
// kinds and the same Origin menu, over what is installed. Each plugin is
|
|
// put where Discover puts it: its card's kind and origin (kindOf, srcOf),
|
|
// and for one the market doesn't list, the same read from what it is: its
|
|
// chips' kind, a git one on GitHub, a @magpie-community package the
|
|
// community's, else another author's. plugins.js imports this when its
|
|
// page is first drawn, so it weighs nothing on the core; until then the
|
|
// list is drawn whole. st holds the picks; the strip and the menu show
|
|
// only where there are two or more to pick from.
|
|
window.pmInstalled = function ({ es, st, everything, entryOf, kindOf, srcOf, name, isGit, ORDER, SOURCES, kindStrip, originButton, drawBody }) {
|
|
const card = new Map();
|
|
for (const l of everything(() => true)) { const e = entryOf(l.package); if (e && !card.has(e)) card.set(e, l); }
|
|
const sorted = es.map((e) => {
|
|
const l = card.get(e);
|
|
if (l) return { e, kind: kindOf(l), src: srcOf(l) };
|
|
const kind = e.middleware || e.isMiddleware || e.gateway || e.isGateway ? "mw" : e.agent || e.isAgent ? "ag" : e.tools?.length && !e.providers?.length ? "tl" : e.page && !e.providers?.length ? "pg" : "pv";
|
|
return { e, kind, src: isGit(e.spec) ? "gh" : name(e.spec).startsWith("@magpie-community/") ? "ours" : "third" };
|
|
});
|
|
const kinds = ORDER.filter((k) => sorted.some((x) => x.kind === k));
|
|
const srcs = SOURCES.map(([v]) => v).filter((v) => v && sorted.some((x) => x.src === v));
|
|
if (!kinds.includes(st.kind) || kinds.length < 2) st.kind = "";
|
|
if (!srcs.includes(st.src) || srcs.length < 2) st.src = "";
|
|
const base = sorted.filter((x) => !st.src || x.src === st.src);
|
|
const shown = base.filter((x) => !st.kind || x.kind === st.kind).map((x) => x.e);
|
|
let none = null;
|
|
if (!shown.length) {
|
|
// a pick that leaves nothing says so, with the way back
|
|
none = el("div", "pm-ghnone");
|
|
const every = el("button", "text", t("Show all"));
|
|
every.type = "button";
|
|
every.onclick = () => { st.kind = st.src = ""; drawBody(); };
|
|
none.append(el("span", "", t("No plugin matches")), every);
|
|
}
|
|
return {
|
|
shown, none,
|
|
strip: kinds.length > 1 ? kindStrip(kinds, (k) => base.filter((x) => !k || x.kind === k).length, st.kind, (k) => { st.kind = k; drawBody(); }) : null,
|
|
pop: srcs.length > 1 ? originButton(st.src, null, (v) => { st.src = v; drawBody(); }) : null,
|
|
};
|
|
};
|