mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Co-authored-by: Kevin Qualters <56408403+kqualters-elastic@users.noreply.github.com>
This commit is contained in:
parent
1511c023ae
commit
31cd5f1d8d
2 changed files with 11 additions and 9 deletions
|
@ -60,14 +60,15 @@ const cellActionLink = [
|
|||
header?: ColumnHeaderOptions;
|
||||
timelineId: string;
|
||||
pageSize: number;
|
||||
}) =>
|
||||
getLink(header?.id, header?.type, header?.linkField)
|
||||
}) => {
|
||||
return getLink(header?.id, header?.type, header?.linkField)
|
||||
? ({ rowIndex, columnId, Component, closePopover }: EuiDataGridColumnCellActionProps) => {
|
||||
const pageRowIndex = getPageRowIndex(rowIndex, pageSize);
|
||||
const ecs = pageRowIndex < ecsData.length ? ecsData[pageRowIndex] : null;
|
||||
const linkValues = header && getOr([], header.linkField ?? '', ecs);
|
||||
const link = getLink(columnId, header?.type, header?.linkField);
|
||||
const linkField = header?.linkField ? header?.linkField : link?.linkField;
|
||||
const linkValues = header && getOr([], linkField ?? '', ecs);
|
||||
const eventId = header && get('_id' ?? '', ecs);
|
||||
|
||||
if (pageRowIndex >= data.length) {
|
||||
// data grid expects each cell action always return an element, it crashes if returns null
|
||||
return <></>;
|
||||
|
@ -78,9 +79,7 @@ const cellActionLink = [
|
|||
fieldName: columnId,
|
||||
});
|
||||
|
||||
const link = getLink(columnId, header?.type, header?.linkField);
|
||||
const value = parseValue(head(values));
|
||||
|
||||
return link && eventId && values && !isEmpty(value) ? (
|
||||
<FormattedFieldValue
|
||||
Component={Component}
|
||||
|
@ -102,7 +101,8 @@ const cellActionLink = [
|
|||
<></>
|
||||
);
|
||||
}
|
||||
: EmptyComponent,
|
||||
: EmptyComponent;
|
||||
},
|
||||
];
|
||||
|
||||
export const cellActions: TGridCellAction[] = [
|
||||
|
|
|
@ -35,6 +35,7 @@ export const COLUMNS_WITH_LINKS = [
|
|||
{
|
||||
columnId: SIGNAL_RULE_NAME_FIELD_NAME,
|
||||
label: i18n.VIEW_RULE_DETAILS,
|
||||
linkField: 'signal.rule.id',
|
||||
},
|
||||
...PORT_NAMES.map((p) => ({
|
||||
columnId: p,
|
||||
|
@ -59,7 +60,8 @@ export const COLUMNS_WITH_LINKS = [
|
|||
];
|
||||
|
||||
export const getLink = (cId?: string, fieldType?: string, linkField?: string) =>
|
||||
cId &&
|
||||
COLUMNS_WITH_LINKS.find(
|
||||
(c) => c.columnId === cId || (c.fieldType && fieldType === c.fieldType && linkField != null)
|
||||
(c) =>
|
||||
(cId && c.columnId === cId) ||
|
||||
(c.fieldType && fieldType === c.fieldType && (linkField != null || c.linkField !== undefined))
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue