Add "Messages behind" for Topics within Consumer group profile (#2614)

Co-authored-by: winniechiu <winniechiu@cht.com.tw>
This commit is contained in:
Winnie Chiu 2022-10-04 20:25:55 +08:00 committed by GitHub
parent e3aeb0cac8
commit 9632ffdbdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -128,6 +128,7 @@ const Details: React.FC = () => {
<tr> <tr>
<TableHeaderCell> </TableHeaderCell> <TableHeaderCell> </TableHeaderCell>
<TableHeaderCell title="Topic" /> <TableHeaderCell title="Topic" />
<TableHeaderCell title="Messages behind" />
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -18,6 +18,15 @@ interface Props {
const ListItem: React.FC<Props> = ({ clusterName, name, consumers }) => { const ListItem: React.FC<Props> = ({ clusterName, name, consumers }) => {
const [isOpen, setIsOpen] = React.useState(false); const [isOpen, setIsOpen] = React.useState(false);
const getTotalMessagesBehind = () => {
let count = 0;
consumers.forEach((consumer) => {
count += consumer?.messagesBehind || 0;
});
return count;
};
return ( return (
<> <>
<tr> <tr>
@ -29,6 +38,7 @@ const ListItem: React.FC<Props> = ({ clusterName, name, consumers }) => {
<TableKeyLink> <TableKeyLink>
<Link to={clusterTopicPath(clusterName, name)}>{name}</Link> <Link to={clusterTopicPath(clusterName, name)}>{name}</Link>
</TableKeyLink> </TableKeyLink>
<td>{getTotalMessagesBehind()}</td>
</tr> </tr>
{isOpen && <TopicContents consumers={consumers} />} {isOpen && <TopicContents consumers={consumers} />}
</> </>

View file

@ -65,7 +65,7 @@ describe('Details component', () => {
expect(screen.getByText(groupId)).toBeInTheDocument(); expect(screen.getByText(groupId)).toBeInTheDocument();
expect(screen.getByRole('table')).toBeInTheDocument(); expect(screen.getByRole('table')).toBeInTheDocument();
expect(screen.getAllByRole('columnheader').length).toEqual(2); expect(screen.getAllByRole('columnheader').length).toEqual(3);
expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
}); });