Skip to content

Commit 833898e

Browse files
authored
Merge branch 'main' into topic-right-click
2 parents 906545c + 550bd05 commit 833898e

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

api/src/main/java/io/kafbat/ui/controller/ConsumerGroupsController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public Mono<ResponseEntity<ConsumerGroupsPageResponseDTO>> getConsumerGroupsPage
143143
Optional.ofNullable(page).filter(i -> i > 0).orElse(1),
144144
Optional.ofNullable(perPage).filter(i -> i > 0).orElse(defaultConsumerGroupsPageSize),
145145
search,
146+
fts,
146147
Optional.ofNullable(orderBy).orElse(ConsumerGroupOrderingDTO.NAME),
147148
Optional.ofNullable(sortOrderDto).orElse(SortOrderDTO.ASC)
148149
)

api/src/main/java/io/kafbat/ui/service/ConsumerGroupService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ public Mono<ConsumerGroupsPage> getConsumerGroupsPage(
152152
int pageNum,
153153
int perPage,
154154
@Nullable String search,
155+
Boolean fts,
155156
ConsumerGroupOrderingDTO orderBy,
156157
SortOrderDTO sortOrderDto) {
157158
return adminClientService.get(cluster).flatMap(ac ->
158159
ac.listConsumerGroups()
159-
.map(listing -> filterGroups(listing, search)
160+
.map(listing -> filterGroups(listing, search, fts)
160161
)
161162
.flatMapIterable(lst -> lst)
162163
.filterWhen(cg -> accessControlService.isConsumerGroupAccessible(cg.groupId(), cluster.getName()))
@@ -169,9 +170,11 @@ public Mono<ConsumerGroupsPage> getConsumerGroupsPage(
169170
(allGroups.size() / perPage) + (allGroups.size() % perPage == 0 ? 0 : 1))))));
170171
}
171172

172-
private Collection<ConsumerGroupListing> filterGroups(Collection<ConsumerGroupListing> groups, String search) {
173-
ClustersProperties.ClusterFtsProperties fts = clustersProperties.getFts();
174-
ConsumerGroupFilter filter = new ConsumerGroupFilter(groups, fts.isEnabled(), fts.getConsumers());
173+
private Collection<ConsumerGroupListing> filterGroups(Collection<ConsumerGroupListing> groups, String search,
174+
Boolean useFts) {
175+
ClustersProperties.ClusterFtsProperties ftsProperties = clustersProperties.getFts();
176+
boolean fts = ftsProperties.use(useFts);
177+
ConsumerGroupFilter filter = new ConsumerGroupFilter(groups, fts, ftsProperties.getConsumers());
175178
return filter.find(search);
176179
}
177180

api/src/main/java/io/kafbat/ui/service/index/LuceneTopicsIndex.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.locks.ReentrantReadWriteLock;
1616
import java.util.function.Function;
1717
import java.util.stream.Collectors;
18+
import lombok.extern.slf4j.Slf4j;
1819
import org.apache.lucene.analysis.Analyzer;
1920
import org.apache.lucene.document.Document;
2021
import org.apache.lucene.document.Field;
@@ -40,6 +41,7 @@
4041
import org.apache.lucene.store.ByteBuffersDirectory;
4142
import org.apache.lucene.store.Directory;
4243

44+
@Slf4j
4345
public class LuceneTopicsIndex implements TopicsIndex {
4446
public static final String FIELD_NAME_RAW = "name_raw";
4547

@@ -74,9 +76,15 @@ private Directory build(List<InternalTopic> topics) {
7476
doc.add(new LongPoint(FIELD_SIZE, topic.getSegmentSize()));
7577
if (topic.getTopicConfigs() != null && !topic.getTopicConfigs().isEmpty()) {
7678
for (InternalTopicConfig topicConfig : topic.getTopicConfigs()) {
77-
if (topicConfig.getName() != null || topicConfig.getValue() != null) {
79+
final String topicConfigValue = topicConfig.getValue();
80+
if (topicConfigValue != null) {
7881
doc.add(new StringField(FIELD_CONFIG_PREFIX + "_" + topicConfig.getName(), topicConfig.getValue(),
7982
Field.Store.NO));
83+
} else {
84+
log.info(
85+
"Topic configuration item '{}' on internal topic '{}' has an unexpected value of null"
86+
+ "; skipping processing", topicConfig.getName(), topic.getName()
87+
);
8088
}
8189
}
8290
}

frontend/src/components/Topics/Topic/Messages/PreviewModal.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { InputLabel } from 'components/common/Input/InputLabel.styled';
66
import IconButtonWrapper from 'components/common/Icons/IconButtonWrapper';
77
import EditIcon from 'components/common/Icons/EditIcon';
88
import CancelIcon from 'components/common/Icons/CancelIcon';
9+
import { JSONPath } from 'jsonpath-plus';
910

1011
import * as S from './PreviewModal.styled';
1112
import { PreviewFilter } from './Message';
@@ -33,8 +34,14 @@ const PreviewModal: React.FC<InfoModalProps> = ({
3334
newErrors.push('field');
3435
}
3536

36-
if (path === '') {
37+
if (path.trim() === '') {
3738
newErrors.push('path');
39+
} else {
40+
try {
41+
JSONPath({ path, json: {} });
42+
} catch {
43+
newErrors.push('invalidPath');
44+
}
3845
}
3946

4047
if (newErrors?.length) {
@@ -111,6 +118,7 @@ const PreviewModal: React.FC<InfoModalProps> = ({
111118
/>
112119
<FormError>
113120
{errors.includes('path') && 'Json path is required'}
121+
{errors.includes('invalidPath') && 'Invalid JSONPath syntax'}
114122
</FormError>
115123
</div>
116124
<S.ButtonWrapper>

0 commit comments

Comments
 (0)