-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Logs UI] Use short timestamps in the log stream view #47042
Changes from all commits
6bd371c
34b6f3b
99e415a
aca953b
b11526f
d82a147
4dc92ff
54282cf
0347e3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*/ | ||
|
||
import React from 'react'; | ||
import { transparentize } from 'polished'; | ||
|
||
import euiStyled from '../../../../../../common/eui_styled_components'; | ||
import { | ||
|
@@ -20,6 +21,8 @@ import { | |
LogEntryColumnWidths, | ||
} from './log_entry_column'; | ||
import { ASSUMED_SCROLLBAR_WIDTH } from './vertical_scroll_panel'; | ||
import { WithLogPosition } from '../../../containers/logs/with_log_position'; | ||
import { localizedDate } from '../../../utils/formatters/datetime'; | ||
|
||
export const LogColumnHeaders: React.FunctionComponent<{ | ||
columnConfigurations: LogColumnConfiguration[]; | ||
|
@@ -30,13 +33,16 @@ export const LogColumnHeaders: React.FunctionComponent<{ | |
{columnConfigurations.map(columnConfiguration => { | ||
if (isTimestampLogColumnConfiguration(columnConfiguration)) { | ||
return ( | ||
<LogColumnHeader | ||
columnWidth={columnWidths[columnConfiguration.timestampColumn.id]} | ||
data-test-subj="logColumnHeader timestampLogColumnHeader" | ||
key={columnConfiguration.timestampColumn.id} | ||
> | ||
Timestamp | ||
</LogColumnHeader> | ||
<WithLogPosition key={columnConfiguration.timestampColumn.id}> | ||
{({ firstVisiblePosition }) => ( | ||
<LogColumnHeader | ||
columnWidth={columnWidths[columnConfiguration.timestampColumn.id]} | ||
data-test-subj="logColumnHeader timestampLogColumnHeader" | ||
> | ||
{firstVisiblePosition ? localizedDate(firstVisiblePosition.time) : 'Timestamp'} | ||
</LogColumnHeader> | ||
)} | ||
</WithLogPosition> | ||
); | ||
} else if (isMessageLogColumnConfiguration(columnConfiguration)) { | ||
return ( | ||
|
@@ -83,13 +89,16 @@ const LogColumnHeadersWrapper = euiStyled.div.attrs({ | |
justify-content: flex-start; | ||
overflow: hidden; | ||
padding-right: ${ASSUMED_SCROLLBAR_WIDTH}px; | ||
border-bottom: ${props => props.theme.eui.euiBorderThin}; | ||
box-shadow: 0 2px 2px -1px ${props => transparentize(0.3, props.theme.eui.euiColorLightShade)}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure that can be done with the CSS-in-JS library we use. I'll give it a shot |
||
position: relative; | ||
z-index: 1; | ||
`; | ||
|
||
const LogColumnHeaderWrapper = LogEntryColumn.extend.attrs({ | ||
role: 'columnheader', | ||
})` | ||
align-items: center; | ||
border-bottom: ${props => props.theme.eui.euiBorderThick}; | ||
display: flex; | ||
flex-direction: row; | ||
height: 32px; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiTitle } from '@elastic/eui'; | ||
import { localizedDate } from '../../../utils/formatters/datetime'; | ||
|
||
interface LogDateRowProps { | ||
timestamp: number; | ||
} | ||
|
||
/** | ||
* Show a row with the date in the log stream | ||
*/ | ||
export const LogDateRow: React.FC<LogDateRowProps> = ({ timestamp }) => { | ||
const formattedDate = localizedDate(timestamp); | ||
|
||
return ( | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="xxs"> | ||
<h2 style={{ paddingLeft: 8 }}>{formattedDate}</h2> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiHorizontalRule /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export function localizedDate(dateTime: number | Date, locale: string = i18n.getLocale()) { | ||
const formatter = new Intl.DateTimeFormat(locale, { | ||
year: 'numeric', | ||
month: 'short', | ||
day: 'numeric', | ||
}); | ||
|
||
return formatter.format(dateTime); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like that
localizedDate
is a utility function which can be used directly, by hooks, etc