datajunction-ui 0.0.115 → 0.0.117
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/package.json
CHANGED
|
@@ -702,18 +702,27 @@ describe('NamespacePage', () => {
|
|
|
702
702
|
);
|
|
703
703
|
});
|
|
704
704
|
|
|
705
|
-
it('calls listNodesForLanding for the default branch namespace', async () => {
|
|
705
|
+
it('calls listNodesForLanding once per node type for the default branch namespace', async () => {
|
|
706
706
|
renderWithProviders(<NamespacePage />);
|
|
707
707
|
|
|
708
708
|
await waitFor(
|
|
709
709
|
() => {
|
|
710
|
-
//
|
|
711
|
-
// 'default.main' should be made
|
|
710
|
+
// One call per node type is made for the default branch preview
|
|
712
711
|
const calls = mockDjClient.listNodesForLanding.mock.calls;
|
|
713
|
-
const
|
|
712
|
+
const defaultBranchCalls = calls.filter(
|
|
714
713
|
args => args[0] === 'default.main',
|
|
715
714
|
);
|
|
716
|
-
expect(
|
|
715
|
+
expect(defaultBranchCalls).toHaveLength(5);
|
|
716
|
+
const types = defaultBranchCalls.map(args => args[1][0]);
|
|
717
|
+
expect(types).toEqual(
|
|
718
|
+
expect.arrayContaining([
|
|
719
|
+
'METRIC',
|
|
720
|
+
'CUBE',
|
|
721
|
+
'DIMENSION',
|
|
722
|
+
'TRANSFORM',
|
|
723
|
+
'SOURCE',
|
|
724
|
+
]),
|
|
725
|
+
);
|
|
717
726
|
},
|
|
718
727
|
{ timeout: 3000 },
|
|
719
728
|
);
|
|
@@ -42,19 +42,10 @@ const NODE_TYPE_COLORS = {
|
|
|
42
42
|
source: { bg: '#ccf7e5', color: '#00b368' },
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
function DefaultBranchPreview({
|
|
46
|
-
const
|
|
47
|
-
nodes.forEach(node => {
|
|
48
|
-
const type = (node.type || 'unknown').toLowerCase();
|
|
49
|
-
if (!groups[type]) groups[type] = [];
|
|
50
|
-
groups[type].push(node);
|
|
51
|
-
});
|
|
52
|
-
const grouped = NODE_TYPE_ORDER.filter(t => groups[t]?.length > 0).map(t => ({
|
|
53
|
-
type: t,
|
|
54
|
-
nodes: groups[t],
|
|
55
|
-
}));
|
|
45
|
+
function DefaultBranchPreview({ groups, defaultBranchNs }) {
|
|
46
|
+
const filtered = groups.filter(g => g.nodes.length > 0);
|
|
56
47
|
|
|
57
|
-
if (
|
|
48
|
+
if (filtered.length === 0) return null;
|
|
58
49
|
|
|
59
50
|
return (
|
|
60
51
|
<div
|
|
@@ -65,9 +56,8 @@ function DefaultBranchPreview({ nodes, defaultBranchNs }) {
|
|
|
65
56
|
margin: '20px',
|
|
66
57
|
}}
|
|
67
58
|
>
|
|
68
|
-
{
|
|
69
|
-
const shown = typeNodes
|
|
70
|
-
const remaining = typeNodes.length - shown.length;
|
|
59
|
+
{filtered.map(({ type, nodes: typeNodes, hasMore }, idx) => {
|
|
60
|
+
const shown = typeNodes;
|
|
71
61
|
const isLeftCol = idx % 2 === 0;
|
|
72
62
|
return (
|
|
73
63
|
<div
|
|
@@ -113,7 +103,7 @@ function DefaultBranchPreview({ nodes, defaultBranchNs }) {
|
|
|
113
103
|
{typeNodes.length}
|
|
114
104
|
</span>
|
|
115
105
|
</span>
|
|
116
|
-
{
|
|
106
|
+
{hasMore && (
|
|
117
107
|
<a
|
|
118
108
|
href={`/namespaces/${defaultBranchNs}?type=${type}`}
|
|
119
109
|
style={{
|
|
@@ -123,7 +113,7 @@ function DefaultBranchPreview({ nodes, defaultBranchNs }) {
|
|
|
123
113
|
fontWeight: '500',
|
|
124
114
|
}}
|
|
125
115
|
>
|
|
126
|
-
|
|
116
|
+
see all →
|
|
127
117
|
</a>
|
|
128
118
|
)}
|
|
129
119
|
</div>
|
|
@@ -383,7 +373,7 @@ export function NamespacePage() {
|
|
|
383
373
|
// Branch landing state (for git-root namespaces)
|
|
384
374
|
const [branches, setBranches] = useState(null); // null = not yet fetched
|
|
385
375
|
const [branchesLoading, setBranchesLoading] = useState(false);
|
|
386
|
-
const [
|
|
376
|
+
const [defaultBranchGroups, setDefaultBranchGroups] = useState([]);
|
|
387
377
|
const [defaultBranchNodesLoading, setDefaultBranchNodesLoading] =
|
|
388
378
|
useState(false);
|
|
389
379
|
|
|
@@ -426,35 +416,45 @@ export function NamespacePage() {
|
|
|
426
416
|
.finally(() => setBranchesLoading(false));
|
|
427
417
|
}, [djClient, namespace, isGitRoot]);
|
|
428
418
|
|
|
429
|
-
// Fetch default branch nodes for the
|
|
419
|
+
// Fetch default branch nodes for the preview, one query per node type so
|
|
420
|
+
// that no single type crowds out the others in a shared limit.
|
|
430
421
|
useEffect(() => {
|
|
431
422
|
if (!isGitRoot || !gitConfig?.default_branch) return;
|
|
432
423
|
const defaultBranchNs = `${namespace}.${gitConfig.default_branch}`;
|
|
433
424
|
setDefaultBranchNodesLoading(true);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
425
|
+
const fetchLimit = MAX_PER_TYPE + 1;
|
|
426
|
+
Promise.all(
|
|
427
|
+
NODE_TYPE_ORDER.map(type =>
|
|
428
|
+
djClient
|
|
429
|
+
.listNodesForLanding(
|
|
430
|
+
defaultBranchNs,
|
|
431
|
+
[type.toUpperCase()],
|
|
432
|
+
[],
|
|
433
|
+
null,
|
|
434
|
+
null,
|
|
435
|
+
null,
|
|
436
|
+
fetchLimit,
|
|
437
|
+
{ key: 'name', direction: 'ascending' },
|
|
438
|
+
null,
|
|
439
|
+
{},
|
|
440
|
+
)
|
|
441
|
+
.then(result => {
|
|
442
|
+
const edges = result?.data?.findNodesPaginated?.edges ?? [];
|
|
443
|
+
const nodes = edges.map(e => ({
|
|
444
|
+
...e.node,
|
|
445
|
+
status: e.node.current?.status,
|
|
446
|
+
mode: e.node.current?.mode,
|
|
447
|
+
}));
|
|
448
|
+
return {
|
|
449
|
+
type,
|
|
450
|
+
nodes: nodes.slice(0, MAX_PER_TYPE),
|
|
451
|
+
hasMore: nodes.length > MAX_PER_TYPE,
|
|
452
|
+
};
|
|
453
|
+
})
|
|
454
|
+
.catch(() => ({ type, nodes: [], hasMore: false })),
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
.then(groups => setDefaultBranchGroups(groups))
|
|
458
458
|
.finally(() => setDefaultBranchNodesLoading(false));
|
|
459
459
|
}, [djClient, namespace, isGitRoot, gitConfig?.default_branch]);
|
|
460
460
|
|
|
@@ -1531,7 +1531,7 @@ export function NamespacePage() {
|
|
|
1531
1531
|
<LoadingIcon />
|
|
1532
1532
|
) : (
|
|
1533
1533
|
<DefaultBranchPreview
|
|
1534
|
-
|
|
1534
|
+
groups={defaultBranchGroups}
|
|
1535
1535
|
defaultBranchNs={`${namespace}.${gitConfig.default_branch}`}
|
|
1536
1536
|
/>
|
|
1537
1537
|
)}
|