feat(devtools): display provider count on injector tree nodes (#63632)

Allows the tree visualizer to display a sublabel for each node.

Used by the injector tree to display provider count for each injector.

PR Close #63632
This commit is contained in:
AleksanderBodurri 2025-09-07 21:17:02 -04:00 committed by Jessica Janiuk
parent 950ffd001e
commit 4fa3b2673e
3 changed files with 27 additions and 0 deletions

View file

@ -154,6 +154,12 @@ export function transformInjectorResolutionPathsIntoTree(
injector,
children: [],
};
if (injector.providers !== undefined) {
const providerText = injector.providers === 1 ? 'Provider' : 'Providers';
next.subLabel = `${injector.providers} ${providerText}`;
}
next.injector.node = injectorIdToNode.get(next.injector.id);
currentLevel.push(next);
currentLevel = next.children;

View file

@ -17,6 +17,18 @@
background: var(--primary-contrast);
}
.sub-label {
background-color: #fff;
padding: 1px 4px;
bottom: -8px;
right: -2px;
font-size: 14px;
position: absolute;
border-radius: 50px;
color: #000;
outline: 1px solid #000;
}
.arrow {
fill: var(--full-contrast);
}

View file

@ -18,6 +18,7 @@ const RESIZE_OBSERVER_DEBOUNCE = 250;
export interface TreeNode {
label: string;
subLabel?: string;
children: TreeNode[];
}
@ -270,6 +271,7 @@ export class TreeVisualizer<T extends TreeNode = TreeNode> extends GraphRenderer
.attr('y', -halfLabelHeight)
.append('xhtml:div')
.attr('class', 'node')
.style('position', 'relative')
.text((node: TreeD3Node<T>) => {
const label = node.data.label;
return label.length > MAX_NODE_LABEL_LENGTH
@ -277,6 +279,13 @@ export class TreeVisualizer<T extends TreeNode = TreeNode> extends GraphRenderer
: label;
});
d3Node.each(function (node: TreeD3Node<T>) {
const subLabel = node.data.subLabel;
if (subLabel) {
d3.select(this).append('div').attr('class', 'sub-label').text(subLabel);
}
});
this.config.d3NodeModifier(d3Node);
svg.attr('height', '100%').attr('width', '100%');