@collabdt/core 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/core/components/AppSidebarContent.js +2 -2
  2. package/dist/core/components/AppSidebarContent.js.map +1 -1
  3. package/dist/core/components/viewers/Data/DataMenu.js +1 -1
  4. package/dist/core/components/viewers/Data/DataMenu.js.map +1 -1
  5. package/dist/core/components/viewers/Data/HeaderButtons.js +1 -1
  6. package/dist/core/components/viewers/Data/HeaderButtons.js.map +1 -1
  7. package/dist/core/components/viewers/Data/utils/viewerConfig.js +1 -1
  8. package/dist/core/components/viewers/Data/utils/viewerConfig.js.map +1 -1
  9. package/dist/core/components/viewers/Viewer.js +1 -1
  10. package/dist/core/components/viewers/Viewer.js.map +1 -1
  11. package/dist/core/components/viewers/plugins/PluginsManager.d.ts +6 -9
  12. package/dist/core/components/viewers/plugins/PluginsManager.d.ts.map +1 -1
  13. package/dist/core/components/viewers/plugins/PluginsManager.js +321 -122
  14. package/dist/core/components/viewers/plugins/PluginsManager.js.map +1 -1
  15. package/dist/core/components/viewers/plugins/src/PluginDetails.d.ts +22 -0
  16. package/dist/core/components/viewers/plugins/src/PluginDetails.d.ts.map +1 -0
  17. package/dist/core/components/viewers/plugins/src/PluginDetails.js +204 -0
  18. package/dist/core/components/viewers/plugins/src/PluginDetails.js.map +1 -0
  19. package/dist/core/components/viewers/plugins/src/PluginQuickControls.d.ts +25 -0
  20. package/dist/core/components/viewers/plugins/src/PluginQuickControls.d.ts.map +1 -0
  21. package/dist/core/components/viewers/plugins/src/PluginQuickControls.js +79 -0
  22. package/dist/core/components/viewers/plugins/src/PluginQuickControls.js.map +1 -0
  23. package/dist/core/components/viewers/plugins/src/PluginRow.d.ts +28 -0
  24. package/dist/core/components/viewers/plugins/src/PluginRow.d.ts.map +1 -0
  25. package/dist/core/components/viewers/plugins/src/PluginRow.js +141 -0
  26. package/dist/core/components/viewers/plugins/src/PluginRow.js.map +1 -0
  27. package/dist/core/components/viewers/plugins/src/RegistryAccessList.d.ts +9 -0
  28. package/dist/core/components/viewers/plugins/src/RegistryAccessList.d.ts.map +1 -0
  29. package/dist/core/components/viewers/plugins/src/RegistryAccessList.js +96 -0
  30. package/dist/core/components/viewers/plugins/src/RegistryAccessList.js.map +1 -0
  31. package/dist/core/components/viewers/plugins/src/RegistryDetails.d.ts +19 -0
  32. package/dist/core/components/viewers/plugins/src/RegistryDetails.d.ts.map +1 -0
  33. package/dist/core/components/viewers/plugins/src/RegistryDetails.js +171 -0
  34. package/dist/core/components/viewers/plugins/src/RegistryDetails.js.map +1 -0
  35. package/dist/core/components/viewers/plugins/src/RegistryImport.d.ts +7 -0
  36. package/dist/core/components/viewers/plugins/src/RegistryImport.d.ts.map +1 -0
  37. package/dist/core/components/viewers/plugins/src/RegistryImport.js +88 -0
  38. package/dist/core/components/viewers/plugins/src/RegistryImport.js.map +1 -0
  39. package/dist/core/components/viewers/plugins/src/RegistryPublishStrip.d.ts +14 -0
  40. package/dist/core/components/viewers/plugins/src/RegistryPublishStrip.d.ts.map +1 -0
  41. package/dist/core/components/viewers/plugins/src/RegistryPublishStrip.js +74 -0
  42. package/dist/core/components/viewers/plugins/src/RegistryPublishStrip.js.map +1 -0
  43. package/dist/core/components/viewers/plugins/src/RegistryToolbar.d.ts +12 -0
  44. package/dist/core/components/viewers/plugins/src/RegistryToolbar.d.ts.map +1 -0
  45. package/dist/core/components/viewers/plugins/src/RegistryToolbar.js +41 -0
  46. package/dist/core/components/viewers/plugins/src/RegistryToolbar.js.map +1 -0
  47. package/dist/core/components/viewers/plugins/src/VisibleToPicker.d.ts +10 -0
  48. package/dist/core/components/viewers/plugins/src/VisibleToPicker.d.ts.map +1 -0
  49. package/dist/core/components/viewers/plugins/src/VisibleToPicker.js +82 -0
  50. package/dist/core/components/viewers/plugins/src/VisibleToPicker.js.map +1 -0
  51. package/dist/core/components/viewers/plugins/src/pluginColumns.d.ts +12 -0
  52. package/dist/core/components/viewers/plugins/src/pluginColumns.d.ts.map +1 -0
  53. package/dist/core/components/viewers/plugins/src/pluginColumns.js +47 -0
  54. package/dist/core/components/viewers/plugins/src/pluginColumns.js.map +1 -0
  55. package/dist/core/components/viewers/plugins/src/pluginRows.d.ts +29 -0
  56. package/dist/core/components/viewers/plugins/src/pluginRows.d.ts.map +1 -0
  57. package/dist/core/components/viewers/plugins/src/pluginRows.js +66 -0
  58. package/dist/core/components/viewers/plugins/src/pluginRows.js.map +1 -0
  59. package/dist/core/components/viewers/plugins/src/pluginStatus.d.ts +6 -5
  60. package/dist/core/components/viewers/plugins/src/pluginStatus.d.ts.map +1 -1
  61. package/dist/core/components/viewers/plugins/src/pluginStatus.js +8 -1
  62. package/dist/core/components/viewers/plugins/src/pluginStatus.js.map +1 -1
  63. package/dist/core/components/viewers/plugins/src/publishState.d.ts +22 -0
  64. package/dist/core/components/viewers/plugins/src/publishState.d.ts.map +1 -0
  65. package/dist/core/components/viewers/plugins/src/publishState.js +19 -0
  66. package/dist/core/components/viewers/plugins/src/publishState.js.map +1 -0
  67. package/dist/core/components/viewers/plugins/src/registryErrorMessage.d.ts +3 -0
  68. package/dist/core/components/viewers/plugins/src/registryErrorMessage.d.ts.map +1 -0
  69. package/dist/core/components/viewers/plugins/src/registryErrorMessage.js +11 -0
  70. package/dist/core/components/viewers/plugins/src/registryErrorMessage.js.map +1 -0
  71. package/dist/core/components/viewers/plugins/src/sharedPluginChanges.d.ts +15 -0
  72. package/dist/core/components/viewers/plugins/src/sharedPluginChanges.d.ts.map +1 -0
  73. package/dist/core/components/viewers/plugins/src/sharedPluginChanges.js +24 -0
  74. package/dist/core/components/viewers/plugins/src/sharedPluginChanges.js.map +1 -0
  75. package/dist/core/components/viewers/plugins/src/sortPluginRows.d.ts +15 -0
  76. package/dist/core/components/viewers/plugins/src/sortPluginRows.d.ts.map +1 -0
  77. package/dist/core/components/viewers/plugins/src/sortPluginRows.js +45 -0
  78. package/dist/core/components/viewers/plugins/src/sortPluginRows.js.map +1 -0
  79. package/dist/core/components/viewers/plugins/src/useFittedColumns.d.ts +5 -0
  80. package/dist/core/components/viewers/plugins/src/useFittedColumns.d.ts.map +1 -0
  81. package/dist/core/components/viewers/plugins/src/useFittedColumns.js +27 -0
  82. package/dist/core/components/viewers/plugins/src/useFittedColumns.js.map +1 -0
  83. package/dist/core/components/viewers/plugins/src/useMountedPlugins.d.ts +6 -2
  84. package/dist/core/components/viewers/plugins/src/useMountedPlugins.d.ts.map +1 -1
  85. package/dist/core/components/viewers/plugins/src/useMountedPlugins.js +8 -2
  86. package/dist/core/components/viewers/plugins/src/useMountedPlugins.js.map +1 -1
  87. package/dist/core/components/viewers/plugins/src/usePluginsData.d.ts.map +1 -1
  88. package/dist/core/components/viewers/plugins/src/usePluginsData.js +10 -5
  89. package/dist/core/components/viewers/plugins/src/usePluginsData.js.map +1 -1
  90. package/dist/core/components/viewers/plugins/src/useRegistryPlugins.d.ts +15 -0
  91. package/dist/core/components/viewers/plugins/src/useRegistryPlugins.d.ts.map +1 -0
  92. package/dist/core/components/viewers/plugins/src/useRegistryPlugins.js +105 -0
  93. package/dist/core/components/viewers/plugins/src/useRegistryPlugins.js.map +1 -0
  94. package/dist/core/components/viewers/plugins/types.d.ts +87 -0
  95. package/dist/core/components/viewers/plugins/types.d.ts.map +1 -1
  96. package/dist/core/i18n/messages/en.json +130 -18
  97. package/dist/core/i18n/messages/es.json +130 -18
  98. package/dist/core/i18n/messages/fr.json +130 -18
  99. package/dist/core/plugins/sdk/semver.d.ts +7 -0
  100. package/dist/core/plugins/sdk/semver.d.ts.map +1 -0
  101. package/dist/core/plugins/sdk/semver.js +52 -0
  102. package/dist/core/plugins/sdk/semver.js.map +1 -0
  103. package/dist/core/types/dbTypes.d.ts +1 -1
  104. package/dist/core/types/dbTypes.d.ts.map +1 -1
  105. package/dist/core/types/dbTypes.js +1 -1
  106. package/dist/core/types/dbTypes.js.map +1 -1
  107. package/dist/core/utils/appContent.js +1 -1
  108. package/dist/core/utils/appContent.js.map +1 -1
  109. package/package.json +3 -3
  110. package/dist/core/components/viewers/plugins/src/PluginCard.d.ts +0 -14
  111. package/dist/core/components/viewers/plugins/src/PluginCard.d.ts.map +0 -1
  112. package/dist/core/components/viewers/plugins/src/PluginCard.js +0 -234
  113. package/dist/core/components/viewers/plugins/src/PluginCard.js.map +0 -1
