Skip to content

Commit d547856

Browse files
authored
[Metrics][Discover] Adds dimension type icons to metrics flyout (#235421)
## 🍒 Summary This pull request adds support for different dimension types in the unified metrics grid flyout. It maps various dimension types to their corresponding `EuiToken` icons, providing a more informative and visually consistent user experience. ## 🛠️ Changes - Maps dimension types to EuiToken icons - Displays a token icon for boolean, ip, keyword, and numeric types ## 🎙️ Prompts - "I just merged this PR: #235276 I would like to add support for the different dimension types defined in `src/platform/plugins/shared/metrics_experience/common/fields/constants.ts`. I would like to `EuiToken` to replace type of dimension in the list." - "Here are the tokens and how they should map:" - "`tokenBoolean`: boolean" - "`tokenIP`: ip" - "`tokenKeyword`: keyword" - "`tokenNumber`: long, integer, short, byte, unsigned_long" <img width="2047" height="1003" alt="image" src="https://github.com/user-attachments/assets/1a3af13b-f8bb-44ac-8d90-e260c6bb8786" /> 🤖 This pull request was assisted by Gemini CLI
1 parent c4a10ef commit d547856

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/platform/packages/shared/kbn-unified-metrics-grid/src/components/flyout/dimension_badges.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,34 @@ export const DimensionBadges = ({
4141
const isAttributes = dimension.name.startsWith('attributes.');
4242
const isTopLevel = dimension.name.startsWith(topLevelNamespace);
4343
const badgeColor = isAttributes || isTopLevel ? 'default' : 'hollow';
44-
const isKeyword = dimension.type === 'keyword';
44+
const iconMap = new Map<string, string>([
45+
['boolean', 'tokenBoolean'],
46+
['ip', 'tokenIP'],
47+
['keyword', 'tokenKeyword'],
48+
['long', 'tokenNumber'],
49+
['integer', 'tokenNumber'],
50+
['short', 'tokenNumber'],
51+
['byte', 'tokenNumber'],
52+
['unsigned_long', 'tokenNumber'],
53+
]);
54+
55+
const hasIcon = iconMap.has(dimension.type);
4556

4657
const badgeContent = (
4758
<EuiBadge
4859
key={dimension.name}
4960
color={badgeColor}
5061
style={{ marginRight: euiTheme.size.xs, marginBottom: euiTheme.size.xxs }}
5162
>
52-
{isKeyword && (
63+
{hasIcon && (
5364
<EuiToken
54-
iconType="tokenKeyword"
65+
iconType={iconMap.get(dimension.type)!}
5566
size="xs"
5667
style={{ marginRight: euiTheme.size.xs }}
5768
/>
5869
)}
5970
{dimension.name}
60-
{!isKeyword && ` (${dimension.type})`}
71+
{!hasIcon && ` (${dimension.type})`}
6172
</EuiBadge>
6273
);
6374

0 commit comments

Comments
 (0)