Skip to content

Commit

Permalink
Merge pull request #1081 from redpanda-data/fix/fixes-invalid-regexp-…
Browse files Browse the repository at this point in the history
…scenario

Fixes invalid regexp scenario
  • Loading branch information
jvorcak authored Feb 6, 2024
2 parents 6f5c260 + 93e7fe8 commit e7ee17b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
13 changes: 9 additions & 4 deletions frontend/src/components/pages/acls/Acl.List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ class AclList extends PageComponent {
</Alert>
: null;

const quickSearchRegExp = new RegExp(uiSettings.aclList.configTable.quickSearch, 'i')

const groups = this.principalGroups.filter(
aclGroup => aclGroup.principalName.match(quickSearchRegExp)
);
let groups = this.principalGroups
try {
const quickSearchRegExp = new RegExp(uiSettings.aclList.configTable.quickSearch, 'i')
groups = groups.filter(
aclGroup => aclGroup.principalName.match(quickSearchRegExp)
);
} catch (e) {
console.warn('Invalid expression')
}

return <>
<AlertDeleteFailed aclFailed={this.aclFailed} onClose={() => {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/pages/admin/Admin.Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ export class AdminUsers extends Component<{}> {
render() {
if (!api.adminInfo) return DefaultSkeleton;

const quickSearchRegExp = new RegExp(this.quickSearch, 'i')
let users = api.adminInfo.users

const users = this.quickSearch.length > 0 ? api.adminInfo.users.filter(u => u.internalIdentifier.match(quickSearchRegExp) || u.oauthUserId.match(quickSearchRegExp)) : api.adminInfo.users;
try {
const quickSearchRegExp = new RegExp(this.quickSearch, 'i')
users = users.filter(u => u.internalIdentifier.match(quickSearchRegExp) || u.oauthUserId.match(quickSearchRegExp))
} catch (e) {
console.warn('Invalid expression')
}

const table = (
<DataTable<UserDetails>
Expand Down
18 changes: 12 additions & 6 deletions frontend/src/components/pages/consumers/Group.List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ class GroupList extends PageComponent {
render() {
if (!api.consumerGroups) return DefaultSkeleton;

const quickSearchRegExp = new RegExp(uiSettings.consumerGroupList.quickSearch, 'i')
let groups = Array.from(api.consumerGroups.values())

try {
const quickSearchRegExp = new RegExp(uiSettings.consumerGroupList.quickSearch, 'i')
groups = groups
.filter(groupDescription =>
groupDescription.groupId.match(quickSearchRegExp) ||
groupDescription.protocol.match(quickSearchRegExp)
);
} catch (e) {
console.warn('Invalid expression')
}

const groups = Array.from(api.consumerGroups.values())
.filter(groupDescription =>
groupDescription.groupId.match(quickSearchRegExp) ||
groupDescription.protocol.match(quickSearchRegExp)
);
const stateGroups = groups.groupInto(g => g.state);

return (
Expand Down
14 changes: 9 additions & 5 deletions frontend/src/components/pages/schemas/Schema.List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ class SchemaList extends PageComponent<{}> {
if (api.schemaOverviewIsConfigured == false) return renderNotConfigured();
if (api.schemaSubjects === undefined) return DefaultSkeleton; // request in progress

const quickSearchRegExp = new RegExp(uiSettings.schemaList.quickSearch, 'i')

const filteredSubjects = api.schemaSubjects
.filter(x => uiSettings.schemaList.showSoftDeleted || (!uiSettings.schemaList.showSoftDeleted && !x.isSoftDeleted))
.filter(x => x.name.toLowerCase().match(quickSearchRegExp));
let filteredSubjects = api.schemaSubjects

try {
const quickSearchRegExp = new RegExp(uiSettings.schemaList.quickSearch, 'i');
filteredSubjects = filteredSubjects.filter(x => uiSettings.schemaList.showSoftDeleted || (!uiSettings.schemaList.showSoftDeleted && !x.isSoftDeleted))
.filter(x => x.name.toLowerCase().match(quickSearchRegExp));
} catch (e) {
console.warn('Invalid expression')
}

return (
<PageContent key="b">
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/components/pages/topics/Topic.List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,16 @@ class TopicList extends PageComponent {
if (uiSettings.topicList.hideInternalTopics) {
topics = topics.filter(x => !x.isInternal && !x.topicName.startsWith('_'));
}
const quickSearchRegExp = new RegExp(uiSettings.topicList.quickSearch.toLowerCase(), 'i')

topics = topics.filter(x => {
return x.topicName.toLowerCase().match(quickSearchRegExp);
});
try {
const quickSearchRegExp = new RegExp(uiSettings.topicList.quickSearch.toLowerCase(), 'i')

topics = topics.filter(x => {
return x.topicName.toLowerCase().match(quickSearchRegExp);
});
} catch (e) {
console.warn('Invalid expression')
}


const partitionCount = topics.sum((x) => x.partitionCount);
Expand Down

0 comments on commit e7ee17b

Please sign in to comment.