Replace the stacked install modals (browse -> details -> import review) with page-based flows so the primary action is always reachable: - /manage/custom-widgets/workshop browses submissions as a card grid with large previews, sitting in a tab next to the installed widgets - /manage/custom-widgets/workshop/[id] merges the listing, security review and source setup onto one page with a sticky install footer - /manage/custom-widgets/publish/[id] replaces the publish modal - /manage/workshop redirects; its navbar entry is gone - the Custom CSS picker collapses from three modals to one Extract useCustomWidgetImport and ImportReviewContent so the Workshop page and the file/clipboard dialog share one import pipeline. Votes now show the viewer's own choice filled Reddit-style, backed by a new user-votes query, and screenshots get a zoomable lightbox. Rework the installed list onto ManageCollectionItem: show the widget description, replace the cryptic "JSX - 2" badge with plain request and origin facts, and swap the toggle and bare pencil for a status badge, a labelled Edit button and a menu entry for enable/disable. Fixes found while reviewing: - importing could run twice and duplicate a widget; guard on pending and succeeded, and return to the installed list instead of the heavy edit form - a background refetch of the submission (window focus, or the invalidation a vote triggers) reset the source setup and silently wiped part-typed credentials; key the reset on the sources, not the object - breadcrumbs raised MISSING_MESSAGE for unmapped dynamic segments; fall back to the raw segment via t.has - publishing had no in-flight guard and could post duplicate listings - tooltips on disabled vote and report controls never fired, making the sign-in hint unreachable
75 lines
2.9 KiB
TypeScript
75 lines
2.9 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
import { resolve } from "node:path";
|
|
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
const languageDirectory = resolve(import.meta.dirname, "../../../translation/src/lang");
|
|
|
|
describe("Workshop navigation translations", () => {
|
|
test("defines the breadcrumb labels for the Custom Widgets sub-routes", async () => {
|
|
const messages = JSON.parse(await readFile(resolve(languageDirectory, "en.json"), "utf8")) as {
|
|
management?: { navbar?: { items?: { workshop?: unknown } } };
|
|
navigationStructure?: {
|
|
manage?: {
|
|
workshop?: unknown;
|
|
"custom-widgets"?: {
|
|
workshop?: { label?: unknown };
|
|
publish?: { label?: unknown };
|
|
};
|
|
};
|
|
};
|
|
customWidget?: { page?: { tabs?: Record<string, unknown> } };
|
|
workshop?: Record<string, unknown>;
|
|
};
|
|
|
|
// The Workshop is reached through the Custom Widgets tabs, not its own navbar entry.
|
|
expect(messages.management?.navbar?.items?.workshop).toBeUndefined();
|
|
expect(messages.navigationStructure?.manage?.workshop).toBeUndefined();
|
|
expect(messages.navigationStructure?.manage?.["custom-widgets"]?.workshop?.label).toBe("Workshop");
|
|
expect(messages.navigationStructure?.manage?.["custom-widgets"]?.publish?.label).toBe("Publish to Workshop");
|
|
expect(messages.customWidget?.page?.tabs).toMatchObject({
|
|
installed: "Installed",
|
|
workshop: "Workshop",
|
|
ariaLabel: expect.any(String),
|
|
});
|
|
|
|
expect(messages.workshop).toMatchObject({
|
|
communityMember: "Community member",
|
|
outdated: "Outdated",
|
|
install: "Install",
|
|
back: expect.any(String),
|
|
listAriaLabel: expect.any(String),
|
|
installReviewTitle: expect.any(String),
|
|
emptyFilteredDescription: expect.any(String),
|
|
importCssConfirm: expect.any(String),
|
|
reportCount: expect.any(String),
|
|
reportWarning: expect.any(String),
|
|
reportVisibility: expect.any(String),
|
|
screenshotAlt: expect.any(String),
|
|
upvote: expect.any(String),
|
|
downvote: expect.any(String),
|
|
reportCategory: expect.objectContaining({
|
|
outdated: expect.any(String),
|
|
malicious: expect.any(String),
|
|
spam: expect.any(String),
|
|
copyright: expect.any(String),
|
|
inappropriate: expect.any(String),
|
|
other: expect.any(String),
|
|
}),
|
|
publish: expect.objectContaining({
|
|
invalidScreenshot: expect.any(String),
|
|
}),
|
|
});
|
|
});
|
|
|
|
test("drops the message keys that only existed for the stacked install modals", async () => {
|
|
const messages = JSON.parse(await readFile(resolve(languageDirectory, "en.json"), "utf8")) as {
|
|
workshop?: Record<string, unknown>;
|
|
};
|
|
|
|
for (const key of ["installDialog", "continueInstall", "confirmInstallTitle", "backToWidget", "inspectCss"]) {
|
|
expect(messages.workshop).not.toHaveProperty(key);
|
|
}
|
|
});
|
|
});
|