File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
x-pack/plugins/security_solution/public
common/components/formatted_date
management/pages/endpoint_hosts/view/details Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,24 @@ export const PreferenceFormattedDate = React.memo<{ dateFormat?: string; value:
2222
2323PreferenceFormattedDate . displayName = 'PreferenceFormattedDate' ;
2424
25+ export const PreferenceFormattedDateFromPrimitive = ( {
26+ value,
27+ } : {
28+ value ?: string | number | null ;
29+ } ) => {
30+ if ( value == null ) {
31+ return getOrEmptyTagFromValue ( value ) ;
32+ }
33+ const maybeDate = getMaybeDate ( value ) ;
34+ if ( ! maybeDate . isValid ( ) ) {
35+ return getOrEmptyTagFromValue ( value ) ;
36+ }
37+ const date = maybeDate . toDate ( ) ;
38+ return < PreferenceFormattedDate value = { date } /> ;
39+ } ;
40+
41+ PreferenceFormattedDateFromPrimitive . displayName = 'PreferenceFormattedDateFromPrimitive' ;
42+
2543/**
2644 * This function may be passed to `Array.find()` to locate the `P1DT`
2745 * configuration (sub) setting, a string array that contains two entries
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ import { useNavigateByRouterEventHandler } from '../../../../../common/hooks/end
4242import { getEndpointListPath } from '../../../../common/routing' ;
4343import { SecurityPageName } from '../../../../../app/types' ;
4444import { useFormatUrl } from '../../../../../common/components/link_to' ;
45- import { PreferenceFormattedDate } from '../../../../../common/components/formatted_date' ;
45+ import { PreferenceFormattedDateFromPrimitive } from '../../../../../common/components/formatted_date' ;
4646
4747export const EndpointDetailsFlyout = memo ( ( ) => {
4848 const history = useHistory ( ) ;
@@ -170,7 +170,7 @@ const PolicyResponseFlyoutPanel = memo<{
170170 </ EuiText >
171171 < EuiSpacer size = "s" />
172172 < EuiText size = "xs" color = "subdued" data-test-subj = "endpointDetailsPolicyResponseTimestamp" >
173- < PreferenceFormattedDate value = { responseTimestamp } />
173+ < PreferenceFormattedDateFromPrimitive value = { responseTimestamp } />
174174 </ EuiText >
175175 < EuiSpacer size = "s" />
176176 { error && (
You can’t perform that action at this time.
0 commit comments