From f31661255b366bb2f50a47b9821874bdc0cd1b8e Mon Sep 17 00:00:00 2001 From: Kfir Peled <61654899+kfirpeled@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:51:11 +0000 Subject: [PATCH] [Cloud Security] Improve graph node label ellipsis logic (#204580) ## Summary This PR improves the logic of node's label truncation. It follows the guidelines from design: > - Set the maximum width for names to 160px > - Truncate names to max two lines > - I recommend truncating names in the middle, as entity IDs often differ only in their last characters while starting similarly. This approach will make it easier to identify differences between names > - Display the full name in a tooltip on hover for better visibility Before: After: https://github.com/user-attachments/assets/2ab04809-7599-45ab-9aaa-ae1fcabdf969 **How to test** To test this PR you can run ``` yarn storybook cloud_security_posture_packages ``` ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Sean Rathier Co-authored-by: Brad White --- .../src/components/node/diamond_node.tsx | 4 +- .../src/components/node/ellipse_node.tsx | 9 +- .../src/components/node/hexagon_node.tsx | 4 +- .../src/components/node/label.stories.tsx | 117 ++++++++++++++++++ .../graph/src/components/node/label.tsx | 104 ++++++++++++++++ .../src/components/node/pentagon_node.tsx | 4 +- .../src/components/node/rectangle_node.tsx | 4 +- .../graph/src/components/node/styles.tsx | 15 +-- 8 files changed, 234 insertions(+), 27 deletions(-) create mode 100644 x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/label.stories.tsx create mode 100644 x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/label.tsx diff --git a/x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/diamond_node.tsx b/x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/diamond_node.tsx index c974c0c9a60e6..ac6f51284a98d 100644 --- a/x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/diamond_node.tsx +++ b/x-pack/solutions/security/packages/kbn-cloud-security-posture/graph/src/components/node/diamond_node.tsx @@ -11,7 +11,6 @@ import { Handle, Position } from '@xyflow/react'; import type { EntityNodeViewModel, NodeProps } from '../types'; import { NodeShapeContainer, - NodeLabel, NodeShapeOnHoverSvg, NodeShapeSvg, NodeIcon, @@ -20,6 +19,7 @@ import { } from './styles'; import { DiamondHoverShape, DiamondShape } from './shapes/diamond_shape'; import { NodeExpandButton } from './node_expand_button'; +import { Label } from './label'; const NODE_WIDTH = 99; const NODE_HEIGHT = 98; @@ -81,7 +81,7 @@ export const DiamondNode: React.FC = memo((props: NodeProps) => { style={HandleStyleOverride} /> - {label ? label : id} +