Skip to content

Commit

Permalink
feat(topology): render Cryostat icon for Agent targets (cryostatio#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Sep 20, 2023
1 parent e19d1be commit f8fecd3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/Topology/GraphView/CustomNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { RESOURCE_NAME_TRUNCATE_LENGTH } from './UtilsFactory';

export const NODE_ICON_PADDING = 5;

export const renderIcon = (_data: TargetNode, element: Node, useAlt: boolean): React.ReactNode => {
export const renderIcon = (graphic, _data: TargetNode, element: Node, useAlt: boolean): React.ReactNode => {
const { width, height } = element.getDimensions();

const contentSize = Math.min(width, height) - NODE_ICON_PADDING * 2;
Expand All @@ -63,7 +63,7 @@ export const renderIcon = (_data: TargetNode, element: Node, useAlt: boolean): R
<ContainerNodeIcon width={mainContentSize} height={mainContentSize} />
</g>
) : (
<image x={trueCx} y={trueCy} width={mainContentSize} height={mainContentSize} xlinkHref={openjdkSvg} />
<image x={trueCx} y={trueCy} width={mainContentSize} height={mainContentSize} xlinkHref={graphic} />
)}
</>
);
Expand Down Expand Up @@ -99,6 +99,8 @@ const CustomNode: React.FC<CustomNodeProps> = ({

const data: TargetNode = element.getData();

const graphic = React.useMemo(() => (data.target.connectUrl.startsWith('http') ? cryostatSvg : openjdkSvg), [data]);

const [nodeStatus] = getStatusTargetNode(data);

const graphId = React.useMemo(() => element.getGraph().getId(), [element]);
Expand Down Expand Up @@ -138,7 +140,7 @@ const CustomNode: React.FC<CustomNodeProps> = ({
showLabel
attachments={nodeDecorators}
>
<g id={'target-node-visual-inner-icon'}>{renderIcon(data, element, !showIcon)}</g>
<g id={'target-node-visual-inner-icon'}>{renderIcon(graphic, data, element, !showIcon)}</g>
</DefaultNode>
</g>
</Layer>
Expand Down

0 comments on commit f8fecd3

Please sign in to comment.