@@ -34,6 +34,7 @@ var __objRest = (source, exclude) => {
34
34
  return target;
35
35
  };
36
36
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
37
+ import * as LR from "lucide-react";
37
38
  import { useTranslations } from "next-intl";
38
39
  import * as React from "react";
39
40
  import { toast } from "sonner";
@@ -42,6 +43,8 @@ import { INSTALLED_PLUGINS } from "../../../plugins/installed";
42
43
  import { resolvePluginEntry } from "../../../plugins/sdk/types";
43
44
  import { usePermissions } from "../../../store/Permissions/context";
44
45
  import { ViewerNames } from "../../../types/dbTypes";
46
+ import ConfirmDialog from "../../ConfirmDialog";
47
+ import { Badge } from "../../ui/Badge";
45
48
  import {
46
49
  Breadcrumb,
47
50
  BreadcrumbItem,
@@ -49,53 +52,85 @@ import {
49
52
  BreadcrumbPage
50
53
  } from "../../ui/Breadcrumb";
51
54
  import { Input } from "../../ui/Input";
55
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../ui/Tabs";
52
56
  import { VIEWER_CONFIG } from "../Data/utils/viewerConfig";
53
- import { PluginCard } from "./src/PluginCard";
57
+ import { visibleColumns } from "./src/pluginColumns";
58
+ import { PluginDetails } from "./src/PluginDetails";
59
+ import { InstallQuickControl, OrgQuickControl, UserQuickControl } from "./src/PluginQuickControls";
60
+ import { PLUGIN_ROW_GRID, PluginRow, pluginRowStyle } from "./src/PluginRow";
61
+ import { isInTab, isMine, matchesSearch, mergePluginRows, registryStanding } from "./src/pluginRows";
54
62
  import { effectiveStatus } from "./src/pluginStatus";
63
+ import { isPublishState } from "./src/publishState";
64
+ import { RegistryDetails } from "./src/RegistryDetails";
65
+ import { RegistryToolbar } from "./src/RegistryToolbar";
66
+ import { nextSort, rowName, SORT_KEYS, sortPluginRows } from "./src/sortPluginRows";
67
+ import { useFittedColumns } from "./src/useFittedColumns";
55
68
  import { usePluginsActions, usePluginsData } from "./src/usePluginsData";
56
- function PluginsManager({ listings, actions }) {
69
+ import { useRegistryActions, useRegistryPlugins } from "./src/useRegistryPlugins";
70
+ import { VisibleToPicker } from "./src/VisibleToPicker";
71
+ function PluginsManager({ listings, actions, registryActions }) {
72
+ var _a;
57
73
  const t = useTranslations("PluginsPage");
58
- const tData = useTranslations("DataMenu");
59
- const { ability } = usePermissions();
74
+ const tRegistry = useTranslations("PluginRegistry");
75
+ const { ability: casl } = usePermissions();
60
76
  const [searchTerm, setSearchTerm] = React.useState("");
61
- const viewerConfig = VIEWER_CONFIG[ViewerNames.extensions];
77
+ const [tab, setTab] = React.useState("all");
78
+ const [scope, setScope] = React.useState("all");
79
+ const viewerConfig = VIEWER_CONFIG[ViewerNames.plugins];
62
80
  const headerTitle = t("title");
63
81
  const MenuIcon = viewerConfig == null ? void 0 : viewerConfig.icon;
64
82
  const { listings: resolved, isLoading } = usePluginsData(listings);
65
83
  const boundActions = usePluginsActions(actions);
66
84
  const host = usePluginHost();
85
+ const { registry } = useRegistryPlugins();
86
+ const boundRegistryActions = useRegistryActions(registryActions);
67
87
  const [overrides, setOverrides] = React.useState({});
68
- const rows = React.useMemo(
88
+ const listingRows = React.useMemo(
69
89
  () => resolved.map((row) => {
70
90
  const patch = overrides[row.manifest.slug];
71
91
  return patch ? __spreadValues(__spreadValues({}, row), patch) : row;
72
92
  }),
73
93
  [resolved, overrides]
74
94
  );
75
- const canManage = React.useMemo(() => {
76
- const legacyWriter = ability.can("update", "Organization");
77
- const orgAdmin = ability.can("update", "PluginInstallation") || legacyWriter;
95
+ const ability = React.useMemo(() => {
96
+ const orgAdmin = casl.can("update", "PluginInstallation");
78
97
  return {
79
- canInstall: ability.can("create", "PluginInstallation") || orgAdmin,
98
+ canInstall: casl.can("create", "PluginInstallation") || orgAdmin,
80
99
  canConfigureOrg: orgAdmin,
81
- canChooseForSelf: ability.can("update", "PluginUserSetting") || legacyWriter
100
+ canChooseForSelf: casl.can("update", "PluginUserSetting")
82
101
  };
83
- }, [ability]);
84
- const filtered = React.useMemo(() => {
85
- const needle = searchTerm.trim().toLowerCase();
86
- if (!needle) return rows;
87
- return rows.filter(
88
- ({ manifest }) => {
89
- var _a;
90
- return manifest.name.toLowerCase().includes(needle) || manifest.slug.toLowerCase().includes(needle) || ((_a = manifest.description) != null ? _a : "").toLowerCase().includes(needle) || manifest.capabilities.some((capability) => capability.toLowerCase().includes(needle));
91
- }
92
- );
93
- }, [rows, searchTerm]);
94
- const inOrg = filtered.filter((row) => effectiveStatus(row) !== "available");
95
- const found = canManage.canInstall ? filtered.filter((row) => effectiveStatus(row) === "available") : [];
102
+ }, [casl]);
103
+ const rows = React.useMemo(
104
+ () => mergePluginRows(listingRows, registry.configured ? registry.plugins : []),
105
+ [listingRows, registry]
106
+ );
107
+ const devTeam = React.useMemo(
108
+ () => {
109
+ var _a2;
110
+ return registry.configured && registry.viewer ? { canGrant: registry.viewer.canGrant, canPublishFromDisk: (_a2 = registry.viewer.canPublishFromDisk) != null ? _a2 : false } : null;
111
+ },
112
+ [registry]
113
+ );
114
+ const canGrant = (_a = devTeam == null ? void 0 : devTeam.canGrant) != null ? _a : false;
115
+ const hasRegistryStanding = rows.some((row) => registryStanding(row, devTeam) !== null);
116
+ const columns = React.useMemo(
117
+ () => visibleColumns(ability, canGrant, hasRegistryStanding),
118
+ [ability, canGrant, hasRegistryStanding]
119
+ );
120
+ const [sort, setSort] = React.useState(null);
121
+ const tabs = [
122
+ "all",
123
+ "running",
124
+ "installed",
125
+ ...ability.canInstall ? ["notInstalled"] : [],
126
+ ...registry.configured ? ["registry"] : []
127
+ ];
128
+ const needle = searchTerm.trim().toLowerCase();
129
+ const rowsFor = (target) => rows.filter((row) => isInTab(row, target, tabs) && matchesSearch(row, needle) && (target !== "registry" || scope === "all" || isMine(row)));
130
+ const sortedRowsFor = (target) => sortPluginRows(rowsFor(target), sort);
96
131
  React.useEffect(() => {
97
132
  if (!host) return;
98
- for (const row of rows) {
133
+ for (const row of listingRows) {
99
134
  const { slug } = row.manifest;
100
135
  const shouldRun = effectiveStatus(row) === "running";
101
136
  const isRunning = host.getStatus(slug) === "active";
@@ -109,7 +144,7 @@ function PluginsManager({ listings, actions }) {
109
144
  void host.unloadPlugin(slug);
110
145
  }
111
146
  }
112
- }, [rows, host]);
147
+ }, [listingRows, host]);
113
148
  const commit = React.useCallback(
114
149
  async (slug, name, patch, write, success) => {
115
150
  setOverrides((current) => __spreadProps(__spreadValues({}, current), { [slug]: __spreadValues(__spreadValues({}, current[slug]), patch) }));
@@ -119,7 +154,7 @@ function PluginsManager({ listings, actions }) {
119
154
  } catch (error) {
120
155
  console.error("Plugin update failed:", error);
121
156
  setOverrides((current) => {
122
- const _a = current, { [slug]: _reverted } = _a, rest = __objRest(_a, [__restKey(slug)]);
157
+ const _a2 = current, { [slug]: _reverted } = _a2, rest = __objRest(_a2, [__restKey(slug)]);
123
158
  return rest;
124
159
  });
125
160
  toast.error(t("toastFailed", { name }));
@@ -127,120 +162,284 @@ function PluginsManager({ listings, actions }) {
127
162
  },
128
163
  [t]
129
164
  );
165
+ const tabLabel = {
166
+ all: t("tabAll"),
167
+ running: t("tabRunning"),
168
+ installed: t("tabInstalled"),
169
+ notInstalled: t("tabNotInstalled"),
170
+ registry: tRegistry("tabLabel")
171
+ };
172
+ const emptyText = (target) => {
173
+ if (needle) return t("noResults", { query: searchTerm.trim() });
174
+ if (target === "registry") return emptyRegistryText();
175
+ if (target === "notInstalled") return t("emptyNotInstalled");
176
+ if (target === "running") return t("emptyRunning");
177
+ if (isLoading && resolved.length === 0) return t("loading");
178
+ return ability.canInstall ? t("emptyAdmin") : t("empty");
179
+ };
180
+ const emptyRegistryText = () => {
181
+ if (scope === "mine") return tRegistry("emptyMine");
182
+ if (devTeam == null ? void 0 : devTeam.canPublishFromDisk) return tRegistry("empty");
183
+ return canGrant ? tRegistry("emptyImport") : tRegistry("emptyAwaitingImport");
184
+ };
130
185
  return /* @__PURE__ */ jsx("div", { className: "sm:p-2 overflow-hidden bg-[#fafafa] h-full", children: /* @__PURE__ */ jsx("div", { className: "bg-background rounded-xl shadow h-full min-h-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full min-h-0", children: [
131
186
  /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 justify-start items-center px-3 py-4 relative", children: /* @__PURE__ */ jsx(Breadcrumb, { className: "px-3", children: /* @__PURE__ */ jsx(BreadcrumbList, { children: /* @__PURE__ */ jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsx(BreadcrumbPage, { children: headerTitle }) }) }) }) }),
132
- /* @__PURE__ */ jsx("div", { className: "flex flex-row justify-between items-center px-6 py-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
133
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
134
- MenuIcon && /* @__PURE__ */ jsx(MenuIcon, { className: "h-8 w-8" }),
135
- /* @__PURE__ */ jsx("h1", { className: "text-2xl text-foreground", children: headerTitle })
136
- ] }),
137
- /* @__PURE__ */ jsx("h2", { className: "text-sm text-muted-foreground font-normal max-w-[70ch]", children: t("intro") })
187
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row justify-between items-center px-6 py-6", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
188
+ MenuIcon && /* @__PURE__ */ jsx(MenuIcon, { className: "h-8 w-8" }),
189
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl text-foreground", children: headerTitle })
138
190
  ] }) }),
139
- /* @__PURE__ */ jsx("div", { className: "flex flex-col sm:flex-row sm:justify-end items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4", children: /* @__PURE__ */ jsx("div", { className: "w-full sm:w-96", children: /* @__PURE__ */ jsx(
140
- Input,
191
+ /* @__PURE__ */ jsxs(
192
+ Tabs,
141
193
  {
142
- placeholder: `${tData("searchPlaceholder")} ${headerTitle}...`,
143
- value: searchTerm,
144
- onChange: (event) => setSearchTerm(event.target.value),
145
- "aria-label": t("searchPlaceholder")
146
- }
147
- ) }) }),
148
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8", children: isLoading && rows.length === 0 ? /* @__PURE__ */ jsx(Empty, { text: t("loading") }) : rows.length === 0 ? /* @__PURE__ */ jsx(Empty, { text: canManage.canInstall ? t("emptyAdmin") : t("empty") }) : filtered.length === 0 ? /* @__PURE__ */ jsx(Empty, { text: t("noResults", { query: searchTerm.trim() }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
149
- inOrg.length > 0 && /* @__PURE__ */ jsx(
150
- Section,
151
- {
152
- title: t("sectionAvailable"),
153
- hint: t("countPlugins", { count: inOrg.length }),
154
- children: inOrg.map((row) => /* @__PURE__ */ jsx(
155
- Row,
194
+ value: tab,
195
+ onValueChange: (value) => setTab(value),
196
+ className: "flex flex-1 min-h-0 flex-col",
197
+ children: [
198
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row sm:justify-between items-stretch sm:items-end px-3 sm:px-6 py-4 gap-3 sm:gap-4", children: [
199
+ tabs.length > 1 ? /* @__PURE__ */ jsx(TabsList, { className: "w-auto sm:flex-1", children: tabs.map((target) => /* @__PURE__ */ jsxs(TabsTrigger, { value: target, children: [
200
+ tabLabel[target],
201
+ /* @__PURE__ */ jsx(Badge, { className: "ml-1 tabular-nums", children: rowsFor(target).length })
202
+ ] }, target)) }) : /* @__PURE__ */ jsx("span", {}),
203
+ /* @__PURE__ */ jsx("div", { className: "w-full sm:w-80", children: /* @__PURE__ */ jsx(
204
+ Input,
205
+ {
206
+ placeholder: t("searchPlaceholder"),
207
+ value: searchTerm,
208
+ onChange: (event) => setSearchTerm(event.target.value),
209
+ "aria-label": t("searchPlaceholder")
210
+ }
211
+ ) })
212
+ ] }),
213
+ tabs.map((target) => /* @__PURE__ */ jsxs(
214
+ TabsContent,
156
215
  {
157
- listing: row,
158
- ability: canManage,
159
- actions: boundActions,
160
- commit
216
+ value: target,
217
+ className: "mt-0 flex-1 min-h-0 overflow-y-auto px-3 sm:px-6 pb-8",
218
+ "data-testid": target === "registry" ? "plugin-registry" : `plugins-tab-${target}`,
219
+ children: [
220
+ target === "registry" && /* @__PURE__ */ jsx(
221
+ RegistryToolbar,
222
+ {
223
+ registry,
224
+ actions: boundRegistryActions,
225
+ scope,
226
+ onScopeChange: setScope
227
+ }
228
+ ),
229
+ target === "notInstalled" && /* @__PURE__ */ jsx("p", { className: "mb-3 text-sm text-muted-foreground", children: t("tabNotInstalledHint") }),
230
+ /* @__PURE__ */ jsx(
231
+ PluginTable,
232
+ {
233
+ rows: sortedRowsFor(target),
234
+ columns,
235
+ sort,
236
+ onSort: (key) => setSort((current) => nextSort(current, key)),
237
+ emptyText: emptyText(target),
238
+ children: (row, fittedColumns) => /* @__PURE__ */ jsx(
239
+ Row,
240
+ {
241
+ row,
242
+ columns: fittedColumns,
243
+ ability,
244
+ actions: boundActions,
245
+ commit,
246
+ devTeam,
247
+ registryActions: boundRegistryActions
248
+ },
249
+ row.slug
250
+ )
251
+ }
252
+ )
253
+ ]
161
254
  },
162
- row.manifest.slug
255
+ target
163
256
  ))
164
- }
165
- ),
166
- found.length > 0 && /* @__PURE__ */ jsx(Section, { title: t("sectionFound"), hint: t("sectionFoundHint"), children: found.map((row) => /* @__PURE__ */ jsx(
167
- Row,
168
- {
169
- listing: row,
170
- ability: canManage,
171
- actions: boundActions,
172
- commit
173
- },
174
- row.manifest.slug
175
- )) })
176
- ] }) })
257
+ ]
258
+ }
259
+ )
177
260
  ] }) }) });
178
261
  }
262
+ const COLUMN_LABEL_KEY = {
263
+ name: "columnPlugin",
264
+ version: "columnVersion",
265
+ status: "columnStatus",
266
+ run: "columnRun",
267
+ install: "columnInstall",
268
+ enable: "columnEnable",
269
+ visibleTo: "columnVisibleTo",
270
+ registry: "columnRegistry"
271
+ };
272
+ const isSortKey = (column) => SORT_KEYS.includes(column);
273
+ function PluginTable({
274
+ rows,
275
+ columns,
276
+ sort,
277
+ onSort,
278
+ emptyText,
279
+ children
280
+ }) {
281
+ const t = useTranslations("PluginsPage");
282
+ const [tableRef, fitted] = useFittedColumns(columns);
283
+ if (rows.length === 0) {
284
+ return /* @__PURE__ */ jsx("p", { className: "rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground", children: emptyText });
285
+ }
286
+ return /* @__PURE__ */ jsxs("div", { ref: tableRef, className: "min-w-0 overflow-hidden rounded-xl border", children: [
287
+ /* @__PURE__ */ jsx(
288
+ "div",
289
+ {
290
+ role: "row",
291
+ className: `${PLUGIN_ROW_GRID} border-b bg-muted/30 px-3 py-1 text-xs text-muted-foreground`,
292
+ style: pluginRowStyle(fitted),
293
+ children: fitted.map((column) => {
294
+ const label = t(COLUMN_LABEL_KEY[column]);
295
+ const className = column === "name" ? "pl-6" : void 0;
296
+ if (!isSortKey(column)) return /* @__PURE__ */ jsx("span", { role: "columnheader", className, children: label }, column);
297
+ const direction = (sort == null ? void 0 : sort.key) === column ? sort.direction : null;
298
+ const SortIcon = direction === "asc" ? LR.ArrowUp : direction === "desc" ? LR.ArrowDown : LR.ArrowUpDown;
299
+ return /* @__PURE__ */ jsx(
300
+ "span",
301
+ {
302
+ role: "columnheader",
303
+ "aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : "none",
304
+ className,
305
+ children: /* @__PURE__ */ jsxs(
306
+ "button",
307
+ {
308
+ type: "button",
309
+ className: "-mx-1 inline-flex items-center gap-1 rounded px-1 py-1 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
310
+ onClick: () => onSort(column),
311
+ "aria-label": t("sortBy", { column: label }),
312
+ children: [
313
+ label,
314
+ /* @__PURE__ */ jsx(SortIcon, { "aria-hidden": true, className: direction ? "h-3.5 w-3.5" : "h-3.5 w-3.5 opacity-40" })
315
+ ]
316
+ }
317
+ )
318
+ },
319
+ column
320
+ );
321
+ })
322
+ }
323
+ ),
324
+ /* @__PURE__ */ jsx("ul", { children: rows.map((row) => children(row, fitted)) })
325
+ ] });
326
+ }
179
327
  function Row({
180
- listing,
328
+ row,
329
+ columns,
181
330
  ability,
182
331
  actions,
183
- commit
332
+ commit,
333
+ devTeam,
334
+ registryActions
184
335
  }) {
336
+ var _a, _b, _c, _d;
185
337
  const t = useTranslations("PluginsPage");
186
- const { slug } = listing.manifest;
187
- const name = listing.manifest.name;
188
- return /* @__PURE__ */ jsx(
189
- PluginCard,
190
- {
191
- listing,
192
- ability,
193
- onSetInstalled: (installed) => void commit(
194
- slug,
195
- name,
196
- { installed, status: installed ? "off" : "available" },
197
- () => actions.setInstalled(slug, installed),
198
- installed ? t("toastInstalled", { name }) : t("toastUninstalled", { name })
199
- ),
200
- onSetOrgEnabled: (enabled) => void commit(
201
- slug,
202
- name,
203
- { orgEnabled: enabled },
204
- () => actions.setOrgEnabled(slug, enabled),
205
- enabled ? t("toastOrgEnabled", { name }) : t("toastOrgDisabled", { name })
206
- ),
207
- onSetAllowUserOverride: (allow) => void commit(
208
- slug,
209
- name,
210
- { allowUserOverride: allow },
211
- () => actions.setAllowUserOverride(slug, allow),
212
- allow ? t("toastOverrideAllowed", { name }) : t("toastOverrideBlocked", { name })
213
- ),
214
- onSetUserEnabled: (enabled) => void commit(
338
+ const { slug, listing, entry } = row;
339
+ const name = rowName(row);
340
+ const canGrant = (_a = devTeam == null ? void 0 : devTeam.canGrant) != null ? _a : false;
341
+ const standing = registryStanding(row, devTeam);
342
+ const publishing = listing && standing && isPublishState(standing) ? { manifest: listing.manifest, state: standing } : void 0;
343
+ const showRegistry = Boolean(devTeam && (entry || publishing));
344
+ const [open, setOpen] = React.useState(false);
345
+ const [confirmingUninstall, setConfirmingUninstall] = React.useState(false);
346
+ const setOrgEnabled = (enabled) => void commit(
347
+ slug,
348
+ name,
349
+ { orgEnabled: enabled },
350
+ () => actions.setOrgEnabled(slug, enabled),
351
+ enabled ? t("toastOrgEnabled", { name }) : t("toastOrgDisabled", { name })
352
+ );
353
+ const setUserEnabled = (enabled) => void commit(
354
+ slug,
355
+ name,
356
+ { userEnabled: enabled },
357
+ () => actions.setUserEnabled(slug, enabled),
358
+ enabled ? t("toastUserEnabled", { name }) : t("toastUserDisabled", { name })
359
+ );
360
+ const writeInstalled = (installed) => void commit(
361
+ slug,
362
+ name,
363
+ { installed, status: installed ? "off" : "available" },
364
+ () => actions.setInstalled(slug, installed),
365
+ installed ? t("toastInstalled", { name }) : t("toastUninstalled", { name })
366
+ );
367
+ const setInstalled = (installed) => installed ? writeInstalled(true) : setConfirmingUninstall(true);
368
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
369
+ /* @__PURE__ */ jsxs(
370
+ PluginRow,
371
+ {
372
+ open,
373
+ onOpenChange: setOpen,
374
+ columns,
375
+ cells: {
376
+ run: /* @__PURE__ */ jsx(UserQuickControl, { listing, ability, name, onSetUserEnabled: setUserEnabled }),
377
+ install: /* @__PURE__ */ jsx(InstallQuickControl, { listing, ability, name, onSetInstalled: setInstalled, onReview: () => setOpen(true) }),
378
+ enable: /* @__PURE__ */ jsx(OrgQuickControl, { listing, ability, name, onSetOrgEnabled: setOrgEnabled }),
379
+ visibleTo: entry && canGrant ? /* @__PURE__ */ jsx(VisibleToPicker, { plugin: entry, actions: registryActions }) : null
380
+ },
215
381
  slug,
216
382
  name,
217
- { userEnabled: enabled },
218
- () => actions.setUserEnabled(slug, enabled),
219
- enabled ? t("toastUserEnabled", { name }) : t("toastUserDisabled", { name })
220
- ),
221
- onCopyError: () => {
222
- var _a, _b;
223
- void ((_b = navigator.clipboard) == null ? void 0 : _b.writeText((_a = listing.error) != null ? _a : "").then(() => toast.success(t("errorCopied"))).catch(() => toast.error(t("toastFailed", { name }))));
383
+ icon: (_b = listing == null ? void 0 : listing.manifest.icon) != null ? _b : entry == null ? void 0 : entry.icon,
384
+ version: (_d = (_c = listing == null ? void 0 : listing.manifest.version) != null ? _c : entry == null ? void 0 : entry.latestVersion) != null ? _d : null,
385
+ status: listing ? effectiveStatus(listing) : void 0,
386
+ standing,
387
+ children: [
388
+ listing ? /* @__PURE__ */ jsx(
389
+ PluginDetails,
390
+ {
391
+ listing,
392
+ ability,
393
+ onSetInstalled: setInstalled,
394
+ onSetOrgEnabled: setOrgEnabled,
395
+ onSetAllowUserOverride: (allow) => void commit(
396
+ slug,
397
+ name,
398
+ { allowUserOverride: allow },
399
+ () => actions.setAllowUserOverride(slug, allow),
400
+ allow ? t("toastOverrideAllowed", { name }) : t("toastOverrideBlocked", { name })
401
+ ),
402
+ onSetUserEnabled: setUserEnabled,
403
+ onCopyError: () => {
404
+ var _a2, _b2;
405
+ void ((_b2 = navigator.clipboard) == null ? void 0 : _b2.writeText((_a2 = listing.error) != null ? _a2 : "").then(() => toast.success(t("errorCopied"))).catch(() => toast.error(t("toastFailed", { name }))));
406
+ }
407
+ }
408
+ ) : /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
409
+ (entry == null ? void 0 : entry.description) && /* @__PURE__ */ jsx("span", { className: "mb-1 block text-foreground", children: entry.description }),
410
+ t("notInOrg")
411
+ ] }),
412
+ showRegistry && /* @__PURE__ */ jsx(
413
+ RegistryDetails,
414
+ {
415
+ entry,
416
+ publishing,
417
+ canGrant,
418
+ actions: registryActions
419
+ }
420
+ )
421
+ ]
224
422
  }
225
- }
226
- );
227
- }
228
- function Section({
229
- title,
230
- hint,
231
- children
232
- }) {
233
- return /* @__PURE__ */ jsxs("section", { className: "mb-8 last:mb-0", children: [
234
- /* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-2 mb-3", children: [
235
- /* @__PURE__ */ jsx("h2", { className: "text-sm text-foreground", children: title }),
236
- /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: hint })
237
- ] }),
238
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children })
423
+ ),
424
+ /* @__PURE__ */ jsx(
425
+ ConfirmDialog,
426
+ {
427
+ isOpen: confirmingUninstall,
428
+ isDeleting: false,
429
+ onOpenChange: setConfirmingUninstall,
430
+ handleConfirm: (event) => {
431
+ event.preventDefault();
432
+ setConfirmingUninstall(false);
433
+ writeInstalled(false);
434
+ },
435
+ title: t("uninstallTitle", { name }),
436
+ description: t("uninstallDescription"),
437
+ confirmLabel: t("uninstallConfirm"),
438
+ cancelLabel: t("cancel")
439
+ }
440
+ )
239
441
  ] });
240
442
  }
241
- function Empty({ text }) {
242
- return /* @__PURE__ */ jsx("p", { className: "rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground", children: text });
243
- }
244
443
  export {
245
444
  PluginsManager
246
445
  };