Skip to content

Commit c6b5df1

Browse files
feat(groups): improve consumer groups loading (#1889)
1 parent 8186cf5 commit c6b5df1

File tree

15 files changed

+356
-177
lines changed

15 files changed

+356
-177
lines changed

application.example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ akhq:
109109
skip-consumer-groups: false # Skip loading consumer group information when showing topics. Overrides default
110110
skip-last-record: true # Skip loading last record date information when showing topics. Overrides default
111111
show-all-consumer-groups: true # Expand list of consumer groups instead of showing one. Overrides default.
112+
groups-default-view: ALL # default consumer groups list view (ALL, HIDE_EMPTY). Overrides default
112113
topic-data:
113114
sort: NEWEST # default sort order (OLDEST, NEWEST) (default: OLDEST). Overrides default
114115
date-time-format: ISO # format of message timestamps (RELATIVE, ISO) (default: RELATIVE)
@@ -181,6 +182,7 @@ akhq:
181182
skip-consumer-groups: false # Skip loading consumer group information when showing topics. Overrides default
182183
skip-last-record: true # Skip loading last record date information when showing topics. Overrides default
183184
show-all-consumer-groups: true # Expand list of consumer groups instead of showing one. Overrides default.
185+
groups-default-view: ALL # default consumer groups list view (ALL, HIDE_EMPTY). Overrides default
184186
topic-data:
185187
sort: NEWEST # default sort order (OLDEST, NEWEST) (default: OLDEST). Overrides default
186188

client/src/components/SearchBar/SearchBar.jsx

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class SearchBar extends Form {
1212
showTopicListView: PropTypes.bool,
1313
showSearch: PropTypes.bool,
1414
showFilters: PropTypes.string,
15-
showKeepSearch: PropTypes.bool
15+
showKeepSearch: PropTypes.bool,
16+
showGroupsListView: PropTypes.bool
1617
};
1718
state = {
1819
formData: {},
@@ -34,7 +35,16 @@ class SearchBar extends Form {
3435
_id: SETTINGS_VALUES.TOPIC.TOPIC_DEFAULT_VIEW.HIDE_STREAM,
3536
name: 'Hide stream topics'
3637
}
37-
]
38+
],
39+
groupsListViewOptions: [
40+
{
41+
_id: SETTINGS_VALUES.TOPIC.CONSUMER_GROUP_DEFAULT_VIEW.ALL,
42+
name: "Show empty consumer groups"
43+
},
44+
{
45+
_id: SETTINGS_VALUES.TOPIC.CONSUMER_GROUP_DEFAULT_VIEW.HIDE_EMPTY,
46+
name: "Hide empty consumer groups"
47+
}]
3848
};
3949

4050
schema = {};
@@ -44,19 +54,16 @@ class SearchBar extends Form {
4454
}
4555

