diff --git a/kafka-ui-react-app/src/components/Topics/Topic/ConsumerGroups/TopicConsumerGroups.tsx b/kafka-ui-react-app/src/components/Topics/Topic/ConsumerGroups/TopicConsumerGroups.tsx index 0fc72fd82e..69948fd66d 100644 --- a/kafka-ui-react-app/src/components/Topics/Topic/ConsumerGroups/TopicConsumerGroups.tsx +++ b/kafka-ui-react-app/src/components/Topics/Topic/ConsumerGroups/TopicConsumerGroups.tsx @@ -1,65 +1,72 @@ import React from 'react'; -import { Link } from 'react-router-dom'; import { clusterConsumerGroupsPath, RouteParamsClusterTopic } from 'lib/paths'; -import { Table } from 'components/common/table/Table/Table.styled'; -import TableHeaderCell from 'components/common/table/TableHeaderCell/TableHeaderCell'; -import { Tag } from 'components/common/Tag/Tag.styled'; -import { TableKeyLink } from 'components/common/table/Table/TableKeyLink.styled'; -import getTagColor from 'components/common/Tag/getTagColor'; +import { ConsumerGroup } from 'generated-sources'; import useAppParams from 'lib/hooks/useAppParams'; import { useTopicConsumerGroups } from 'lib/hooks/api/topics'; +import { ColumnDef } from '@tanstack/react-table'; +import Table, { LinkCell, TagCell } from 'components/common/NewTable'; const TopicConsumerGroups: React.FC = () => { const { clusterName, topicName } = useAppParams(); - const { data: consumerGroups } = useTopicConsumerGroups({ + const { data: consumerGroups = [] } = useTopicConsumerGroups({ clusterName, topicName, }); + const columns = React.useMemo[]>( + () => [ + { + header: 'Consumer Group ID', + accessorKey: 'groupId', + enableSorting: false, + // eslint-disable-next-line react/no-unstable-nested-components + cell: ({ row }) => ( + + ), + }, + { + header: 'Active Consumers', + accessorKey: 'members', + enableSorting: false, + }, + { + header: 'Messages Behind', + accessorKey: 'messagesBehind', + enableSorting: false, + }, + { + header: 'Coordinator', + accessorKey: 'coordinator', + enableSorting: false, + cell: ({ getValue }) => { + const coordinator = getValue(); + if (coordinator === undefined) { + return 0; + } + return coordinator.id; + }, + }, + { + header: 'State', + accessorKey: 'state', + enableSorting: false, + cell: TagCell, + }, + ], + [] + ); return ( - - - - - - - - - - - - {consumerGroups?.map((consumer) => ( - - - - {consumer.groupId} - - - - - - - - ))} - {(!consumerGroups || consumerGroups.length === 0) && ( - - - - )} - -
{consumer.members}{consumer.messagesBehind}{consumer.coordinator?.id} - {consumer.state && ( - {`${consumer.state - .charAt(0) - .toUpperCase()}${consumer.state - .slice(1) - .toLowerCase()}`} - )} -
No active consumer groups
+ ); };