Skip to content

Commit c16b62e

Browse files
committed
fixes
1 parent b59ce84 commit c16b62e

File tree

6 files changed

+50
-52
lines changed

6 files changed

+50
-52
lines changed

src/containers/Tenant/Diagnostics/TopicData/TopicData.tsx

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
5858
const [emptyData, setEmptyData] = React.useState(false);
5959

6060
const [baseOffset, setBaseOffset] = React.useState<number>();
61+
const [truncated, setTruncated] = React.useState(false);
6162
const [baseEndOffset, setBaseEndOffset] = React.useState<number>();
6263

6364
const startRef = React.useRef<number>();
@@ -107,17 +108,6 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
107108
{pollingInterval: autoRefreshInterval},
108109
);
109110

110-
const calculateBoundOffsets = React.useCallback(
111-
({startOffset, endOffset}: {startOffset: number; endOffset: number}) => {
112-
const normolizedNewStartOffset = Math.max(
113-
endOffset - PAGINATED_TABLE_LIMIT,
114-
safeParseNumber(startOffset),
115-
);
116-
return {newStartOffset: normolizedNewStartOffset, newEndOffset: endOffset};
117-
},
118-
[],
119-
);
120-
121111
React.useEffect(() => {
122112
const selectedPartitionData = partitions?.find(
123113
({partitionId}) => partitionId === selectedPartition,
@@ -129,23 +119,17 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
129119
setBaseEndOffset(endOffset);
130120
}
131121
if (!baseOffset) {
132-
const {newStartOffset} = calculateBoundOffsets({
133-
startOffset: safeParseNumber(selectedPartitionData.startOffset),
134-
endOffset: endOffset ?? 0,
135-
});
122+
const partitionStartOffset = safeParseNumber(selectedPartitionData.startOffset);
123+
const newStartOffset = Math.max(
124+
(endOffset ?? 0) - PAGINATED_TABLE_LIMIT,
125+
partitionStartOffset,
126+
);
136127

128+
setTruncated(newStartOffset !== partitionStartOffset);
137129
setBaseOffset(newStartOffset);
138130
}
139131
}
140-
}, [
141-
selectedPartition,
142-
partitions,
143-
baseOffset,
144-
baseEndOffset,
145-
startOffset,
146-
endOffset,
147-
calculateBoundOffsets,
148-
]);
132+
}, [selectedPartition, partitions, baseOffset, baseEndOffset, startOffset, endOffset]);
149133