4656
componentDidUpdate(prevProps) {
47-
const { search, topicListView, keepSearch } = this.props;
57+
const { search, topicListView, keepSearch, groupsListView } = this.props;
4858

49-
if (
50-
search !== prevProps.search ||
51-
topicListView !== prevProps.topicListView ||
52-
keepSearch !== prevProps.keepSearch
53-
) {
59+
if (search !== prevProps.search || topicListView !== prevProps.topicListView
60+
|| keepSearch !== prevProps.keepSearch || groupsListView !== prevProps.groupsListView) {
5461
this.setupProps();
5562
}
5663
}
5764

5865
setupProps() {
59-
const { showSearch, showTopicListView, showKeepSearch } = this.props;
66+
const { showSearch, showTopicListView, showKeepSearch, showGroupsListView } = this.props;
6067
const { formData } = this.state;
6168
if (showSearch) {
6269
const { search } = this.props;
@@ -72,6 +79,11 @@ class SearchBar extends Form {
7279
formData['keepSearch'] = this.props.keepSearch;
7380
this.schema['keepSearch'] = Joi.boolean();
7481
}
82+
if (showGroupsListView) {
83+
const { groupsListView } = this.props;
84+
formData['groupsListView'] = groupsListView;
85+
this.schema['groupsListView'] = Joi.string().required();
86+
}
7587
return formData;
7688
}
7789

@@ -88,14 +100,15 @@ class SearchBar extends Form {
88100
}
89101

90102
doSubmit = () => {
91-
const { pagination, search, topicListView, keepSearch } = this.state.formData;
103+
const { pagination, search, topicListView, keepSearch, groupsListView } = this.state.formData;
92104
const data = {
93105
pagination: pagination,
94106
searchData: {
95107
search: search,
96108
topicListView: topicListView
97109
},
98-
keepSearch: keepSearch
110+
keepSearch: keepSearch,
111+
groupsListView: groupsListView
99112
};
100113
this.props.doSubmit(data);
101114
};
@@ -109,8 +122,8 @@ class SearchBar extends Form {
109122
}
110123

111124
render() {
112-
const { showSearch, showTopicListView, showKeepSearch } = this.props;
113-
const { topicListViewOptions, showFilters, formData } = this.state;
125+
const { showSearch, showTopicListView, showKeepSearch, showGroupsListView } = this.props;
126+
const { topicListViewOptions, groupsListViewOptions, showFilters, formData } = this.state;
114127

115128
return (
116129
<React.Fragment>
@@ -155,6 +168,22 @@ class SearchBar extends Form {
155168
'select-wrapper',
156169
false
157170
)}
171+
{showGroupsListView && (
172+
this.renderSelect(
173+
'groupsListView',
174+
'',
175+
groupsListViewOptions,
176+
({ currentTarget: input }) => {
177+
let { formData } = this.state;
178+
formData.groupsListView = input.value;
179+
this.setState();
180+
this.props.ongroupsListViewChange(input.value);
181+
},
182+
'',
183+
'select-wrapper',
184+
false
185+
)
186+
)}
158187
<button className="btn btn-primary" type="submit">
159188
<FontAwesomeIcon icon={faSearch} />
160189
<span className="d-lg-none"> Search</span>

client/src/containers/Settings/Settings.jsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class Settings extends Form {
1717
topicDataDateTimeFormat: '',
1818
skipConsumerGroups: false,
1919
skipLastRecord: false,
20-
showAllConsumerGroups: true
20+
showAllConsumerGroups: true,
21+
groupsDefaultView: ''
2122
},
2223
errors: {}
2324
};
@@ -33,14 +34,19 @@ class Settings extends Form {
3334
topicDataDateTimeFormat = Object.entries(SETTINGS_VALUES.TOPIC_DATA.DATE_TIME_FORMAT).map(
3435
([value]) => ({ _id: value, name: value })
3536
);
37+
groupsDefaultView = Object.entries(SETTINGS_VALUES.TOPIC.CONSUMER_GROUP_DEFAULT_VIEW).map(([value]) => ({
38+
_id: value,
39+
name: value
40+
}));
3641

3742
schema = {
3843
topicDefaultView: Joi.string().optional(),
3944
topicDataSort: Joi.string().optional(),
4045
topicDataDateTimeFormat: Joi.string().required(),
4146
skipConsumerGroups: Joi.boolean().optional(),
4247
skipLastRecord: Joi.boolean().optional(),
43-
showAllConsumerGroups: Joi.boolean().optional()
48+
showAllConsumerGroups: Joi.boolean().optional(),
49+
groupsDefaultView: Joi.string().optional()
4450
};
4551

4652
componentDidMount() {
@@ -72,7 +78,11 @@ class Settings extends Form {
7278
showAllConsumerGroups:
7379
this.state.uiOptions && this.state.uiOptions.topic
7480
? this.state.uiOptions.topic.showAllConsumerGroups
75-
: false
81+
: false,
82+
groupsDefaultView:
83+
this.state.uiOptions && this.state.uiOptions.topic
84+
? this.state.uiOptions.topic.groupsDefaultView
85+
: ''
7686
}
7787
});
7888
});
@@ -102,7 +112,8 @@ class Settings extends Form {
102112
defaultView: formData.topicDefaultView,
103113
skipConsumerGroups: formData.skipConsumerGroups,
104114
skipLastRecord: formData.skipLastRecord,
105-
showAllConsumerGroups: formData.showAllConsumerGroups
115+
showAllConsumerGroups: formData.showAllConsumerGroups,
116+
groupsDefaultView: formData.groupsDefaultView
106117
},
107118
topicData: {
108119
sort: formData.topicDataSort,
@@ -178,6 +189,20 @@ class Settings extends Form {
178189
/>
179190
</span>
180191
</div>
192+
{this.renderSelect(
193+
'groupsDefaultView',
194+
'Consumer Groups Default View',
195+
this.groupsDefaultView,
196+
({ currentTarget: input }) => {
197+
const { formData } = this.state;
198+
formData.groupsDefaultView = input.value;
199+
this.setState({ formData });
200+
},
201+
'col-sm-10',
202+
'select-wrapper settings-wrapper',
203+
true,
204+
{ className: 'form-control' }
205+
)}
181206
</fieldset>
182207

183208
<fieldset id="topicData" key="topicData">

0 commit comments

Comments
 (0)