@principal-ai/principal-view-react 0.13.27 → 0.13.29
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/components/GraphRenderer.js +2 -2
- package/dist/components/GraphRenderer.js.map +1 -1
- package/dist/nodes/CustomNode.d.ts.map +1 -1
- package/dist/nodes/CustomNode.js +41 -10
- package/dist/nodes/CustomNode.js.map +1 -1
- package/package.json +3 -3
- package/src/components/GraphRenderer.tsx +2 -2
- package/src/nodes/CustomNode.tsx +40 -12
- package/src/stories/OtelNodeTypesPrototype.stories.tsx +788 -0
- package/src/stories/data/graph-converter-test-execution.json +50 -50
package/src/nodes/CustomNode.tsx
CHANGED
|
@@ -439,12 +439,39 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
439
439
|
// Get display name - use name from props (falls back to node.id in converter)
|
|
440
440
|
const displayName = nodeProps.name;
|
|
441
441
|
|
|
442
|
-
// Extract
|
|
442
|
+
// Extract identifier based on node type (for display below the label)
|
|
443
|
+
// Supports: event.name, otel.spanPattern, otel.scope, otel.resourceMatch, boundary.direction
|
|
443
444
|
const eventData = nodeData?.event as { name?: string; description?: string; attributes?: Record<string, unknown> } | undefined;
|
|
444
|
-
const
|
|
445
|
+
const otelData = nodeData?.otel as { spanPattern?: string; scope?: string; resourceMatch?: Record<string, string | string[]> } | undefined;
|
|
446
|
+
const boundaryData = nodeData?.boundary as { direction?: string } | undefined;
|
|
447
|
+
|
|
448
|
+
// Get identifier from multiple sources
|
|
449
|
+
const getNodeIdentifier = (): string | undefined => {
|
|
450
|
+
// Event name (for otel-event nodes)
|
|
451
|
+
if (eventData?.name) return eventData.name;
|
|
452
|
+
// Event ref (for nodes using library events)
|
|
453
|
+
if (nodeData?.eventRef) return nodeData.eventRef as string;
|
|
454
|
+
// Span pattern (for otel-span-convention nodes)
|
|
455
|
+
if (otelData?.spanPattern) return otelData.spanPattern;
|
|
456
|
+
// Scope name (for otel-scope nodes)
|
|
457
|
+
if (otelData?.scope) return otelData.scope;
|
|
458
|
+
// Resource match (for otel-resource nodes) - show first key:value
|
|
459
|
+
if (otelData?.resourceMatch) {
|
|
460
|
+
const entries = Object.entries(otelData.resourceMatch);
|
|
461
|
+
if (entries.length > 0) {
|
|
462
|
+
const [key, value] = entries[0];
|
|
463
|
+
return `${key}: ${Array.isArray(value) ? value[0] : value}`;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
// Boundary direction (for otel-boundary nodes)
|
|
467
|
+
if (boundaryData?.direction) return boundaryData.direction;
|
|
468
|
+
return undefined;
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
const identifier = getNodeIdentifier();
|
|
445
472
|
|
|
446
|
-
// Show
|
|
447
|
-
const
|
|
473
|
+
// Show identifier if it differs from display name
|
|
474
|
+
const showIdentifier = identifier && identifier !== displayName;
|
|
448
475
|
|
|
449
476
|
// Helper to render text with word break opportunities after dots
|
|
450
477
|
const renderWithDotBreaks = (text: string) => {
|
|
@@ -461,11 +488,12 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
461
488
|
));
|
|
462
489
|
};
|
|
463
490
|
|
|
464
|
-
// Helper component for rendering name with optional
|
|
465
|
-
|
|
491
|
+
// Helper component for rendering name with optional identifier
|
|
492
|
+
// Identifiers can come from: event.name, eventRef, otel.spanPattern, otel.scope, otel.resourceMatch, boundary.direction
|
|
493
|
+
const renderNameWithIdentifier = (centered: boolean = true) => (
|
|
466
494
|
<div style={{ textAlign: centered ? 'center' : 'left', wordBreak: 'break-word' }}>
|
|
467
495
|
<div>{displayName}</div>
|
|
468
|
-
{
|
|
496
|
+
{showIdentifier && (
|
|
469
497
|
<div
|
|
470
498
|
style={{
|
|
471
499
|
fontSize: theme.fontSizes[0] * 0.75, // 75% of the main font size
|
|
@@ -474,7 +502,7 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
474
502
|
fontFamily: theme.fonts.monospace,
|
|
475
503
|
}}
|
|
476
504
|
>
|
|
477
|
-
{renderWithDotBreaks(
|
|
505
|
+
{renderWithDotBreaks(identifier)}
|
|
478
506
|
</div>
|
|
479
507
|
)}
|
|
480
508
|
</div>
|
|
@@ -786,7 +814,7 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
786
814
|
{resolveIcon(icon, 20)}
|
|
787
815
|
</div>
|
|
788
816
|
)}
|
|
789
|
-
{
|
|
817
|
+
{renderNameWithIdentifier()}
|
|
790
818
|
{state && (
|
|
791
819
|
<div
|
|
792
820
|
style={{
|
|
@@ -859,7 +887,7 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
859
887
|
{resolveIcon(icon, 20)}
|
|
860
888
|
</div>
|
|
861
889
|
)}
|
|
862
|
-
{
|
|
890
|
+
{renderNameWithIdentifier()}
|
|
863
891
|
{state && (
|
|
864
892
|
<div
|
|
865
893
|
style={{
|
|
@@ -934,7 +962,7 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
934
962
|
}}
|
|
935
963
|
>
|
|
936
964
|
{icon && resolveIcon(icon, 18)}
|
|
937
|
-
{
|
|
965
|
+
{renderNameWithIdentifier(false)}
|
|
938
966
|
</div>
|
|
939
967
|
) : (
|
|
940
968
|
<>
|
|
@@ -945,7 +973,7 @@ export const CustomNode: React.FC<NodeProps<Node<CustomNodeData>>> = ({ data, se
|
|
|
945
973
|
{resolveIcon(icon, 20)}
|
|
946
974
|
</div>
|
|
947
975
|
)}
|
|
948
|
-
{
|
|
976
|
+
{renderNameWithIdentifier()}
|
|
949
977
|
</>
|
|
950
978
|
)}
|
|
951
979
|
{state && (
|