plugin-installed-strip.fixture.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { useState } from "react";
  2. import { createRoot } from "react-dom/client";
  3. import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js";
  4. import { TooltipProvider } from "@/components/ui/tooltip.js";
  5. import { PluginStoreListView } from "@/settings/PluginStoreListView.js";
  6. import type { StorePluginItem } from "@/settings/pluginStoreListing.js";
  7. import "@/styles.css";
  8. const params = new URLSearchParams(location.search);
  9. document.documentElement.className =
  10. params.get("theme") === "light" ? "light theme-zai-light" : "dark theme-zai-dark";
  11. const items: StorePluginItem[] = Array.from({ length: 12 }, (_, index) => {
  12. const name = `plugin-${String(index).padStart(2, "0")}`;
  13. return {
  14. id: `${name}@personal`,
  15. name,
  16. marketplace: "personal",
  17. installed: true,
  18. restorable: false,
  19. orphaned: false,
  20. installedMeta: {
  21. id: `${name}@personal`,
  22. name,
  23. marketplace: "personal",
  24. enabled: true,
  25. scope: "user",
  26. updateStatus: "update-available",
  27. },
  28. };
  29. });
  30. function Fixture() {
  31. const [updated, setUpdated] = useState("");
  32. const [opened, setOpened] = useState("");
  33. return (
  34. <ZCodeIntlProvider initialLocale={params.get("locale") === "zh-CN" ? "zh-CN" : "en-US"}>
  35. <TooltipProvider>
  36. <main className="min-h-screen bg-background p-4 text-foreground">
  37. <PluginStoreListView
  38. items={items}
  39. marketplaces={[]}
  40. loading={false}
  41. query=""
  42. onQueryChange={() => {}}
  43. segment="public"
  44. onSegmentChange={() => {}}
  45. onOpenManage={() => {}}
  46. actions={{
  47. onOpenDetail: setOpened,
  48. onUpdate: setUpdated,
  49. onInstall: () => {},
  50. onUninstall: () => {},
  51. onSetEnabled: () => {},
  52. operationId: null,
  53. togglingPluginId: null,
  54. }}
  55. />
  56. <output data-testid="updated">{updated}</output>
  57. <output data-testid="opened">{opened}</output>
  58. </main>
  59. </TooltipProvider>
  60. </ZCodeIntlProvider>
  61. );
  62. }
  63. createRoot(document.getElementById("root")!).render(<Fixture />);