150134
React.useEffect(() => {
151135
if (partitions && partitions.length && isNil(selectedPartition)) {
@@ -166,18 +150,10 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
166150

167151
const setBoundOffsets = React.useCallback(
168152
({startOffset, endOffset}: {startOffset: number; endOffset: number}) => {
169-
const {newStartOffset, newEndOffset} = calculateBoundOffsets({
170-
startOffset,
171-
endOffset,
172-
});
173-
const normolizedNewStartOffset = Math.max(
174-
newEndOffset - PAGINATED_TABLE_LIMIT,
175-
safeParseNumber(newStartOffset),
176-
);
177-
setStartOffset(normolizedNewStartOffset);
178-
setEndOffset(newEndOffset);
153+
setStartOffset(startOffset);
154+
setEndOffset(endOffset);
179155
},
180-
[calculateBoundOffsets],
156+
[],
181157
);
182158

183159
React.useEffect(() => {
@@ -263,6 +239,7 @@ export function TopicData({parentRef, path, database}: TopicDataProps) {
263239
partitionsError={partitionsError}
264240
startOffset={startOffset}
265241
endOffset={endOffset}
242+
truncatedData={truncated}
266243
scrollToOffset={scrollToOffset}
267244
/>
268245
);

src/containers/Tenant/Diagnostics/TopicData/TopicDataControls/TopicDataControls.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type {TableColumnSetupItem} from '@gravity-ui/uikit';
88
import {
99
ActionTooltip,
1010
Button,
11+
Flex,
12+
HelpMark,
1113
Icon,
1214
RadioButton,
1315
Select,
@@ -37,6 +39,7 @@ interface TopicDataControlsProps {
3739

3840
startOffset?: number;
3941
endOffset?: number;
42+
truncatedData?: boolean;
4043
scrollToOffset: (offset: number) => void;
4144
}
4245

@@ -50,6 +53,7 @@ export function TopicDataControls({
5053
partitionsLoading,
5154
partitionsError,
5255
scrollToOffset,
56+
truncatedData,
5357
}: TopicDataControlsProps) {
5458
const {
5559
selectedPartition,
@@ -94,9 +98,12 @@ export function TopicDataControls({
9498
<TopicDataStartControls scrollToOffset={scrollToOffset} />
9599

96100
{!isNil(startOffset) && !isNil(endOffset) && (
97-
<Text color="secondary" whiteSpace="nowrap">
98-
{formatNumber(startOffset)}{formatNumber(endOffset - 1)}
99-
</Text>
101+
<Flex gap={1}>
102+
<Text color="secondary" whiteSpace="nowrap">
103+
{formatNumber(startOffset)}{formatNumber(endOffset - 1)}
104+
</Text>
105+
{truncatedData && <HelpMark>{i18n('description_last-messages')}</HelpMark>}
106+
</Flex>
100107
)}
101108
<TableColumnSetup
102109
popupWidth={242}

src/containers/Tenant/Diagnostics/TopicData/TopicMessageDetails/components/TopicMessageGeneralInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const dataGroups: {
3232
{name: TOPIC_DATA_COLUMNS_IDS.ORIGINAL_SIZE},
3333
{name: TOPIC_DATA_COLUMNS_IDS.CODEC},
3434
{name: TOPIC_DATA_COLUMNS_IDS.PRODUCERID, copy: (row) => row.ProducerId},
35-
{name: TOPIC_DATA_COLUMNS_IDS.SEQNO},
35+
{name: TOPIC_DATA_COLUMNS_IDS.SEQNO, copy: (row) => row.SeqNo},
3636
],
3737
];
3838

src/containers/Tenant/Diagnostics/TopicData/TopicMessageDetails/components/fields.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
import {isNil} from 'lodash';
2+
13
import type {TopicMessageEnhanced} from '../../../../../../types/api/topic';
4+
import {EMPTY_DATA_PLACEHOLDER} from '../../../../../../utils/constants';
25
import {
36
TopicDataTimestamp,
47
codecColumn,
58
messageColumn,
69
metadataColumn,
710
originalSizeColumn,
8-
seqNoColumn,
911
sizeColumn,
1012
tsDiffColumn,
11-
valueOrPlaceholder,
1213
} from '../../columns/columns';
1314
import {useTopicDataQueryParams} from '../../useTopicDataQueryParams';
1415
import {TOPIC_DATA_COLUMNS_TITLES} from '../../utils/constants';
1516
import {TOPIC_DATA_COLUMNS_IDS} from '../../utils/types';
1617

18+
function valueOrPlaceholder(
19+
value: string | number | undefined,
20+
placeholder = EMPTY_DATA_PLACEHOLDER,
21+
) {
22+
return isNil(value) ? placeholder : value;
23+
}
24+
1725
type TopicMessageDetailsField = {
1826
name: string;
1927
header?: React.ReactNode;
@@ -53,6 +61,13 @@ const producerIdColumn: TopicMessageDetailsField = {
5361
return valueOrPlaceholder(row.ProducerId);
5462
},
5563
};
64+
const seqNoColumn: TopicMessageDetailsField = {
65+
name: TOPIC_DATA_COLUMNS_IDS.SEQNO,
66+
header: TOPIC_DATA_COLUMNS_TITLES[TOPIC_DATA_COLUMNS_IDS.SEQNO],
67+
render: ({row}) => {
68+
return valueOrPlaceholder(row.SeqNo);
69+
},
70+
};
5671

5772
function PartitionId() {
5873
const {selectedPartition} = useTopicDataQueryParams();

src/containers/Tenant/Diagnostics/TopicData/columns/columns.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,13 @@ export const seqNoColumn: Column<TopicMessageEnhanced> = {
200200
name: TOPIC_DATA_COLUMNS_IDS.SEQNO,
201201
header: TOPIC_DATA_COLUMNS_TITLES[TOPIC_DATA_COLUMNS_IDS.SEQNO],
202202
align: DataTable.RIGHT,
203-
render: ({row}) => valueOrPlaceholder(row.SeqNo),
204-
width: 70,
203+
render: ({row}) =>
204+
row.SeqNo ? (
205+
<EntityStatus showStatus={false} name={row.SeqNo} hasClipboardButton />
206+
) : (
207+
EMPTY_DATA_PLACEHOLDER
208+
),
209+
width: 100,
205210
};
206211

207212
export function getAllColumns() {
@@ -250,13 +255,6 @@ export function TopicDataTimestamp({timestamp}: TopicDataTimestampProps) {
250255
);
251256
}
252257

253-
export function valueOrPlaceholder(
254-
value: string | number | undefined,
255-
placeholder = EMPTY_DATA_PLACEHOLDER,
256-
) {
257-
return isNil(value) ? placeholder : value;
258-
}
259-
260258
interface PartitionIdProps {
261259
offset?: string | number;
262260
removed?: boolean;

src/containers/Tenant/Diagnostics/TopicData/i18n/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"label_partition": "Partition ID",
44
"label_timestamp-create": "Timestamp Create",
55
"label_timestamp-write": "Timestamp Write",
6-
"label_ts_diff": "TS Diff",
6+
"label_ts_diff": "Write Lag",
77
"label_key": "Key",
88
"label_metadata": "Metadata",
99
"label_message": "Message",
@@ -31,5 +31,6 @@
3131
"label_download": "Save message to file",
3232
"label_truncated": "Truncated {{size}}",
3333
"description_not-loaded-message": "Message was not fetched in table due to problems with big messages.\nYou can view it in side panel by clicking on Offset",
34-
"description_removed-message": "Message was deleted due to retention"
34+
"description_removed-message": "Message was deleted due to retention",
35+
"description_last-messages": "Only last 50 000 messages from any partition are displayed"
3536
}

0 commit comments

Comments
 (0)