Skip to content

Commit 1bcdec4

Browse files
authored
FE: Add Search By consumer name in Topic View (#3089)
1 parent e3ee4c7 commit 1bcdec4

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import styled from 'styled-components';
2+
3+
export const SearchWrapper = styled.div`
4+
margin: 10px;
5+
width: 21%;
6+
`;

kafka-ui-react-app/src/components/Topics/Topic/ConsumerGroups/TopicConsumerGroups.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@ import useAppParams from 'lib/hooks/useAppParams';
55
import { useTopicConsumerGroups } from 'lib/hooks/api/topics';
66
import { ColumnDef } from '@tanstack/react-table';
77
import Table, { LinkCell, TagCell } from 'components/common/NewTable';
8+
import Search from 'components/common/Search/Search';
9+
10+
import * as S from './TopicConsumerGroups.styled';
811

912
const TopicConsumerGroups: React.FC = () => {
13+
const [keyword, setKeyword] = React.useState('');
1014
const { clusterName, topicName } = useAppParams<RouteParamsClusterTopic>();
1115

12-
const { data: consumerGroups = [] } = useTopicConsumerGroups({
16+
const { data = [] } = useTopicConsumerGroups({
1317
clusterName,
1418
topicName,
1519
});
20+
21+
const consumerGroups = React.useMemo(
22+
() =>
23+
data.filter(
24+
(item) => item.groupId.toLocaleLowerCase().indexOf(keyword) > -1
25+
),
26+
[data, keyword]
27+
);
28+
1629
const columns = React.useMemo<ColumnDef<ConsumerGroup>[]>(
1730
() => [
1831
{
@@ -61,12 +74,21 @@ const TopicConsumerGroups: React.FC = () => {
6174
[]
6275
);
6376
return (
64-
<Table
65-
columns={columns}
66-
data={consumerGroups}
67-
enableSorting
68-
emptyMessage="No active consumer groups"
69-
/>
77+
<>
78+
<S.SearchWrapper>
79+
<Search
80+
onChange={setKeyword}
81+
placeholder="Search by Consumer Name"
82+
value={keyword}
83+
/>
84+
</S.SearchWrapper>
85+
<Table
86+
columns={columns}
87+
data={consumerGroups}
88+
enableSorting
89+
emptyMessage="No active consumer groups"
90+
/>
91+
</>
7092
);
7193
};
7294

0 commit comments

Comments
 (0)