From f8599494ee44be3a6c1d7d3a19da4fa4843e753f Mon Sep 17 00:00:00 2001 From: AlexisSouquiere Date: Tue, 30 Jul 2024 15:55:13 +0200 Subject: [PATCH 1/6] Adding hide empty groups option in topic groups --- client/src/components/SearchBar/SearchBar.jsx | 52 +++++- .../Topic/Topic/TopicGroups/TopicGroups.jsx | 163 +++++++++++------- client/src/utils/endpoints.jsx | 4 +- .../org/akhq/controllers/TopicController.java | 10 +- .../repositories/ConsumerGroupRepository.java | 26 ++- .../akhq/repositories/TopicRepository.java | 5 + 6 files changed, 178 insertions(+), 82 deletions(-) diff --git a/client/src/components/SearchBar/SearchBar.jsx b/client/src/components/SearchBar/SearchBar.jsx index fd910a98f..4c140fd10 100644 --- a/client/src/components/SearchBar/SearchBar.jsx +++ b/client/src/components/SearchBar/SearchBar.jsx @@ -12,7 +12,8 @@ class SearchBar extends Form { showTopicListView: PropTypes.bool, showSearch: PropTypes.bool, showFilters: PropTypes.string, - showKeepSearch: PropTypes.bool + showKeepSearch: PropTypes.bool, + showConsumerGroupsListView: PropTypes.bool }; state = { formData: {}, @@ -34,7 +35,16 @@ class SearchBar extends Form { _id: SETTINGS_VALUES.TOPIC.TOPIC_DEFAULT_VIEW.HIDE_STREAM, name: 'Hide stream topics' } - ] + ], + consumerGroupsListViewOptions: [ + { + _id: "ALL", + name: "Show empty consumer groups" + }, + { + _id: "HIDE_EMPTY", + name: "Hide empty consumer groups" + }] }; schema = {}; @@ -44,19 +54,20 @@ class SearchBar extends Form { } componentDidUpdate(prevProps) { - const { search, topicListView, keepSearch } = this.props; + const { search, topicListView, keepSearch, consumerGroupsListView } = this.props; if ( search !== prevProps.search || topicListView !== prevProps.topicListView || - keepSearch !== prevProps.keepSearch + keepSearch !== prevProps.keepSearch || + consumerGroupsListView !== prevProps.consumerGroupsListView ) { this.setupProps(); } } setupProps() { - const { showSearch, showTopicListView, showKeepSearch } = this.props; + const { showSearch, showTopicListView, showKeepSearch, showConsumerGroupsListView } = this.props; const { formData } = this.state; if (showSearch) { const { search } = this.props; @@ -72,6 +83,11 @@ class SearchBar extends Form { formData['keepSearch'] = this.props.keepSearch; this.schema['keepSearch'] = Joi.boolean(); } + if (showConsumerGroupsListView) { + const { consumerGroupsListView } = this.props; + formData['consumerGroupsListView'] = consumerGroupsListView; + this.schema['consumerGroupsListView'] = Joi.string().required(); + } return formData; } @@ -88,14 +104,15 @@ class SearchBar extends Form { } doSubmit = () => { - const { pagination, search, topicListView, keepSearch } = this.state.formData; + const { pagination, search, topicListView, keepSearch, consumerGroupsListView } = this.state.formData; const data = { pagination: pagination, searchData: { search: search, topicListView: topicListView }, - keepSearch: keepSearch + keepSearch: keepSearch, + consumerGroupsListView: consumerGroupsListView }; this.props.doSubmit(data); }; @@ -109,8 +126,9 @@ class SearchBar extends Form { } render() { - const { showSearch, showTopicListView, showKeepSearch } = this.props; - const { topicListViewOptions, showFilters, formData } = this.state; + const { showSearch, showTopicListView, showKeepSearch, showConsumerGroupsListView } = this.props; + const { topicListViewOptions, consumerGroupsListViewOptions, + showFilters, formData } = this.state; return ( @@ -155,6 +173,22 @@ class SearchBar extends Form { 'select-wrapper', false )} + {showConsumerGroupsListView && ( + this.renderSelect( + 'consumerGroupsListView', + '', + consumerGroupsListViewOptions, + ({ currentTarget: input }) => { + let { formData } = this.state; + formData.consumerGroupsListView = input.value; + this.setState(); + this.props.onConsumerGroupsListViewChange(input.value); + }, + '', + 'select-wrapper', + false + ) + )}