@eventcatalog/core 5.0.0-beta.1 → 5.0.0-beta.10
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.
- package/LICENSE +227 -128
- package/dist/analytics/analytics.cjs +18 -3
- package/dist/analytics/analytics.d.cts +1 -1
- package/dist/analytics/analytics.d.ts +1 -1
- package/dist/analytics/analytics.js +3 -2
- package/dist/analytics/log-build.cjs +71 -35
- package/dist/analytics/log-build.js +5 -4
- package/dist/analytics/telemetry.cjs +42 -0
- package/dist/analytics/telemetry.d.cts +20 -0
- package/dist/analytics/telemetry.d.ts +20 -0
- package/dist/analytics/telemetry.js +8 -0
- package/dist/{chunk-K2ACDO7Y.js → chunk-2LBDRHE4.js} +1 -1
- package/dist/{chunk-TQLRG35T.js → chunk-AWOO63ME.js} +71 -45
- package/dist/chunk-CPW6G62V.js +17 -0
- package/dist/{chunk-UDS3SYLZ.js → chunk-CRKJBDN7.js} +56 -33
- package/dist/{chunk-Q6SD5SNQ.js → chunk-EM36OL6A.js} +1 -1
- package/dist/{chunk-S2QGT7ZF.js → chunk-IONYKKOY.js} +1 -1
- package/dist/{chunk-KYJZJLBD.js → chunk-LJMXOEEC.js} +9 -3
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +204 -124
- package/dist/eventcatalog.config.d.cts +59 -1
- package/dist/eventcatalog.config.d.ts +59 -1
- package/dist/eventcatalog.js +30 -11
- package/dist/federation/federate.js +2 -2
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/runtime-dependencies/@hocuspocus__provider.mjs +3 -0
- package/dist/runtime-dependencies/@hocuspocus__server.mjs +3 -0
- package/dist/runtime-dependencies/@mcp-b__webmcp-local-relay.mjs +3 -0
- package/dist/runtime-dependencies/@mcp-b__webmcp-polyfill.mjs +3 -0
- package/dist/runtime-dependencies/manifest.json +8 -1
- package/dist/runtime-dependencies/react-hotkeys-hook.mjs +3 -0
- package/dist/runtime-dependencies/y-protocols.mjs +3 -0
- package/dist/runtime-dependencies/y-protocols__awareness.mjs +3 -0
- package/dist/runtime-dependencies/yjs.mjs +3 -0
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/dist/utils/license-status.cjs +71 -45
- package/dist/utils/license-status.d.cts +14 -5
- package/dist/utils/license-status.d.ts +14 -5
- package/dist/utils/license-status.js +1 -1
- package/eventcatalog/astro.config.mjs +5 -0
- package/eventcatalog/integrations/storage.mjs +20 -0
- package/eventcatalog/integrations/studio-server.mjs +32 -0
- package/eventcatalog/src/components/Grids/utils.tsx +0 -23
- package/eventcatalog/src/components/Header.astro +3 -3
- package/eventcatalog/src/components/MDX/CodeGroup/CodeGroup.tsx +6 -1
- package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +12 -4
- package/eventcatalog/src/components/SideNav/NestedSideBar/index.tsx +16 -7
- package/eventcatalog/src/components/SideNav/NestedSideBar/utils.ts +10 -0
- package/eventcatalog/src/components/Tables/Discover/DiscoverTable.tsx +4 -62
- package/eventcatalog/src/components/Tables/Discover/columns.tsx +17 -150
- package/eventcatalog/src/components/Tables/Resources/ResourcesTable.tsx +425 -0
- package/eventcatalog/src/components/Tables/RowActionsMenu.tsx +157 -0
- package/eventcatalog/src/components/Tables/TablePagination.tsx +82 -0
- package/eventcatalog/src/features/ai/chat-api.ts +3 -3
- package/eventcatalog/src/features/auth/middleware/middleware-auth.ts +10 -0
- package/eventcatalog/src/features/integrations/eventcatalog-features.ts +34 -1
- package/eventcatalog/src/features/mcp/apps/canvas/shared.ts +47 -0
- package/eventcatalog/src/features/mcp/apps/canvas/styles.css +22 -0
- package/eventcatalog/src/features/mcp/apps/canvas/view.tsx +276 -0
- package/eventcatalog/src/features/mcp/apps/generated/canvas.html +210 -0
- package/eventcatalog/src/features/mcp/apps/generated/viewer.html +75 -74
- package/eventcatalog/src/features/mcp/apps/shared/app-view.tsx +2 -1
- package/eventcatalog/src/features/mcp/mcp-apps.ts +6 -3
- package/eventcatalog/src/features/mcp/mcp-server.ts +36 -5
- package/eventcatalog/src/features/server/start.ts +25 -0
- package/eventcatalog/src/features/storage/database.ts +88 -0
- package/eventcatalog/src/features/storage/migrations.ts +85 -0
- package/eventcatalog/src/features/storage/sql/database.sql +5 -0
- package/eventcatalog/src/features/storage/sql/migrations/0001-studio-canvases.sql +12 -0
- package/eventcatalog/src/features/storage/sql/migrations.sql +15 -0
- package/eventcatalog/src/features/storage/sql.ts +28 -0
- package/eventcatalog/src/features/studio/agent-choreography.ts +381 -0
- package/eventcatalog/src/features/studio/api/canvases-api.ts +170 -0
- package/eventcatalog/src/features/studio/api/canvases.ts +25 -0
- package/eventcatalog/src/features/studio/api/client.ts +35 -0
- package/eventcatalog/src/features/studio/canvas-actions.ts +414 -0
- package/eventcatalog/src/features/studio/canvas-doc.ts +414 -0
- package/eventcatalog/src/features/studio/canvas-preview.ts +53 -0
- package/eventcatalog/src/features/studio/catalog-resources.ts +155 -0
- package/eventcatalog/src/features/studio/catalog.ts +171 -0
- package/eventcatalog/src/features/studio/clipboard.ts +97 -0
- package/eventcatalog/src/features/studio/components/CanvasControls.tsx +154 -0
- package/eventcatalog/src/features/studio/components/CanvasHeader.tsx +370 -0
- package/eventcatalog/src/features/studio/components/CanvasStatusMenu.tsx +117 -0
- package/eventcatalog/src/features/studio/components/Comments.tsx +770 -0
- package/eventcatalog/src/features/studio/components/ConnectAgentDialog.tsx +281 -0
- package/eventcatalog/src/features/studio/components/ConnectionsChooser.tsx +144 -0
- package/eventcatalog/src/features/studio/components/ContainerChooser.tsx +145 -0
- package/eventcatalog/src/features/studio/components/DeleteCanvasDialog.tsx +81 -0
- package/eventcatalog/src/features/studio/components/DragGhost.tsx +115 -0
- package/eventcatalog/src/features/studio/components/JoinForm.tsx +34 -0
- package/eventcatalog/src/features/studio/components/LeftPanel.tsx +314 -0
- package/eventcatalog/src/features/studio/components/Picture.tsx +21 -0
- package/eventcatalog/src/features/studio/components/Presence.tsx +286 -0
- package/eventcatalog/src/features/studio/components/PropertiesPanel.tsx +212 -0
- package/eventcatalog/src/features/studio/components/ShareDialog.tsx +260 -0
- package/eventcatalog/src/features/studio/components/StudioDesigner.tsx +1216 -0
- package/eventcatalog/src/features/studio/components/StudioNotice.astro +24 -0
- package/eventcatalog/src/features/studio/components/canvas-nodes.tsx +255 -0
- package/eventcatalog/src/features/studio/components/icons.ts +53 -0
- package/eventcatalog/src/features/studio/components/status.ts +53 -0
- package/eventcatalog/src/features/studio/edges.ts +56 -0
- package/eventcatalog/src/features/studio/flow-state.ts +92 -0
- package/eventcatalog/src/features/studio/grouping.ts +226 -0
- package/eventcatalog/src/features/studio/hooks/presence-sender.ts +46 -0
- package/eventcatalog/src/features/studio/hooks/presence-store.ts +119 -0
- package/eventcatalog/src/features/studio/hooks/use-canvas-webmcp.ts +347 -0
- package/eventcatalog/src/features/studio/hooks/use-comments.ts +54 -0
- package/eventcatalog/src/features/studio/hooks/use-follow-camera.ts +104 -0
- package/eventcatalog/src/features/studio/hooks/use-studio-flow.ts +589 -0
- package/eventcatalog/src/features/studio/identity.ts +37 -0
- package/eventcatalog/src/features/studio/layout.ts +42 -0
- package/eventcatalog/src/features/studio/levels.ts +282 -0
- package/eventcatalog/src/features/studio/node-types.ts +205 -0
- package/eventcatalog/src/features/studio/pages/[id].astro +68 -0
- package/eventcatalog/src/features/studio/pages/index.astro +784 -0
- package/eventcatalog/src/features/studio/pages/webmcp-relay.ts +27 -0
- package/eventcatalog/src/features/studio/placement.ts +197 -0
- package/eventcatalog/src/features/studio/server/canvas-mcp.ts +510 -0
- package/eventcatalog/src/features/studio/server/runtime.ts +491 -0
- package/eventcatalog/src/features/studio/server/sign-in.ts +18 -0
- package/eventcatalog/src/features/studio/server/sql/storage.sql +18 -0
- package/eventcatalog/src/features/studio/server/storage.ts +90 -0
- package/eventcatalog/src/features/studio/server/tool-icons.ts +30 -0
- package/eventcatalog/src/features/studio/studio.css +273 -0
- package/eventcatalog/src/features/studio/tool-sync.ts +75 -0
- package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +10 -5
- package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.spec.ts +52 -63
- package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.ts +34 -46
- package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +11 -29
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_ResourcesPage.astro +79 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_index.data.spec.ts +32 -14
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_index.data.ts +63 -58
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/index.astro +2 -62
- package/eventcatalog/src/pages/docs/services/[id]/[version]/resources/index.astro +13 -0
- package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +24 -42
- package/eventcatalog/src/stores/sidebar-store/builders/flow.ts +2 -0
- package/eventcatalog/src/stores/sidebar-store/builders/message.ts +2 -0
- package/eventcatalog/src/stores/sidebar-store/builders/service.ts +23 -23
- package/eventcatalog/src/stores/sidebar-store/builders/shared.ts +13 -0
- package/eventcatalog/src/stores/sidebar-store/builders/system.ts +18 -27
- package/eventcatalog/src/stores/sidebar-store/state.ts +5 -0
- package/eventcatalog/src/styles/tailwind.css +2 -2
- package/eventcatalog/src/utils/collections/channels.ts +56 -1
- package/eventcatalog/src/utils/collections/flows.ts +50 -1
- package/eventcatalog/src/utils/collections/message-connections.ts +60 -0
- package/eventcatalog/src/utils/collections/message-triggers.ts +2 -1
- package/eventcatalog/src/utils/collections/resource-owners.ts +193 -0
- package/eventcatalog/src/utils/collections/resources.ts +310 -0
- package/eventcatalog/src/utils/collections/util.ts +31 -0
- package/eventcatalog/src/utils/feature.ts +8 -0
- package/eventcatalog/src/utils/git.ts +11 -5
- package/eventcatalog/src/utils/node-graphs/export-mermaid.ts +0 -2
- package/eventcatalog/src/utils/trial.ts +1 -1
- package/package.json +17 -12
- package/dist/runtime-dependencies/shelljs.mjs +0 -3
- package/eventcatalog/public/studio-bg.png +0 -0
- package/eventcatalog/src/components/Grids/DomainGrid.tsx +0 -838
- package/eventcatalog/src/components/Grids/MessageGrid.tsx +0 -344
- package/eventcatalog/src/components/Grids/SystemGrid.tsx +0 -185
- package/eventcatalog/src/components/Grids/components.tsx +0 -170
- package/eventcatalog/src/components/Grids/message-link.ts +0 -38
- package/eventcatalog/src/components/Studio/StudioPageModal.tsx +0 -150
- package/eventcatalog/src/components/Tables/SystemResources/SystemResourcesTable.tsx +0 -294
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_resources.spec.ts +0 -65
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/_resources.ts +0 -46
- package/eventcatalog/src/pages/studio.astro +0 -316
- package/dist/{chunk-AYNZXUB5.js → chunk-KHACCTW2.js} +3 -3
|
@@ -24,26 +24,3 @@ export const getCollectionStyles = (collection: CollectionMessageTypes | Collect
|
|
|
24
24
|
return { color: 'gray', Icon: EnvelopeIcon };
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export interface PaginationProps {
|
|
29
|
-
currentPage: number;
|
|
30
|
-
totalPages: number;
|
|
31
|
-
totalItems: number;
|
|
32
|
-
itemsPerPage: number;
|
|
33
|
-
onPageChange: (page: number) => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface SearchBarProps {
|
|
37
|
-
searchQuery: string;
|
|
38
|
-
onSearchChange: (query: string) => void;
|
|
39
|
-
placeholder?: string;
|
|
40
|
-
totalResults?: number;
|
|
41
|
-
totalItems?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface TypeFilterProps {
|
|
45
|
-
selectedTypes: CollectionMessageTypes[];
|
|
46
|
-
onTypeChange: (types: CollectionMessageTypes[]) => void;
|
|
47
|
-
filteredCount?: number;
|
|
48
|
-
totalCount?: number;
|
|
49
|
-
}
|
|
@@ -94,16 +94,16 @@ const providerName = user?.provider ? providerNames[user.provider] || user.provi
|
|
|
94
94
|
<img
|
|
95
95
|
src={userImage}
|
|
96
96
|
alt=""
|
|
97
|
-
class="h-
|
|
97
|
+
class="h-7 w-7 rounded-full object-cover ring-1 ring-[rgb(var(--ec-page-border))]"
|
|
98
98
|
/>
|
|
99
99
|
) : (
|
|
100
|
-
<span class="h-
|
|
100
|
+
<span class="h-7 w-7 rounded-full bg-[rgb(var(--ec-accent-subtle))] text-[rgb(var(--ec-accent))] ring-1 ring-[rgb(var(--ec-page-border))] flex items-center justify-center text-[11px] font-semibold">
|
|
101
101
|
{userInitials}
|
|
102
102
|
</span>
|
|
103
103
|
)}
|
|
104
104
|
<svg
|
|
105
105
|
viewBox="0 0 24 24"
|
|
106
|
-
class="h-
|
|
106
|
+
class="h-3.5 w-3.5 transition-transform group-aria-expanded:rotate-180"
|
|
107
107
|
fill="none"
|
|
108
108
|
stroke="currentColor"
|
|
109
109
|
stroke-width="2"
|
|
@@ -167,7 +167,12 @@ export default function CodeGroup({
|
|
|
167
167
|
hidden={index !== active}
|
|
168
168
|
tabIndex={0}
|
|
169
169
|
>
|
|
170
|
-
{
|
|
170
|
+
{/* Astro's router marks scripts in this HTML with data-astro-exec before hydration, so it never matches exactly. */}
|
|
171
|
+
{item.html !== undefined ? (
|
|
172
|
+
<div suppressHydrationWarning dangerouslySetInnerHTML={{ __html: item.html }} />
|
|
173
|
+
) : (
|
|
174
|
+
item.content
|
|
175
|
+
)}
|
|
171
176
|
</div>
|
|
172
177
|
))}
|
|
173
178
|
</div>
|
|
@@ -384,6 +384,9 @@ export default function SchemaDetailsPanel({
|
|
|
384
384
|
[diffToVersion, uniqueAvailableVersions]
|
|
385
385
|
);
|
|
386
386
|
const comparing = (activeTab === 'versions' && hasMultipleVersions) || isDiffModalOpen;
|
|
387
|
+
const contentReady = !content.loading && !content.error;
|
|
388
|
+
// Server-rendered examples stay mounted and are only shown on the Examples tab (see the tab content below).
|
|
389
|
+
const showRenderedExamples = !!renderedExamples && activeTab === 'examples' && contentReady;
|
|
387
390
|
|
|
388
391
|
const compareWithCurrent = (version: string) => {
|
|
389
392
|
setDiffFromVersion(version);
|
|
@@ -705,11 +708,16 @@ export default function SchemaDetailsPanel({
|
|
|
705
708
|
|
|
706
709
|
{/* Tab content */}
|
|
707
710
|
<div className="flex-1 min-h-0 overflow-hidden p-6">
|
|
708
|
-
{
|
|
711
|
+
{/* Always render the examples slot and hide it on other tabs. Astro moves a slot missing from the
|
|
712
|
+
server HTML into a <template>, where its island scripts never run and no island on the page hydrates. */}
|
|
713
|
+
{renderedExamples && (
|
|
714
|
+
<div className="h-full overflow-auto pr-1" hidden={!showRenderedExamples}>
|
|
715
|
+
{renderedExamples}
|
|
716
|
+
</div>
|
|
717
|
+
)}
|
|
718
|
+
{!contentReady ? (
|
|
709
719
|
<SchemaLoadingState loading={content.loading} error={content.error} retry={content.retry} />
|
|
710
|
-
) : activeTab === 'examples' &&
|
|
711
|
-
<div className="h-full overflow-auto pr-1">{renderedExamples}</div>
|
|
712
|
-
) : activeTab === 'examples' && examples.length > 0 ? (
|
|
720
|
+
) : showRenderedExamples ? null : activeTab === 'examples' && examples.length > 0 ? (
|
|
713
721
|
<ExamplesViewer examples={examples} />
|
|
714
722
|
) : activeTab === 'metadata' ? (
|
|
715
723
|
<SchemaMetadata message={message} owners={showOwners ? owners : []} />
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
findNodeKeyByUrl,
|
|
26
26
|
getBadgeClasses,
|
|
27
27
|
getDefaultCollapsedState,
|
|
28
|
+
hidesDefaultItemIcon,
|
|
28
29
|
isGroupCollapsed,
|
|
29
30
|
toggleGroupCollapsed,
|
|
30
31
|
} from './utils';
|
|
@@ -663,6 +664,11 @@ export default function NestedSideBar() {
|
|
|
663
664
|
|
|
664
665
|
const isTopLevel = navigationStack.length === 1;
|
|
665
666
|
|
|
667
|
+
// The list drilled into (e.g. Channels): its items, even those in groups under it (e.g. ADRs
|
|
668
|
+
// grouped by status), drop a default icon that repeats the list's own
|
|
669
|
+
const levelNode = currentLevel.key ? resolveRef(currentLevel.key) : null;
|
|
670
|
+
const repeatsLevelIcon = (item: NavNode) => !!levelNode && hidesDefaultItemIcon(levelNode, item, false);
|
|
671
|
+
|
|
666
672
|
/**
|
|
667
673
|
* Render a list of child refs (resolving keys as needed)
|
|
668
674
|
*/
|
|
@@ -674,7 +680,7 @@ export default function NestedSideBar() {
|
|
|
674
680
|
if (currentItemGroup.length > 0) {
|
|
675
681
|
result.push(
|
|
676
682
|
<div key={`items-${result.length}`} className="flex flex-col gap-0.5 mb-1.5">
|
|
677
|
-
{currentItemGroup.map((item, idx) => renderItem(item.node, item.key, idx))}
|
|
683
|
+
{currentItemGroup.map((item, idx) => renderItem(item.node, item.key, idx, repeatsLevelIcon(item.node)))}
|
|
678
684
|
</div>
|
|
679
685
|
);
|
|
680
686
|
currentItemGroup = [];
|
|
@@ -795,9 +801,12 @@ export default function NestedSideBar() {
|
|
|
795
801
|
return renderGroup(child, childKey, childIndex, depth + 1);
|
|
796
802
|
}
|
|
797
803
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
804
|
+
return renderItem(
|
|
805
|
+
child,
|
|
806
|
+
childKey,
|
|
807
|
+
childIndex,
|
|
808
|
+
hidesDefaultItemIcon(group, child, isNested) || repeatsLevelIcon(child)
|
|
809
|
+
);
|
|
801
810
|
})}
|
|
802
811
|
</div>
|
|
803
812
|
)}
|
|
@@ -814,9 +823,9 @@ export default function NestedSideBar() {
|
|
|
814
823
|
const isFav = isFavorited(itemKey);
|
|
815
824
|
const canFavorite = itemKey !== null; // Only items with keys can be favorited
|
|
816
825
|
|
|
817
|
-
// Get icon component from lucide-react. When suppressDefaultIcon is set (
|
|
818
|
-
//
|
|
819
|
-
// a custom icon (item.leftIcon) is always still shown.
|
|
826
|
+
// Get icon component from lucide-react. When suppressDefaultIcon is set (the group heading
|
|
827
|
+
// already shows the item's type, see hidesDefaultItemIcon) the default per-collection glyph
|
|
828
|
+
// is hidden; a custom icon (item.leftIcon) is always still shown.
|
|
820
829
|
const IconComponent =
|
|
821
830
|
item.icon && !suppressDefaultIcon ? (LucideIcons as unknown as Record<string, LucideIcons.LucideIcon>)[item.icon] : null;
|
|
822
831
|
const handleStarClick = (e: React.MouseEvent) => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Shared utilities for NestedSideBar components
|
|
2
2
|
|
|
3
|
+
import type { NavNode } from '@stores/sidebar-store/state';
|
|
4
|
+
|
|
3
5
|
export const SIDEBAR_GROUP_COLLAPSE_THRESHOLD = 5;
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -67,6 +69,14 @@ export const toggleGroupCollapsed = (
|
|
|
67
69
|
* Finds the sidebar node represented by a resource URL.
|
|
68
70
|
* The URL must have its configured base path removed before it is passed in.
|
|
69
71
|
*/
|
|
72
|
+
/**
|
|
73
|
+
* Whether an item in a group drops its default per-collection icon because the group heading
|
|
74
|
+
* already conveys its type: every item under a nested group, and items whose icon is the
|
|
75
|
+
* group's own (e.g. events listed under Events). Custom icons (`leftIcon`) always show.
|
|
76
|
+
*/
|
|
77
|
+
export const hidesDefaultItemIcon = (group: NavNode, item: NavNode, isNested: boolean): boolean =>
|
|
78
|
+
isNested || (!!group.icon && group.icon === item.icon);
|
|
79
|
+
|
|
70
80
|
export const findNodeKeyByUrl = (
|
|
71
81
|
url: string,
|
|
72
82
|
nodes: Record<string, unknown>,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type ColumnFiltersState,
|
|
12
12
|
type SortingState,
|
|
13
13
|
} from '@tanstack/react-table';
|
|
14
|
-
import { ArrowDown, ArrowUp, ArrowUpDown,
|
|
14
|
+
import { ArrowDown, ArrowUp, ArrowUpDown, SearchX, X, Search, Users } from 'lucide-react';
|
|
15
15
|
import { UserIcon } from '@heroicons/react/24/outline';
|
|
16
16
|
import { useEffect, useMemo, useState } from 'react';
|
|
17
17
|
import type { TableConfiguration } from '@types';
|
|
@@ -19,6 +19,7 @@ import { isSameVersion } from '@utils/collections/version-compare';
|
|
|
19
19
|
import { resolveIconUrl } from '@utils/icon';
|
|
20
20
|
import { FilterDropdown, CheckboxItem } from './FilterComponents';
|
|
21
21
|
import { getDiscoverColumns } from './columns';
|
|
22
|
+
import { TablePagination, useStoredPageSize } from '../TablePagination';
|
|
22
23
|
import { formatAdrStatus, type AdrStatus } from '@utils/collections/adr-constants';
|
|
23
24
|
import { buildDiscoverFilterSearch, filterKnownValues, parseDiscoverFilterSearch } from './url-filters';
|
|
24
25
|
|
|
@@ -243,18 +244,7 @@ export function DiscoverTable<T extends DiscoverTableData>({
|
|
|
243
244
|
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
|
|
244
245
|
const [sorting, setSorting] = useState<SortingState>([]);
|
|
245
246
|
const [tableFilter, setTableFilter] = useState(initialUrlFilters.q);
|
|
246
|
-
const
|
|
247
|
-
const PAGE_SIZE_STORAGE_KEY = 'eventcatalog-discover-page-size';
|
|
248
|
-
const [pageSize, setPageSize] = useState<number>(() => {
|
|
249
|
-
if (typeof window === 'undefined') return 10;
|
|
250
|
-
const stored = Number(window.localStorage.getItem(PAGE_SIZE_STORAGE_KEY));
|
|
251
|
-
return PAGE_SIZE_OPTIONS.includes(stored) ? stored : 10;
|
|
252
|
-
});
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
if (typeof window !== 'undefined') {
|
|
255
|
-
window.localStorage.setItem(PAGE_SIZE_STORAGE_KEY, String(pageSize));
|
|
256
|
-
}
|
|
257
|
-
}, [pageSize]);
|
|
247
|
+
const [pageSize, setPageSize] = useStoredPageSize('eventcatalog-discover-page-size');
|
|
258
248
|
const [showOnlyLatest, setShowOnlyLatest] = useState(initialUrlFilters.showOnlyLatest);
|
|
259
249
|
const [onlyShowDrafts, setOnlyShowDrafts] = useState(initialUrlFilters.onlyShowDrafts);
|
|
260
250
|
const [selectedDomains, setSelectedDomains] = useState<string[]>(() =>
|
|
@@ -1287,55 +1277,7 @@ export function DiscoverTable<T extends DiscoverTableData>({
|
|
|
1287
1277
|
</div>
|
|
1288
1278
|
</div>
|
|
1289
1279
|
|
|
1290
|
-
{
|
|
1291
|
-
<div className="flex-shrink-0 flex items-center justify-between px-6 py-3 border-t border-[rgb(var(--ec-page-border))]">
|
|
1292
|
-
<div className="flex items-center gap-3 text-xs text-[rgb(var(--ec-page-text-muted))]">
|
|
1293
|
-
{totalResults > 0 && (
|
|
1294
|
-
<span>
|
|
1295
|
-
<span className="font-medium text-[rgb(var(--ec-page-text))]">{table.getRowModel().rows.length}</span> of{' '}
|
|
1296
|
-
<span className="font-medium text-[rgb(var(--ec-page-text))]">{totalResults}</span> results
|
|
1297
|
-
</span>
|
|
1298
|
-
)}
|
|
1299
|
-
{totalResults > 0 && <span aria-hidden className="h-3 w-px bg-[rgb(var(--ec-page-border))]" />}
|
|
1300
|
-
<label className="flex items-center gap-1.5">
|
|
1301
|
-
<span>Per page</span>
|
|
1302
|
-
<select
|
|
1303
|
-
value={pageSize}
|
|
1304
|
-
onChange={(e) => setPageSize(Number(e.target.value))}
|
|
1305
|
-
className="cursor-pointer rounded bg-transparent px-1 py-0.5 font-medium text-[rgb(var(--ec-page-text))] hover:bg-[rgb(var(--ec-content-hover))] focus:bg-[rgb(var(--ec-content-hover))] focus:outline-none"
|
|
1306
|
-
>
|
|
1307
|
-
{PAGE_SIZE_OPTIONS.map((size) => (
|
|
1308
|
-
<option key={size} value={size}>
|
|
1309
|
-
{size}
|
|
1310
|
-
</option>
|
|
1311
|
-
))}
|
|
1312
|
-
</select>
|
|
1313
|
-
</label>
|
|
1314
|
-
</div>
|
|
1315
|
-
<div className="flex items-center gap-1.5">
|
|
1316
|
-
<button
|
|
1317
|
-
className="p-1.5 text-[rgb(var(--ec-icon-color))] hover:text-[rgb(var(--ec-page-text))] disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
|
|
1318
|
-
onClick={() => table.previousPage()}
|
|
1319
|
-
disabled={!table.getCanPreviousPage()}
|
|
1320
|
-
title="Previous page"
|
|
1321
|
-
>
|
|
1322
|
-
<ChevronLeft className="w-4 h-4" />
|
|
1323
|
-
</button>
|
|
1324
|
-
<span className="text-xs tabular-nums text-[rgb(var(--ec-page-text-muted))] min-w-[60px] text-center">
|
|
1325
|
-
<span className="font-medium text-[rgb(var(--ec-page-text))]">{table.getState().pagination.pageIndex + 1}</span>
|
|
1326
|
-
{' / '}
|
|
1327
|
-
<span>{table.getPageCount() || 1}</span>
|
|
1328
|
-
</span>
|
|
1329
|
-
<button
|
|
1330
|
-
className="p-1.5 text-[rgb(var(--ec-icon-color))] hover:text-[rgb(var(--ec-page-text))] disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
|
|
1331
|
-
onClick={() => table.nextPage()}
|
|
1332
|
-
disabled={!table.getCanNextPage()}
|
|
1333
|
-
title="Next page"
|
|
1334
|
-
>
|
|
1335
|
-
<ChevronRight className="w-4 h-4" />
|
|
1336
|
-
</button>
|
|
1337
|
-
</div>
|
|
1338
|
-
</div>
|
|
1280
|
+
<TablePagination table={table} pageSize={pageSize} onPageSizeChange={setPageSize} />
|
|
1339
1281
|
</div>
|
|
1340
1282
|
</div>
|
|
1341
1283
|
);
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import { createColumnHelper } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DocumentTextIcon, MapIcon } from '@heroicons/react/24/solid';
|
|
5
|
-
import {
|
|
6
|
-
ArrowDownIcon,
|
|
7
|
-
ArrowTopRightOnSquareIcon,
|
|
8
|
-
ArrowUpIcon,
|
|
9
|
-
EllipsisVerticalIcon,
|
|
10
|
-
StarIcon,
|
|
11
|
-
} from '@heroicons/react/24/outline';
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { ArrowDownIcon, ArrowTopRightOnSquareIcon, ArrowUpIcon } from '@heroicons/react/24/outline';
|
|
12
4
|
import { buildUrl } from '@utils/url-builder';
|
|
13
5
|
import { getColorAndIconForCollection } from '@utils/collections/icons';
|
|
14
6
|
import { getCollectionTextColorClass } from '@utils/collection-colors';
|
|
15
7
|
import { getBadgeHref, getBadgeReactStyle } from '@utils/badge-styles';
|
|
16
8
|
import { isIconPath, resolveIconUrl } from '@utils/icon';
|
|
17
|
-
import { useStore } from '@nanostores/react';
|
|
18
|
-
import { favoritesStore, toggleFavorite, type FavoriteItem } from '../../../stores/favorites-store';
|
|
19
9
|
import type { DiscoverTableData, CollectionType } from './DiscoverTable';
|
|
20
10
|
import type { TableConfiguration } from '@types';
|
|
21
11
|
import { formatAdrDate, isAdrCollection } from '@utils/collections/adr-constants';
|
|
22
12
|
import { CornerDownRight } from 'lucide-react';
|
|
13
|
+
import { RowActionsMenu } from '../RowActionsMenu';
|
|
23
14
|
|
|
24
15
|
const columnHelper = createColumnHelper<DiscoverTableData>();
|
|
25
16
|
|
|
@@ -167,147 +158,23 @@ const ResourceNameCell = ({ item }: { item: DiscoverTableData }) => {
|
|
|
167
158
|
);
|
|
168
159
|
};
|
|
169
160
|
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const RowActionsMenu = ({ item, collectionType }: { item: DiscoverTableData; collectionType: CollectionType }) => {
|
|
174
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
175
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
176
|
-
const menuRef = useRef<HTMLDivElement>(null);
|
|
177
|
-
const [menuPosition, setMenuPosition] = useState<{ top: number; left: number } | null>(null);
|
|
178
|
-
const favorites = useStore(favoritesStore);
|
|
179
|
-
const href = buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`);
|
|
180
|
-
const visualiserHref = buildUrl(`/visualiser/${item.collection}/${item.data.id}/${item.data.version}`);
|
|
181
|
-
const hasVisualiser = !isAdrCollection(item.collection);
|
|
182
|
-
const nodeKey = `${item.collection}-${item.data.id}-${item.data.version}`;
|
|
183
|
-
const badgeLabel =
|
|
161
|
+
// Discover keys favorites as `${collection}-${id}-${version}`; keep that so existing favorites still match.
|
|
162
|
+
const DiscoverRowActions = ({ item, collectionType }: { item: DiscoverTableData; collectionType: CollectionType }) => {
|
|
163
|
+
const badge =
|
|
184
164
|
collectionType === 'external-systems'
|
|
185
165
|
? 'External System'
|
|
186
166
|
: collectionType.charAt(0).toUpperCase() + collectionType.slice(1, -1);
|
|
187
|
-
const isFavorite = favorites.some((fav) => fav.nodeKey === nodeKey);
|
|
188
|
-
|
|
189
|
-
// The table lives inside scrollable, overflow-hidden containers, so the menu is
|
|
190
|
-
// rendered in a portal with fixed positioning to avoid being clipped.
|
|
191
|
-
const updatePosition = () => {
|
|
192
|
-
const button = buttonRef.current;
|
|
193
|
-
if (!button) return;
|
|
194
|
-
const rect = button.getBoundingClientRect();
|
|
195
|
-
const menuHeight = menuRef.current?.offsetHeight ?? 0;
|
|
196
|
-
const spaceBelow = window.innerHeight - rect.bottom;
|
|
197
|
-
|
|
198
|
-
// Flip above the trigger when there isn't enough room below it.
|
|
199
|
-
const openUpwards = menuHeight > 0 && spaceBelow < menuHeight + MENU_GAP && rect.top > spaceBelow;
|
|
200
|
-
const top = openUpwards ? rect.top - menuHeight - MENU_GAP : rect.bottom + MENU_GAP;
|
|
201
|
-
const left = Math.max(MENU_GAP, rect.right - MENU_WIDTH);
|
|
202
|
-
|
|
203
|
-
setMenuPosition({ top, left });
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
useLayoutEffect(() => {
|
|
207
|
-
if (!isOpen) return;
|
|
208
|
-
updatePosition();
|
|
209
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
210
|
-
}, [isOpen]);
|
|
211
|
-
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (!isOpen) return;
|
|
214
|
-
|
|
215
|
-
const handlePointerDown = (event: MouseEvent) => {
|
|
216
|
-
const target = event.target as Node;
|
|
217
|
-
if (!menuRef.current?.contains(target) && !buttonRef.current?.contains(target)) {
|
|
218
|
-
setIsOpen(false);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const handleEscape = (event: KeyboardEvent) => {
|
|
223
|
-
if (event.key === 'Escape') {
|
|
224
|
-
setIsOpen(false);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const handleReposition = () => updatePosition();
|
|
229
|
-
|
|
230
|
-
document.addEventListener('mousedown', handlePointerDown);
|
|
231
|
-
document.addEventListener('keydown', handleEscape);
|
|
232
|
-
window.addEventListener('resize', handleReposition);
|
|
233
|
-
window.addEventListener('scroll', handleReposition, true);
|
|
234
|
-
|
|
235
|
-
return () => {
|
|
236
|
-
document.removeEventListener('mousedown', handlePointerDown);
|
|
237
|
-
document.removeEventListener('keydown', handleEscape);
|
|
238
|
-
window.removeEventListener('resize', handleReposition);
|
|
239
|
-
window.removeEventListener('scroll', handleReposition, true);
|
|
240
|
-
};
|
|
241
|
-
}, [isOpen]);
|
|
242
|
-
|
|
243
|
-
const handleToggleFavorite = () => {
|
|
244
|
-
const favoriteItem: FavoriteItem = {
|
|
245
|
-
nodeKey,
|
|
246
|
-
path: [],
|
|
247
|
-
title: item.data.name,
|
|
248
|
-
badge: badgeLabel,
|
|
249
|
-
href,
|
|
250
|
-
};
|
|
251
|
-
toggleFavorite(favoriteItem);
|
|
252
|
-
setIsOpen(false);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
167
|
return (
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
</button>
|
|
267
|
-
|
|
268
|
-
{isOpen &&
|
|
269
|
-
typeof document !== 'undefined' &&
|
|
270
|
-
createPortal(
|
|
271
|
-
<div
|
|
272
|
-
ref={menuRef}
|
|
273
|
-
role="menu"
|
|
274
|
-
style={{
|
|
275
|
-
position: 'fixed',
|
|
276
|
-
top: menuPosition?.top ?? -9999,
|
|
277
|
-
left: menuPosition?.left ?? -9999,
|
|
278
|
-
width: MENU_WIDTH,
|
|
279
|
-
visibility: menuPosition ? 'visible' : 'hidden',
|
|
280
|
-
}}
|
|
281
|
-
className="z-50 overflow-hidden rounded-xl border border-[rgb(var(--ec-page-border))] bg-[rgb(var(--ec-dropdown-bg))] shadow-xl"
|
|
282
|
-
>
|
|
283
|
-
<a
|
|
284
|
-
href={href}
|
|
285
|
-
className="flex items-center gap-2.5 px-3 py-2.5 text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
|
|
286
|
-
>
|
|
287
|
-
<DocumentTextIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
|
|
288
|
-
View documentation
|
|
289
|
-
</a>
|
|
290
|
-
{hasVisualiser && (
|
|
291
|
-
<a
|
|
292
|
-
href={visualiserHref}
|
|
293
|
-
className="flex items-center gap-2.5 px-3 py-2.5 text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
|
|
294
|
-
>
|
|
295
|
-
<MapIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
|
|
296
|
-
View in visualiser
|
|
297
|
-
</a>
|
|
298
|
-
)}
|
|
299
|
-
<button
|
|
300
|
-
type="button"
|
|
301
|
-
onClick={handleToggleFavorite}
|
|
302
|
-
className="flex w-full items-center gap-2.5 px-3 py-2.5 text-left text-xs font-medium text-[rgb(var(--ec-page-text))] transition-colors hover:bg-[rgb(var(--ec-content-hover))] hover:text-[rgb(var(--ec-accent))]"
|
|
303
|
-
>
|
|
304
|
-
<StarIcon className="h-3.5 w-3.5 text-[rgb(var(--ec-page-text-muted))]" />
|
|
305
|
-
{isFavorite ? 'Remove from favorites' : 'Add to favorites'}
|
|
306
|
-
</button>
|
|
307
|
-
</div>,
|
|
308
|
-
document.body
|
|
309
|
-
)}
|
|
310
|
-
</div>
|
|
168
|
+
<RowActionsMenu
|
|
169
|
+
title={item.data.name}
|
|
170
|
+
href={buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`)}
|
|
171
|
+
visualiserHref={
|
|
172
|
+
isAdrCollection(item.collection)
|
|
173
|
+
? undefined
|
|
174
|
+
: buildUrl(`/visualiser/${item.collection}/${item.data.id}/${item.data.version}`)
|
|
175
|
+
}
|
|
176
|
+
favorite={{ nodeKey: `${item.collection}-${item.data.id}-${item.data.version}`, badge }}
|
|
177
|
+
/>
|
|
311
178
|
);
|
|
312
179
|
};
|
|
313
180
|
|
|
@@ -319,7 +186,7 @@ const createActionsColumn = (collectionType: CollectionType, tableConfiguration:
|
|
|
319
186
|
enableSorting: false,
|
|
320
187
|
cell: (info) => {
|
|
321
188
|
const item = info.row.original;
|
|
322
|
-
return <
|
|
189
|
+
return <DiscoverRowActions item={item} collectionType={collectionType} />;
|
|
323
190
|
},
|
|
324
191
|
meta: {
|
|
325
192
|
showFilter: false,
|