Skip to content

Commit 67df570

Browse files
Merge pull request #3761 from RedisInsight/fe/bugfix/RI-5934-bugfixes-for-formating-timestamps
Fe/bugfix/ri 5934 bugfixes for formating timestamps
2 parents 9e570ba + 304c394 commit 67df570

File tree

14 files changed

+447
-281
lines changed

14 files changed

+447
-281
lines changed

redisinsight/ui/src/components/formated-date/FormatedDate.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const FormatedDate = ({ date }: Props) => {
1515
const dateFormat = config?.dateFormat || DATETIME_FORMATTER_DEFAULT
1616
const timezone = config?.timezone || TimezoneOption.Local
1717

18+
if (!date) return null
19+
1820
const formatedDate = formatTimestamp(date, dateFormat, timezone)
1921

2022
return (

redisinsight/ui/src/components/range-filter/RangeFilter.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { useCallback, useState, useEffect, useRef } from 'react'
22
import cx from 'classnames'
33

4-
import { getFormatTime } from 'uiSrc/utils/streamUtils'
5-
4+
import { FormatedDate } from '../formated-date'
65
import styles from './styles.module.scss'
76

87
const buttonString = 'Reset Filter'
@@ -138,8 +137,8 @@ const RangeFilter = (props: Props) => {
138137
return (
139138
<div data-testid="mock-fill-range" className={styles.rangeWrapper}>
140139
<div className={cx(styles.sliderRange, styles.mockRange)}>
141-
<div className={styles.sliderLeftValue} data-testid="range-left-timestamp">{getFormatTime(start?.toString())}</div>
142-
<div className={styles.sliderRightValue} data-testid="range-right-timestamp">{getFormatTime(end?.toString())}</div>
140+
<div className={styles.sliderLeftValue} data-testid="range-left-timestamp"><FormatedDate date={start?.toString()} /></div>
141+
<div className={styles.sliderRightValue} data-testid="range-right-timestamp"><FormatedDate date={end?.toString()} /></div>
143142
</div>
144143
</div>
145144
)
@@ -192,7 +191,7 @@ const RangeFilter = (props: Props) => {
192191
})
193192
}
194193
>
195-
{getFormatTime(startVal?.toString())}
194+
<FormatedDate date={startVal?.toString()} />
196195
</div>
197196
<div className={
198197
cx(styles.sliderRightValue,
@@ -202,7 +201,7 @@ const RangeFilter = (props: Props) => {
202201
})
203202
}
204203
>
205-
{getFormatTime(endVal?.toString())}
204+
<FormatedDate date={endVal?.toString()} />
206205
</div>
207206
</div>
208207
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/groups-view/GroupsViewWrapper.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import {
2121
import { ITableColumn } from 'uiSrc/components/virtual-table/interfaces'
2222
import PopoverDelete from 'uiSrc/pages/browser/components/popover-delete/PopoverDelete'
2323
import { bufferToString, consumerGroupIdRegex, formatLongName, isEqualBuffers, validateConsumerGroupId } from 'uiSrc/utils'
24-
import { getFormatTime } from 'uiSrc/utils/streamUtils'
2524
import { TableCellTextAlignment } from 'uiSrc/constants'
2625
import { StreamViewType } from 'uiSrc/slices/interfaces/stream'
2726
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2827
import { RedisResponseBuffer } from 'uiSrc/slices/interfaces'
2928
import EditablePopover from 'uiSrc/pages/browser/modules/key-details/shared/editable-popover'
3029

30+
import { FormatedDate } from 'uiSrc/components'
3131
import { ConsumerDto, ConsumerGroupDto, UpdateConsumerGroupDto } from 'apiSrc/modules/browser/stream/dto'
3232

3333
import GroupsView from './GroupsView'
@@ -240,7 +240,14 @@ const GroupsViewWrapper = (props: Props) => {
240240
const smallestTimestamp = smallestPendingId?.viewValue?.split('-')?.[0]
241241
const greatestTimestamp = greatestPendingId?.viewValue?.split('-')?.[0]
242242

243-
const tooltipContent = `${getFormatTime(smallestTimestamp)}${getFormatTime(greatestTimestamp)}`
243+
const tooltipContent = (
244+
<>
245+
<FormatedDate date={smallestTimestamp} />
246+
<span>&nbsp;–&nbsp;</span>
247+
<FormatedDate date={greatestTimestamp} />
248+
</>
249+
)
250+
244251
return (
245252
<EuiText size="s" style={{ maxWidth: '100%' }}>
246253
<div style={{ display: 'flex' }} className="truncateText" data-testid={`group-pending-${viewName}`}>
@@ -282,10 +289,10 @@ const GroupsViewWrapper = (props: Props) => {
282289
<EuiText color="subdued" size="s" style={{ maxWidth: '100%' }}>
283290
<div
284291
className="truncateText streamItem"
285-
style={{ display: 'flex' }}
292+
style={{ display: 'flex', maxWidth: '190px' }}
286293
data-testid={`stream-group-date-${id}`}
287294
>
288-
{getFormatTime(timestamp)}
295+
<FormatedDate date={timestamp} />
289296
</div>
290297
</EuiText>
291298
<EuiText size="s" style={{ maxWidth: '100%' }}>

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/stream-data-view/StreamDataViewWrapper.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ import {
99
createDeleteFieldHeader,
1010
createDeleteFieldMessage,
1111
createTooltipContent,
12-
formatTimestamp,
1312
formattingBuffer,
1413
stringToBuffer
1514
} from 'uiSrc/utils'
1615
import { streamDataSelector, deleteStreamEntry } from 'uiSrc/slices/browser/stream'
1716
import { ITableColumn } from 'uiSrc/components/virtual-table/interfaces'
1817
import PopoverDelete from 'uiSrc/pages/browser/components/popover-delete/PopoverDelete'
19-
import { DATETIME_FORMATTER_DEFAULT, KeyTypes, TableCellTextAlignment, TEXT_FAILED_CONVENT_FORMATTER, TimezoneOption } from 'uiSrc/constants'
18+
import { KeyTypes, TableCellTextAlignment, TEXT_FAILED_CONVENT_FORMATTER } from 'uiSrc/constants'
2019
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2120
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2221
import { keysSelector, selectedKeySelector, updateSelectedKeyRefreshTime } from 'uiSrc/slices/browser/keys'
2322
import { decompressingBuffer } from 'uiSrc/utils/decompressors'
2423

25-
import { userSettingsConfigSelector } from 'uiSrc/slices/user/user-settings'
2624
import { FormattedValue } from 'uiSrc/pages/browser/modules/key-details/shared'
25+
import { FormatedDate } from 'uiSrc/components'
2726
import { StreamEntryDto } from 'apiSrc/modules/browser/stream/dto'
2827
import StreamDataView from './StreamDataView'
2928
import styles from './StreamDataView/styles.module.scss'
@@ -48,7 +47,6 @@ const StreamDataViewWrapper = (props: Props) => {
4847
const { id: instanceId, compressor = null } = useSelector(connectedInstanceSelector)
4948
const { viewType: browserViewType } = useSelector(keysSelector)
5049
const { viewFormat: viewFormatProp } = useSelector(selectedKeySelector)
51-
const config = useSelector(userSettingsConfigSelector)
5250

5351
const dispatch = useDispatch()
5452

@@ -249,18 +247,15 @@ const StreamDataViewWrapper = (props: Props) => {
249247
render: function Id({ id }: StreamEntryDto) {
250248
const idStr = bufferToString(id, viewFormat)
251249
const timestamp = idStr.split('-')?.[0]
252-
const formattedTimestamp = timestamp.length > MAX_FORMAT_LENGTH_STREAM_TIMESTAMP ? '-' : formatTimestamp(
253-
timestamp,
254-
config?.dateFormat || DATETIME_FORMATTER_DEFAULT,
255-
config?.timezone || TimezoneOption.Local
256-
)
257250

258251
return (
259252
<div>
260253
{id.length < MAX_VISIBLE_LENGTH_STREAM_TIMESTAMP && (
261254
<EuiText color="subdued" size="s" style={{ maxWidth: '100%' }}>
262255
<div className="streamItem truncateText" style={{ display: 'flex' }} data-testid={`stream-entry-${id}-date`}>
263-
{formattedTimestamp}
256+
{timestamp.length > MAX_FORMAT_LENGTH_STREAM_TIMESTAMP ? '-' : (
257+
<FormatedDate date={timestamp} />
258+
)}
264259
</div>
265260
</EuiText>
266261
)}

0 commit comments

Comments
 (0)