Skip to content

Commit

Permalink
Show column id when column dislpay name is not available in flyout ov…
Browse files Browse the repository at this point in the history
…erview
  • Loading branch information
umbopepato committed Jan 29, 2025
1 parent 234111a commit 4df554f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const DefaultAlertsFlyoutBody = <AC extends AdditionalContext>(
const value = alert[column.id]?.[0];

return {
title: column.displayAsText as string,
title: (column.displayAsText as string) ?? column.id,
description:
value != null ? (
<DefaultCellValue columnId={column.id} alert={props.alert} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ALERT_RULE_PRODUCER,
} from '@kbn/rule-data-utils';
import { EuiBadge, EuiLink } from '@elastic/eui';
import { JsonValue } from '@kbn/utility-types';
import { AlertsTableSupportedConsumers, GetAlertsTableProp } from '../types';
import { alertProducersData, observabilityFeatureIds } from '../constants';
import { useFieldFormatter } from '../hooks/use_field_formatter';
Expand All @@ -33,8 +34,8 @@ export const DefaultCellValue = ({
services: { fieldFormats, http },
} = useAlertsTableContext();
const formatField = useFieldFormatter(fieldFormats);
const rawValue = alert[columnId]?.[0];
const value = getRenderValue(rawValue);
const rawValue = alert[columnId];
const value = extractFieldValue(rawValue);

switch (columnId) {
case TIMESTAMP:
Expand Down Expand Up @@ -88,8 +89,11 @@ export const DefaultCellValue = ({
}
};

const getRenderValue = (mappedNonEcsValue: any) => {
const value = Array.isArray(mappedNonEcsValue) ? mappedNonEcsValue.join() : mappedNonEcsValue;
/**
* Extracts the value from the raw json ES field
*/
const extractFieldValue = (rawValue: string | JsonValue[]) => {
const value = Array.isArray(rawValue) ? rawValue.join() : rawValue;

if (!isEmpty(value)) {
if (typeof value === 'object') {
Expand Down

0 comments on commit 4df554f

Please sign in to comment.