diff --git a/src/pages/consumer-groups/consumer-group.tsx b/src/pages/consumer-groups/consumer-group.tsx index dd4729b4..a7b3113e 100644 --- a/src/pages/consumer-groups/consumer-group.tsx +++ b/src/pages/consumer-groups/consumer-group.tsx @@ -1,15 +1,24 @@ -import { Text, Button, Container, Divider, Group, Center, Stack, SimpleGrid } from "@mantine/core"; +import { Text, Button, Container, Divider, Group, Stack, SimpleGrid } from "@mantine/core"; import { IconRefresh } from "@tabler/icons"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { SingleLineTitle } from "../../components"; import { ConsumerGroupInfo } from "../../models/kafka"; import { describeConsumerGroup } from "../../tauri"; export const ConsumerGroup = ({ name, clusterId }: { name: string; clusterId: string }) => { + // todo: wip cache last result on the backend const [state, setState] = useState(undefined); - const retrieveConsumerGroup = () => { - describeConsumerGroup(clusterId, name).then((cgi) => setState(cgi)); - }; + useMemo(() => { + setState(undefined); + }, [name, clusterId]); + + const retrieveConsumerGroup = useMemo( + () => async () => { + await describeConsumerGroup(clusterId, name).then((s) => setState(s)); + }, + [name, clusterId] + ); + return ( @@ -18,27 +27,44 @@ export const ConsumerGroup = ({ name, clusterId }: { name: string; clusterId: st - {!state && ( -
- Retrive the consumer group info may take few minutes. Click the button to start the process. - -
- )} + + + + {/* + todo: allow reset each single topic/partition + + + + + + }>Reset to the beginning + }>Reset to end + }>Reset to a point in time + + */} + {state && ( - - Topic - Partition - Offset - {state.offsets.map((o, i) => ( - <> - {o.topic} - {o.partition_id} - {o.offset} - - ))} - + <> + + Topic + Partition + Offset + {state.offsets.map((o, i) => ( + <> + {o.topic} + {o.partition_id} + {o.offset} + + ))} + + {/* */} + )}