[Security Solution][Endpoint] Actions log entries display relative time only up to 1 hr from now (#102162)
* show relative time only upto an hr from now
fixes elastic/security-team/issues/1313
* Update formatted_date_time.tsx
undo changes done in e38e202e81
This commit is contained in:
parent
7390d6a45c
commit
bcb941acea
2 changed files with 5 additions and 10 deletions
|
@ -8,14 +8,10 @@
|
|||
import React from 'react';
|
||||
import { FormattedDate, FormattedTime, FormattedRelative } from '@kbn/i18n/react';
|
||||
|
||||
export const FormattedDateAndTime: React.FC<{ date: Date; showRelativeTime?: boolean }> = ({
|
||||
date,
|
||||
showRelativeTime = false,
|
||||
}) => {
|
||||
export const FormattedDateAndTime: React.FC<{ date: Date }> = ({ date }) => {
|
||||
// If date is greater than or equal to 1h (ago), then show it as a date
|
||||
// and if showRelativeTime is false
|
||||
// else, show it as relative to "now"
|
||||
return Date.now() - date.getTime() >= 3.6e6 && !showRelativeTime ? (
|
||||
return Date.now() - date.getTime() >= 3.6e6 ? (
|
||||
<>
|
||||
<FormattedDate value={date} year="numeric" month="short" day="2-digit" />
|
||||
{' @'}
|
||||
|
|
|
@ -10,7 +10,7 @@ import styled from 'styled-components';
|
|||
|
||||
import { EuiComment, EuiText, EuiAvatarProps, EuiCommentProps, IconType } from '@elastic/eui';
|
||||
import { Immutable, ActivityLogEntry } from '../../../../../../../common/endpoint/types';
|
||||
import { FormattedDateAndTime } from '../../../../../../common/components/endpoint/formatted_date_time';
|
||||
import { FormattedRelativePreferenceDate } from '../../../../../../common/components/formatted_date';
|
||||
import { LogEntryTimelineIcon } from './log_entry_timeline_icon';
|
||||
|
||||
import * as i18 from '../../translations';
|
||||
|
@ -144,9 +144,8 @@ export const LogEntry = memo(({ logEntry }: { logEntry: Immutable<ActivityLogEnt
|
|||
<StyledEuiComment
|
||||
type={(commentType ?? 'regular') as EuiCommentProps['type']}
|
||||
username={username}
|
||||
timestamp={FormattedDateAndTime({
|
||||
date: new Date(logEntry.item.data['@timestamp']),
|
||||
showRelativeTime: true,
|
||||
timestamp={FormattedRelativePreferenceDate({
|
||||
value: logEntry.item.data['@timestamp'],
|
||||
})}
|
||||
event={<b>{displayResponseEvent ? responseEventTitle : actionEventTitle}</b>}
|
||||
timelineIcon={
|
||||
|
|
Loading…
Reference in a new issue