Skip to content

Commit ac04a9d

Browse files
committed
Fixes and Enhancements to group reset functionality
Assisted-by: IBM Bob Signed-off-by: Michael Edgar <medgar@redhat.com>
1 parent 81e3504 commit ac04a9d

12 files changed

Lines changed: 423 additions & 390 deletions

File tree

api/src/main/webui/src/api/types.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,7 @@ export interface UserResponse {
759759
data: KafkaUser;
760760
}
761761

762-
// Reset Offset types
763-
export type OffsetValue = 'custom' | 'latest' | 'earliest' | 'specificDateTime' | 'delete';
764-
export type DateTimeFormat = 'ISO' | 'Epoch';
765-
export type TopicSelection = 'allTopics' | 'selectedTopic';
766-
export type PartitionSelection = 'allPartitions' | 'selectedPartition';
767-
762+
// Reset Offset API types
768763
export interface OffsetResetRequest {
769764
topicId: string;
770765
partition?: number;
@@ -778,28 +773,4 @@ export interface OffsetResetResult {
778773
partition: number;
779774
offset: number | null;
780775
metadata?: string;
781-
}
782-
783-
export interface ResetOffsetFormState {
784-
topicSelection: TopicSelection;
785-
selectedTopicId?: string;
786-
selectedTopicName?: string;
787-
partitionSelection: PartitionSelection;
788-
selectedPartition?: number;
789-
offsetValue: OffsetValue;
790-
customOffset?: number;
791-
dateTime?: string;
792-
dateTimeFormat: DateTimeFormat;
793-
}
794-
795-
export type ResetOffsetErrorType =
796-
| 'CustomOffsetError'
797-
| 'PartitionError'
798-
| 'KafkaError'
799-
| 'SpecificDateTimeNotValidError'
800-
| 'GeneralError';
801-
802-
export interface ResetOffsetError {
803-
type: ResetOffsetErrorType;
804-
message: string;
805776
}

api/src/main/webui/src/components/kafka/groups/ResetOffset/DryRunResults.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
Button,
1111
Alert,
1212
AlertVariant,
13+
ModalHeader,
14+
ModalBody,
15+
ModalFooter,
1316
} from '@patternfly/react-core';
1417
import {
1518
Table,
@@ -19,25 +22,31 @@ import {
1922
Tbody,
2023
Td,
2124
} from '@patternfly/react-table';
22-
import { OffsetResetResult } from '@/api/types';
25+
import { OffsetAndMetadata, OffsetResetResult } from '@/api/types';
26+
import { CliCommandDisplay } from './CliCommandDisplay';
2327

2428
interface DryRunResultsProps {
2529
isOpen: boolean;
2630
results: OffsetResetResult[];
31+
currentOffsets?: OffsetAndMetadata[] | null;
32+
command: string;
2733
onClose: () => void;
28-
onApply: () => void;
29-
isApplying?: boolean;
3034
}
3135

3236
export function DryRunResults({
3337
isOpen,
3438
results,
39+
currentOffsets,
40+
command,
3541
onClose,
36-
onApply,
37-
isApplying = false,
3842
}: DryRunResultsProps) {
3943
const { t } = useTranslation();
4044

45+
const currentOffsetsByPartition = (currentOffsets || []).reduce((acc, offset) => {
46+
acc[`${offset.topicName}-${offset.partition}`] = offset.offset;
47+
return acc;
48+
}, {} as Record<string, number | null>);
49+
4150
// Group results by topic
4251
const resultsByTopic = results.reduce((acc, result) => {
4352
const topicName = result.topicName;
@@ -50,12 +59,12 @@ export function DryRunResults({
5059

5160
return (
5261
<Modal
53-
variant={ModalVariant.large}
54-
title={t('groups.resetOffset.dryRunResults.title')}
62+
variant={ModalVariant.medium}
5563
isOpen={isOpen}
5664
onClose={onClose}
5765
>
58-
<div style={{ padding: '1.5rem' }}>
66+
<ModalHeader title={t('groups.resetOffset.dryRunResults.title')} />
67+
<ModalBody>
5968
<Alert
6069
variant={AlertVariant.info}
6170
isInline
@@ -79,6 +88,7 @@ export function DryRunResults({
7988
<Thead>
8089
<Tr>
8190
<Th>{t('groups.resetOffset.dryRunResults.partition')}</Th>
91+
<Th>{t('groups.resetOffset.dryRunResults.currentOffset')}</Th>
8292
<Th>{t('groups.resetOffset.dryRunResults.newOffset')}</Th>
8393
</Tr>
8494
</Thead>
@@ -88,6 +98,9 @@ export function DryRunResults({
8898
<Td dataLabel={t('groups.resetOffset.dryRunResults.partition')}>
8999
{result.partition}
90100
</Td>
101+
<Td dataLabel={t('groups.resetOffset.dryRunResults.currentOffset')}>
102+
{currentOffsetsByPartition[`${result.topicName}-${result.partition}`] ?? t('common.notAvailable')}
103+
</Td>
91104
<Td dataLabel={t('groups.resetOffset.dryRunResults.newOffset')}>
92105
{result.offset !== null
93106
? result.offset
@@ -100,24 +113,16 @@ export function DryRunResults({
100113
</div>
101114
))
102115
)}
103-
</div>
104-
<div style={{ padding: '1.5rem', paddingTop: '0', display: 'flex', gap: '0.5rem' }}>
105-
<Button
106-
variant="primary"
107-
onClick={onApply}
108-
isDisabled={isApplying || results.length === 0}
109-
isLoading={isApplying}
110-
>
111-
{t('groups.resetOffset.dryRunResults.apply')}
112-
</Button>
116+
<CliCommandDisplay command={command} />
117+
</ModalBody>
118+
<ModalFooter>
113119
<Button
114120
variant="link"
115121
onClick={onClose}
116-
isDisabled={isApplying}
117122
>
118123
{t('groups.resetOffset.dryRunResults.cancel')}
119124
</Button>
120-
</div>
125+
</ModalFooter>
121126
</Modal>
122127
);
123128
}

0 commit comments

Comments
 (0)