Skip to content

Commit bd1f3b3

Browse files
afgomezAlejandro Fernández Gómez
authored andcommitted
Adapt Log entry actions menu to the new API response
1 parent 77f0fda commit bd1f3b3

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('LogEntryActionsMenu component', () => {
2929
<ProviderWrapper>
3030
<LogEntryActionsMenu
3131
logItem={{
32-
fields: [{ field: 'host.ip', value: 'HOST_IP' }],
32+
fields: [{ field: 'host.ip', value: ['HOST_IP'] }],
3333
id: 'ITEM_ID',
3434
index: 'INDEX',
3535
key: {
@@ -59,7 +59,7 @@ describe('LogEntryActionsMenu component', () => {
5959
<ProviderWrapper>
6060
<LogEntryActionsMenu
6161
logItem={{
62-
fields: [{ field: 'container.id', value: 'CONTAINER_ID' }],
62+
fields: [{ field: 'container.id', value: ['CONTAINER_ID'] }],
6363
id: 'ITEM_ID',
6464
index: 'INDEX',
6565
key: {
@@ -89,7 +89,7 @@ describe('LogEntryActionsMenu component', () => {
8989
<ProviderWrapper>
9090
<LogEntryActionsMenu
9191
logItem={{
92-
fields: [{ field: 'kubernetes.pod.uid', value: 'POD_UID' }],
92+
fields: [{ field: 'kubernetes.pod.uid', value: ['POD_UID'] }],
9393
id: 'ITEM_ID',
9494
index: 'INDEX',
9595
key: {
@@ -120,9 +120,9 @@ describe('LogEntryActionsMenu component', () => {
120120
<LogEntryActionsMenu
121121
logItem={{
122122
fields: [
123-
{ field: 'container.id', value: 'CONTAINER_ID' },
124-
{ field: 'host.ip', value: 'HOST_IP' },
125-
{ field: 'kubernetes.pod.uid', value: 'POD_UID' },
123+
{ field: 'container.id', value: ['CONTAINER_ID'] },
124+
{ field: 'host.ip', value: ['HOST_IP'] },
125+
{ field: 'kubernetes.pod.uid', value: ['POD_UID'] },
126126
],
127127
id: 'ITEM_ID',
128128
index: 'INDEX',
@@ -189,7 +189,7 @@ describe('LogEntryActionsMenu component', () => {
189189
<ProviderWrapper>
190190
<LogEntryActionsMenu
191191
logItem={{
192-
fields: [{ field: 'trace.id', value: '1234567' }],
192+
fields: [{ field: 'trace.id', value: ['1234567'] }],
193193
id: 'ITEM_ID',
194194
index: 'INDEX',
195195
key: {
@@ -221,8 +221,8 @@ describe('LogEntryActionsMenu component', () => {
221221
<LogEntryActionsMenu
222222
logItem={{
223223
fields: [
224-
{ field: 'trace.id', value: '1234567' },
225-
{ field: '@timestamp', value: timestamp },
224+
{ field: 'trace.id', value: ['1234567'] },
225+
{ field: '@timestamp', value: [timestamp] },
226226
],
227227
id: 'ITEM_ID',
228228
index: 'INDEX',

x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import * as rt from 'io-ts';
87
import { EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
98
import { FormattedMessage } from '@kbn/i18n/react';
109
import React, { useMemo } from 'react';
1110
import { useVisibilityState } from '../../../utils/use_visibility_state';
1211
import { getTraceUrl } from '../../../../../apm/public';
1312
import { LogEntriesItem } from '../../../../common/http_api';
1413
import { useLinkProps, LinkDescriptor } from '../../../hooks/use_link_props';
15-
import { decodeOrThrow } from '../../../../common/runtime_types';
1614

1715
const UPTIME_FIELDS = ['container.id', 'host.ip', 'kubernetes.pod.uid'];
1816

@@ -97,12 +95,7 @@ const getUptimeLink = (logItem: LogEntriesItem): LinkDescriptor | undefined => {
9795
.filter(({ field, value }) => value != null && UPTIME_FIELDS.includes(field))
9896
.reduce<string[]>((acc, fieldItem) => {
9997
const { field, value } = fieldItem;
100-
try {
101-
const parsedValue = decodeOrThrow(rt.array(rt.string))(JSON.parse(value));
102-
return acc.concat(parsedValue.map((val) => `${field}:${val}`));
103-
} catch (e) {
104-
return acc.concat([`${field}:${value}`]);
105-
}
98+
return acc.concat(value.map((val) => `${field}:${val}`));
10699
}, []);
107100

108101
if (searchExpressions.length === 0) {
@@ -119,15 +112,15 @@ const getUptimeLink = (logItem: LogEntriesItem): LinkDescriptor | undefined => {
119112

120113
const getAPMLink = (logItem: LogEntriesItem): LinkDescriptor | undefined => {
121114
const traceIdEntry = logItem.fields.find(
122-
({ field, value }) => value != null && field === 'trace.id'
115+
({ field, value }) => value[0] != null && field === 'trace.id'
123116
);
124117

125118
if (!traceIdEntry) {
126119
return undefined;
127120
}
128121

129122
const timestampField = logItem.fields.find(({ field }) => field === '@timestamp');
130-
const timestamp = timestampField ? timestampField.value : null;
123+
const timestamp = timestampField ? timestampField.value[0] : null;
131124
const { rangeFrom, rangeTo } = timestamp
132125
? (() => {
133126
const from = new Date(timestamp);
@@ -142,6 +135,6 @@ const getAPMLink = (logItem: LogEntriesItem): LinkDescriptor | undefined => {
142135

143136
return {
144137
app: 'apm',
145-
hash: getTraceUrl({ traceId: traceIdEntry.value, rangeFrom, rangeTo }),
138+
hash: getTraceUrl({ traceId: traceIdEntry.value[0], rangeFrom, rangeTo }),
146139
};
147140
};

0 commit comments

Comments
 (0)