Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public Mono<ResponseEntity<Flux<KafkaAclDTO>>> listAcls(String clusterName,
KafkaAclResourceTypeDTO resourceTypeDto,
String resourceName,
KafkaAclNamePatternTypeDTO namePatternTypeDto,
String search,
ServerWebExchange exchange) {
AccessContext context = AccessContext.builder()
.cluster(clusterName)
Expand All @@ -88,7 +89,7 @@ public Mono<ResponseEntity<Flux<KafkaAclDTO>>> listAcls(String clusterName,
return validateAccess(context).then(
Mono.just(
ResponseEntity.ok(
aclsService.listAcls(getCluster(clusterName), filter)
aclsService.listAcls(getCluster(clusterName), filter, search)
.map(ClusterMapper::toKafkaAclDto)))
).doOnEach(sig -> audit(context, sig));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ public Mono<Void> deleteAcl(KafkaCluster cluster, AclBinding aclBinding) {
.doOnSuccess(v -> log.info("ACL DELETED: [{}]", aclString));
}

public Flux<AclBinding> listAcls(KafkaCluster cluster, ResourcePatternFilter filter) {
public Flux<AclBinding> listAcls(KafkaCluster cluster, ResourcePatternFilter filter, String principalSearch) {
return adminClientService.get(cluster)
.flatMap(c -> c.listAcls(filter))
.flatMapIterable(acls -> acls)
.filter(acl -> principalSearch == null || acl.entry().principal().contains(principalSearch))
.sort(Comparator.comparing(AclBinding::toString)); //sorting to keep stable order on different calls
}

Expand Down
5 changes: 5 additions & 0 deletions contract/src/main/resources/swagger/kafbat-ui-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,11 @@ paths:
required: false
schema:
$ref: '#/components/schemas/KafkaAclNamePatternType'
- name: search
in: query
required: false
schema:
type: string
responses:
200:
description: OK
Expand Down
27 changes: 25 additions & 2 deletions frontend/src/components/ACLPage/List/List.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { ColumnDef, Row } from '@tanstack/react-table';
import Table from 'components/common/NewTable';
import { useConfirm } from 'lib/hooks/useConfirm';
Expand All @@ -19,14 +20,18 @@ import { useTheme } from 'styled-components';
import ACLFormContext from 'components/ACLPage/Form/AclFormContext';
import PlusIcon from 'components/common/Icons/PlusIcon';
import ActionButton from 'components/common/ActionComponent/ActionButton/ActionButton';
import { ControlPanelWrapper } from 'components/common/ControlPanel/ControlPanel.styled';
import Search from 'components/common/Search/Search';
import ResourcePageHeading from 'components/common/ResourcePageHeading/ResourcePageHeading';
import BreakableTextCell from 'components/common/NewTable/BreakableTextCell';

import * as S from './List.styled';

const ACList: React.FC = () => {
const { clusterName } = useAppParams<{ clusterName: ClusterName }>();
const { data: aclList } = useAcls(clusterName);
const [searchParams, setSearchParams] = useSearchParams();
const [search, setSearch] = useState(searchParams.get('q') || '');
const { data: aclList } = useAcls({ clusterName, search });
const { deleteResource } = useDeleteAcl(clusterName);
const modal = useConfirm(true);
const theme = useTheme();
Expand All @@ -37,6 +42,17 @@ const ACList: React.FC = () => {
} = useBoolean();
const [rowId, setRowId] = React.useState('');

useEffect(() => {
const params = new URLSearchParams(searchParams);
if (search) {
params.set('q', search);
params.set('page', '1'); // reset to first page on new search
} else {
params.delete('q');
}
setSearchParams(params, { replace: true });
}, [search]);

const handleDeleteClick = (acl: KafkaAcl | null) => {
if (acl) {
modal('Are you sure want to delete this ACL record?', () =>
Expand Down Expand Up @@ -164,6 +180,13 @@ const ACList: React.FC = () => {
<PlusIcon /> Create ACL
</ActionButton>
</ResourcePageHeading>
<ControlPanelWrapper hasInput>
<Search
placeholder="Search by Principal Name"
value={search}
onChange={setSearch}
/>
</ControlPanelWrapper>
<Table
columns={columns}
data={aclList ?? []}
Expand Down
17 changes: 14 additions & 3 deletions frontend/src/lib/hooks/api/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ import {
KafkaAcl,
} from 'generated-sources';

export function useAcls(clusterName: ClusterName) {
export function useAcls({
clusterName,
search,
}: {
clusterName: ClusterName;
search?: string;
}) {
return useQuery(
['clusters', clusterName, 'acls'],
() => api.listAcls({ clusterName }),
['clusters', clusterName, 'acls', { search }],
() =>
api.listAcls({
clusterName,
search,
}),
{
keepPreviousData: true,
suspense: false,
}
);
Expand Down
Loading