@eventcatalog/core 5.0.0-beta.1 → 5.0.0-beta.3
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/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/{chunk-AYNZXUB5.js → chunk-3PKS2IIP.js} +4 -4
- package/dist/{chunk-Q6SD5SNQ.js → chunk-423S2KHN.js} +1 -1
- package/dist/{chunk-UDS3SYLZ.js → chunk-6OC46WQJ.js} +1 -1
- package/dist/{chunk-K2ACDO7Y.js → chunk-BH2F5WPN.js} +1 -1
- package/dist/{chunk-S2QGT7ZF.js → chunk-GYIVJXOJ.js} +1 -1
- package/dist/{chunk-KYJZJLBD.js → chunk-NDJOAITI.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +1 -1
- package/dist/eventcatalog.js +13 -13
- package/dist/federation/federate.js +4 -4
- package/dist/federation/source-provider.js +2 -2
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/eventcatalog/src/components/Grids/utils.tsx +0 -23
- package/eventcatalog/src/components/MDX/CodeGroup/CodeGroup.tsx +6 -1
- package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +12 -4
- 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/mcp/apps/generated/viewer.html +75 -74
- package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +0 -2
- 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/package.json +7 -7
- 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/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/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
|
@@ -176,7 +176,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
176
176
|
var import_os = __toESM(require("os"), 1);
|
|
177
177
|
|
|
178
178
|
// package.json
|
|
179
|
-
var version = "5.0.0-beta.
|
|
179
|
+
var version = "5.0.0-beta.3";
|
|
180
180
|
|
|
181
181
|
// src/constants.ts
|
|
182
182
|
var VERSION = version;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-6OC46WQJ.js";
|
|
4
4
|
import "../chunk-TQLRG35T.js";
|
|
5
5
|
import "../chunk-ZAZHAVKB.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-NDJOAITI.js";
|
|
7
|
+
import "../chunk-GYIVJXOJ.js";
|
|
8
8
|
import "../chunk-RFIXKATC.js";
|
|
9
9
|
export {
|
|
10
10
|
log_build_default as default
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withFederationOutputTransaction
|
|
3
|
+
} from "./chunk-WRNH5C3U.js";
|
|
1
4
|
import {
|
|
2
5
|
composePublicAssets
|
|
3
6
|
} from "./chunk-5EPNFDT5.js";
|
|
4
7
|
import {
|
|
5
8
|
createFederationSourceProvider
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6K7XZAYI.js";
|
|
7
10
|
import {
|
|
8
11
|
createFederationContentCache
|
|
9
12
|
} from "./chunk-R7Z5ALYI.js";
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
getFederationDiagnostics,
|
|
12
15
|
resolveFederationRules
|
|
13
16
|
} from "./chunk-JJPB6EOZ.js";
|
|
14
|
-
import {
|
|
15
|
-
withFederationOutputTransaction
|
|
16
|
-
} from "./chunk-WRNH5C3U.js";
|
|
17
17
|
import {
|
|
18
18
|
getEventCatalogConfigFile
|
|
19
19
|
} from "./chunk-RFIXKATC.js";
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
package/dist/eventcatalog.cjs
CHANGED
|
@@ -181,7 +181,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
181
181
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
182
182
|
|
|
183
183
|
// package.json
|
|
184
|
-
var version = "5.0.0-beta.
|
|
184
|
+
var version = "5.0.0-beta.3";
|
|
185
185
|
|
|
186
186
|
// src/constants.ts
|
|
187
187
|
var VERSION = version;
|
package/dist/eventcatalog.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runMigrations
|
|
3
|
-
} from "./chunk-XUAF2H54.js";
|
|
4
|
-
import "./chunk-CA4U2JP7.js";
|
|
5
1
|
import {
|
|
6
2
|
log_build_default
|
|
7
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6OC46WQJ.js";
|
|
8
4
|
import {
|
|
9
5
|
getLicenseStatus,
|
|
10
6
|
printLicenseStatus
|
|
11
7
|
} from "./chunk-TQLRG35T.js";
|
|
12
8
|
import "./chunk-ZAZHAVKB.js";
|
|
9
|
+
import {
|
|
10
|
+
runMigrations
|
|
11
|
+
} from "./chunk-XUAF2H54.js";
|
|
12
|
+
import "./chunk-CA4U2JP7.js";
|
|
13
13
|
import {
|
|
14
14
|
FederationConflictError,
|
|
15
15
|
FederationDiagnosticError,
|
|
16
16
|
federateCatalog
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3PKS2IIP.js";
|
|
18
|
+
import "./chunk-WRNH5C3U.js";
|
|
18
19
|
import "./chunk-5EPNFDT5.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-6K7XZAYI.js";
|
|
21
|
+
import "./chunk-352FGP6W.js";
|
|
20
22
|
import "./chunk-R7Z5ALYI.js";
|
|
21
23
|
import {
|
|
22
24
|
getFederationDiagnosticCounts,
|
|
23
25
|
getVisibleFederationDiagnostics
|
|
24
26
|
} from "./chunk-JJPB6EOZ.js";
|
|
25
27
|
import "./chunk-SDZQJTJW.js";
|
|
26
|
-
import "./chunk-352FGP6W.js";
|
|
27
|
-
import "./chunk-WRNH5C3U.js";
|
|
28
28
|
import {
|
|
29
29
|
getProjectOutDir,
|
|
30
30
|
isAuthEnabled,
|
|
@@ -33,10 +33,10 @@ import {
|
|
|
33
33
|
} from "./chunk-MDWB5HLO.js";
|
|
34
34
|
import {
|
|
35
35
|
generate
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-423S2KHN.js";
|
|
37
37
|
import {
|
|
38
38
|
logger
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-BH2F5WPN.js";
|
|
40
40
|
import {
|
|
41
41
|
resolve_catalog_dependencies_default
|
|
42
42
|
} from "./chunk-36RYTYT5.js";
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
import {
|
|
51
51
|
watch
|
|
52
52
|
} from "./chunk-U63GDPPY.js";
|
|
53
|
-
import "./chunk-
|
|
53
|
+
import "./chunk-NDJOAITI.js";
|
|
54
54
|
import {
|
|
55
55
|
getAstroConfigPath
|
|
56
56
|
} from "./chunk-VIJJ7JKH.js";
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
} from "./chunk-LFQJXLHG.js";
|
|
67
67
|
import {
|
|
68
68
|
VERSION
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-GYIVJXOJ.js";
|
|
70
70
|
import {
|
|
71
71
|
getEventCatalogConfigFile,
|
|
72
72
|
verifyRequiredFieldsAreInCatalogConfigFile
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
FederationConflictError,
|
|
3
3
|
FederationDiagnosticError,
|
|
4
4
|
federateCatalog
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-3PKS2IIP.js";
|
|
6
|
+
import "../chunk-WRNH5C3U.js";
|
|
6
7
|
import "../chunk-5EPNFDT5.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-6K7XZAYI.js";
|
|
9
|
+
import "../chunk-352FGP6W.js";
|
|
8
10
|
import "../chunk-R7Z5ALYI.js";
|
|
9
11
|
import "../chunk-JJPB6EOZ.js";
|
|
10
12
|
import "../chunk-SDZQJTJW.js";
|
|
11
|
-
import "../chunk-352FGP6W.js";
|
|
12
|
-
import "../chunk-WRNH5C3U.js";
|
|
13
13
|
import "../chunk-RFIXKATC.js";
|
|
14
14
|
export {
|
|
15
15
|
FederationConflictError,
|
package/dist/generate.cjs
CHANGED
|
@@ -112,7 +112,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
|
112
112
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
113
113
|
|
|
114
114
|
// package.json
|
|
115
|
-
var version = "5.0.0-beta.
|
|
115
|
+
var version = "5.0.0-beta.3";
|
|
116
116
|
|
|
117
117
|
// src/constants.ts
|
|
118
118
|
var VERSION = version;
|
package/dist/generate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-423S2KHN.js";
|
|
4
|
+
import "./chunk-BH2F5WPN.js";
|
|
5
|
+
import "./chunk-GYIVJXOJ.js";
|
|
6
6
|
import "./chunk-RFIXKATC.js";
|
|
7
7
|
export {
|
|
8
8
|
generate
|
package/dist/utils/cli-logger.js
CHANGED
|
@@ -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
|
-
}
|
|
@@ -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 : []} />
|
|
@@ -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,
|