Skip to content

Commit

Permalink
handle invalid dates in table
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Feb 13, 2020
1 parent 01bfcbb commit 0eebc1d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions x-pack/plugins/endpoint/public/embeddables/resolver/view/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const HorizontalRule = memo(function HorizontalRule() {
export const Panel = memo(function Event({ className }: { className?: string }) {
interface ProcessTableView {
name: string;
timestamp: Date;
timestamp?: Date;
event: ProcessEvent;
}

Expand All @@ -48,9 +48,10 @@ export const Panel = memo(function Event({ className }: { className?: string })
() =>
[...processNodePositions.keys()].map(processEvent => {
const { data_buffer } = processEvent;
const date = new Date(data_buffer.timestamp_utc);
return {
name: data_buffer.process_name,
timestamp: new Date(data_buffer.timestamp_utc),
timestamp: isFinite(date.getTime()) ? date : undefined,
event: processEvent,
};
}),
Expand Down Expand Up @@ -107,10 +108,14 @@ export const Panel = memo(function Event({ className }: { className?: string })
name: i18n.translate('xpack.endpoint.resolver.panel.tabel.row.timestampTitle', {
defaultMessage: 'Timestamp',
}),
dataType: 'date' as const,
dataType: 'date',
sortable: true,
render(eventTimestamp: Date) {
return formatter.format(eventTimestamp);
render(eventTimestamp?: Date) {
return eventTimestamp
? formatter.format(eventTimestamp)
: i18n.translate('xpack.endpoint.resolver.panel.tabel.row.timestampInvalidLabel', {
defaultMessage: 'timestamp invalid',
});
},
},
{
Expand Down

0 comments on commit 0eebc1d

Please sign in to comment.