Skip to content

Commit 4765966

Browse files
kibanamachineawahab07elasticmachine
authored
[9.2] [One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557) (#241926)
# Backport This will backport the following commits from `main` to `9.2`: - [[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557)](#241557) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Abdul Wahab Zahid","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-11-05T09:29:30Z","message":"[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557)\n\n- Make the truncation configurable so that resource badges are rendered\nwithout truncation when rendered as individual columns (for Summary\ncolumn, they'll truncate).\n- Show the hover tooltip with full titles, always.\n\nBefore\n\n\nhttps://github.com/user-attachments/assets/1d296649-9967-4be8-b2e3-fcc738e46244\n\nAfter\n\n\nhttps://github.com/user-attachments/assets/ebca3b16-9cc1-4f71-b9a2-b02902fd1ac9\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"4d969dfc5a7ceb3830bd02e126a27e9dfbbdb3a7","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-logs","backport:version","v9.3.0","v8.18.9","v9.0.9","v9.1.7","v9.2.1"],"title":"[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column","number":241557,"url":"https://github.com/elastic/kibana/pull/241557","mergeCommit":{"message":"[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557)\n\n- Make the truncation configurable so that resource badges are rendered\nwithout truncation when rendered as individual columns (for Summary\ncolumn, they'll truncate).\n- Show the hover tooltip with full titles, always.\n\nBefore\n\n\nhttps://github.com/user-attachments/assets/1d296649-9967-4be8-b2e3-fcc738e46244\n\nAfter\n\n\nhttps://github.com/user-attachments/assets/ebca3b16-9cc1-4f71-b9a2-b02902fd1ac9\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"4d969dfc5a7ceb3830bd02e126a27e9dfbbdb3a7"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","9.0","9.1","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/241557","number":241557,"mergeCommit":{"message":"[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557)\n\n- Make the truncation configurable so that resource badges are rendered\nwithout truncation when rendered as individual columns (for Summary\ncolumn, they'll truncate).\n- Show the hover tooltip with full titles, always.\n\nBefore\n\n\nhttps://github.com/user-attachments/assets/1d296649-9967-4be8-b2e3-fcc738e46244\n\nAfter\n\n\nhttps://github.com/user-attachments/assets/ebca3b16-9cc1-4f71-b9a2-b02902fd1ac9\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"4d969dfc5a7ceb3830bd02e126a27e9dfbbdb3a7"}},{"branch":"8.18","label":"v8.18.9","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.9","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Abdul Wahab Zahid <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 43618e9 commit 4765966

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/cell_actions_popover.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
filterOutText,
3939
openCellActionPopoverAriaText,
4040
} from './translations';
41-
import { truncateAndPreserveHighlightTags } from './utils';
41+
import { truncateAndPreserveHighlightTags, extractTextAndMarkTags } from './utils';
4242

4343
interface CellActionsPopoverProps {
4444
onFilter?: DocViewFilterFn;
@@ -178,6 +178,7 @@ export interface FieldBadgeWithActionsProps
178178
> {
179179
icon?: EuiBadgeProps['iconType'];
180180
color?: string;
181+
truncateTitle?: boolean;
181182
}
182183

183184
interface FieldBadgeWithActionsDependencies {
@@ -197,9 +198,13 @@ export function FieldBadgeWithActions({
197198
value,
198199
rawValue,
199200
color = 'hollow',
201+
truncateTitle = false,
200202
}: FieldBadgeWithActionsPropsAndDependencies) {
201203
const MAX_LENGTH = 20;
202204

205+
const displayValue = truncateTitle ? truncateAndPreserveHighlightTags(value, MAX_LENGTH) : value;
206+
const titleText = extractTextAndMarkTags(value).cleanText;
207+
203208
return (
204209
<CellActionsPopover
205210
onFilter={onFilter}
@@ -209,11 +214,17 @@ export function FieldBadgeWithActions({
209214
rawValue={rawValue}
210215
renderValue={renderValue}
211216
renderPopoverTrigger={({ popoverTriggerProps }) => (
212-
<EuiBadge {...popoverTriggerProps} color={color} iconType={icon} iconSide="left">
217+
<EuiBadge
218+
{...popoverTriggerProps}
219+
color={color}
220+
iconType={icon}
221+
iconSide="left"
222+
title={titleText}
223+
>
213224
<span
214225
// eslint-disable-next-line react/no-danger
215226
dangerouslySetInnerHTML={{
216-
__html: truncateAndPreserveHighlightTags(value, MAX_LENGTH),
227+
__html: displayValue,
217228
}}
218229
/>
219230
</EuiBadge>

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/summary_column/resource.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const Resource = ({ fields, limited = false, onFilter, ...props }: Resour
3838
value={value}
3939
icon={Icon}
4040
onFilter={onFilter}
41+
truncateTitle={true}
4142
/>
4243
))}
4344
{extraFieldsCount > 0 && (

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/utils/truncate_preserve_highlight_tags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
function extractTextAndMarkTags(html: string) {
10+
export function extractTextAndMarkTags(html: string) {
1111
const markTags: string[] = [];
1212
const cleanText = html.replace(/<\/?mark[^>]*>/g, (match) => {
1313
markTags.push(match);

0 commit comments

Comments
 (0)