@@ -3,7 +3,7 @@ import React from 'react';
33import type { Value } from '@gravity-ui/date-components' ;
44import { RelativeDatePicker } from '@gravity-ui/date-components' ;
55import { dateTimeParse } from '@gravity-ui/date-utils' ;
6- import { ArrowDownToLine , ArrowUpToLine } from '@gravity-ui/icons' ;
6+ import { ArrowDownToLine , ArrowUpToLine , CircleChevronDownFill } from '@gravity-ui/icons' ;
77import type { TableColumnSetupItem } from '@gravity-ui/uikit' ;
88import {
99 ActionTooltip ,
@@ -21,6 +21,7 @@ import {EntitiesCount} from '../../../../../components/EntitiesCount';
2121import type { PreparedPartitionData } from '../../../../../store/reducers/partitions/types' ;
2222import { formatNumber } from '../../../../../utils/dataFormatters/dataFormatters' ;
2323import { prepareErrorMessage } from '../../../../../utils/prepareErrorMessage' ;
24+ import { safeParseNumber } from '../../../../../utils/utils' ;
2425import i18n from '../i18n' ;
2526import { useTopicDataQueryParams } from '../useTopicDataQueryParams' ;
2627import { b } from '../utils/constants' ;
@@ -35,23 +36,21 @@ interface TopicDataControlsProps {
3536 partitionsLoading : boolean ;
3637 partitionsError : unknown ;
3738
38- initialOffset ?: number ;
39+ startOffset ?: number ;
3940 endOffset ?: number ;
40- scrollToStartOffset : VoidFunction ;
41- scrollToEndOffset : VoidFunction ;
41+ scrollToOffset : ( start : number , reset ?: boolean ) => void ;
4242}
4343
4444export function TopicDataControls ( {
4545 columnsToSelect,
4646 handleSelectedColumnsUpdate,
4747
48- initialOffset ,
48+ startOffset ,
4949 endOffset,
5050 partitions,
5151 partitionsLoading,
5252 partitionsError,
53- scrollToStartOffset,
54- scrollToEndOffset,
53+ scrollToOffset,
5554} : TopicDataControlsProps ) {
5655 const {
5756 selectedPartition,
@@ -78,6 +77,18 @@ export function TopicDataControls({
7877 ] ,
7978 ) ;
8079
80+ const scrollToStartOffset = React . useCallback ( ( ) => {
81+ if ( startOffset ) {
82+ scrollToOffset ( startOffset , true ) ;
83+ }
84+ } , [ startOffset , scrollToOffset ] ) ;
85+
86+ const scrollToEndOffset = React . useCallback ( ( ) => {
87+ if ( endOffset ) {
88+ scrollToOffset ( endOffset , true ) ;
89+ }
90+ } , [ endOffset , scrollToOffset ] ) ;
91+
8192 return (
8293 < React . Fragment >
8394 < Select
@@ -93,15 +104,15 @@ export function TopicDataControls({
93104 error = { Boolean ( partitionsError ) }
94105 loading = { partitionsLoading }
95106 />
96- < TopicDataStartControls />
107+ < TopicDataStartControls scrollToOffset = { scrollToOffset } />
97108 < TableColumnSetup
98109 popupWidth = { 242 }
99110 items = { columnsToSelect }
100111 showStatus
101112 onUpdate = { handleSelectedColumnsUpdate }
102113 sortable = { false }
103114 />
104- { ! isNil ( initialOffset ) && ! isNil ( endOffset ) && (
115+ { ! isNil ( startOffset ) && ! isNil ( endOffset ) && (
105116 < Flex gap = { 0.5 } >
106117 < ActionTooltip title = { i18n ( 'action_scroll-up' ) } >
107118 < Button
@@ -115,7 +126,7 @@ export function TopicDataControls({
115126 </ ActionTooltip >
116127 < EntitiesCount
117128 label = { i18n ( 'label_offset' ) }
118- current = { `${ formatNumber ( initialOffset ) } —${ formatNumber ( endOffset - 1 ) } ` }
129+ current = { `${ formatNumber ( startOffset ) } —${ formatNumber ( endOffset - 1 ) } ` }
119130 className = { b ( 'offsets-count' ) }
120131 />
121132 < ActionTooltip title = { i18n ( 'action_scroll-down' ) } >
@@ -134,7 +145,11 @@ export function TopicDataControls({
134145 ) ;
135146}
136147
137- function TopicDataStartControls ( ) {
148+ interface TopicDataStartControlsProps {
149+ scrollToOffset : ( start : number , reset ?: boolean ) => void ;
150+ }
151+
152+ function TopicDataStartControls ( { scrollToOffset} : TopicDataStartControlsProps ) {
138153 const {
139154 selectedOffset,
140155 startTimestamp,
@@ -199,12 +214,29 @@ function TopicDataStartControls() {
199214 placeholder = { i18n ( 'label_offset' ) }
200215 type = "number"
201216 debounce = { 600 }
217+ endContent = {
218+ < ActionTooltip title = { i18n ( 'action_scroll-selected' ) } >
219+ < Button
220+ disabled = { isNil ( selectedOffset ) || selectedOffset === '' }
221+ view = "flat-action"
222+ size = "xs"
223+ onClick = { ( ) => {
224+ if ( selectedOffset ) {
225+ scrollToOffset ( safeParseNumber ( selectedOffset ) ) ;
226+ }
227+ } }
228+ >
229+ < Icon size = { 14 } data = { CircleChevronDownFill } />
230+ </ Button >
231+ </ ActionTooltip >
232+ }
202233 autoFocus
203234 />
204235 ) }
205236 { topicDataFilter === 'TIMESTAMP' && (
206237 < RelativeDatePicker
207238 format = "YYYY-MM-DD HH:mm:ss"
239+ placeholder = "YYYY-MM-DD HH:mm:ss"
208240 hasClear
209241 isDateUnavailable = { ( value ) => value . isAfter ( dateTimeParse ( ) ) }
210242 label = { i18n ( 'label_from' ) }
0 commit comments