Merge branch 'master' into issues/3720.2
This commit is contained in:
commit
a6241958fb
20 changed files with 574 additions and 15 deletions
8
.github/release_drafter.yaml
vendored
8
.github/release_drafter.yaml
vendored
|
@ -16,18 +16,26 @@ exclude-labels:
|
||||||
- 'type/refactoring'
|
- 'type/refactoring'
|
||||||
|
|
||||||
categories:
|
categories:
|
||||||
|
- title: '🚩 Breaking Changes'
|
||||||
|
labels:
|
||||||
|
- 'impact/changelog'
|
||||||
|
|
||||||
- title: '⚙️Features'
|
- title: '⚙️Features'
|
||||||
labels:
|
labels:
|
||||||
- 'type/feature'
|
- 'type/feature'
|
||||||
|
|
||||||
- title: '🪛Enhancements'
|
- title: '🪛Enhancements'
|
||||||
labels:
|
labels:
|
||||||
- 'type/enhancement'
|
- 'type/enhancement'
|
||||||
|
|
||||||
- title: '🔨Bug Fixes'
|
- title: '🔨Bug Fixes'
|
||||||
labels:
|
labels:
|
||||||
- 'type/bug'
|
- 'type/bug'
|
||||||
|
|
||||||
- title: 'Security'
|
- title: 'Security'
|
||||||
labels:
|
labels:
|
||||||
- 'type/security'
|
- 'type/security'
|
||||||
|
|
||||||
- title: '⎈ Helm/K8S Changes'
|
- title: '⎈ Helm/K8S Changes'
|
||||||
labels:
|
labels:
|
||||||
- 'scope/k8s'
|
- 'scope/k8s'
|
||||||
|
|
17
.github/workflows/release_drafter.yml
vendored
17
.github/workflows/release_drafter.yml
vendored
|
@ -2,18 +2,33 @@ name: Release Drafter
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# branches to consider in the event; optional, defaults to all
|
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Release version'
|
||||||
|
required: false
|
||||||
|
branch:
|
||||||
|
description: 'Target branch'
|
||||||
|
required: false
|
||||||
|
default: 'master'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_release_draft:
|
update_release_draft:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- uses: release-drafter/release-drafter@v5
|
- uses: release-drafter/release-drafter@v5
|
||||||
with:
|
with:
|
||||||
config-name: release_drafter.yaml
|
config-name: release_drafter.yaml
|
||||||
disable-autolabeler: true
|
disable-autolabeler: true
|
||||||
|
version: ${{ github.event.inputs.version }}
|
||||||
|
commitish: ${{ github.event.inputs.branch }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
13
kafka-ui-react-app/src/components/ACLPage/ACLPage.tsx
Normal file
13
kafka-ui-react-app/src/components/ACLPage/ACLPage.tsx
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Routes, Route } from 'react-router-dom';
|
||||||
|
import ACList from 'components/ACLPage/List/List';
|
||||||
|
|
||||||
|
const ACLPage = () => {
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route index element={<ACList />} />
|
||||||
|
</Routes>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ACLPage;
|
|
@ -0,0 +1,44 @@
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
export const EnumCell = styled.div`
|
||||||
|
text-transform: capitalize;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const DeleteCell = styled.div`
|
||||||
|
svg {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Chip = styled.div<{
|
||||||
|
chipType?: 'default' | 'success' | 'danger' | 'secondary' | string;
|
||||||
|
}>`
|
||||||
|
width: fit-content;
|
||||||
|
text-transform: capitalize;
|
||||||
|
padding: 2px 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 16px;
|
||||||
|
border-radius: 16px;
|
||||||
|
color: ${({ theme }) => theme.tag.color};
|
||||||
|
background-color: ${({ theme, chipType }) => {
|
||||||
|
switch (chipType) {
|
||||||
|
case 'success':
|
||||||
|
return theme.tag.backgroundColor.green;
|
||||||
|
case 'danger':
|
||||||
|
return theme.tag.backgroundColor.red;
|
||||||
|
case 'secondary':
|
||||||
|
return theme.tag.backgroundColor.secondary;
|
||||||
|
default:
|
||||||
|
return theme.tag.backgroundColor.gray;
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const PatternCell = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
${Chip} {
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
`;
|
153
kafka-ui-react-app/src/components/ACLPage/List/List.tsx
Normal file
153
kafka-ui-react-app/src/components/ACLPage/List/List.tsx
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
import { useTheme } from 'styled-components';
|
||||||
|
import PageHeading from 'components/common/PageHeading/PageHeading';
|
||||||
|
import Table from 'components/common/NewTable';
|
||||||
|
import DeleteIcon from 'components/common/Icons/DeleteIcon';
|
||||||
|
import { useConfirm } from 'lib/hooks/useConfirm';
|
||||||
|
import useAppParams from 'lib/hooks/useAppParams';
|
||||||
|
import { useAcls, useDeleteAcl } from 'lib/hooks/api/acl';
|
||||||
|
import { ClusterName } from 'redux/interfaces';
|
||||||
|
import {
|
||||||
|
KafkaAcl,
|
||||||
|
KafkaAclNamePatternType,
|
||||||
|
KafkaAclPermissionEnum,
|
||||||
|
} from 'generated-sources';
|
||||||
|
|
||||||
|
import * as S from './List.styled';
|
||||||
|
|
||||||
|
const ACList: React.FC = () => {
|
||||||
|
const { clusterName } = useAppParams<{ clusterName: ClusterName }>();
|
||||||
|
const theme = useTheme();
|
||||||
|
const { data: aclList } = useAcls(clusterName);
|
||||||
|
const { deleteResource } = useDeleteAcl(clusterName);
|
||||||
|
const modal = useConfirm(true);
|
||||||
|
|
||||||
|
const [rowId, setRowId] = React.useState('');
|
||||||
|
|
||||||
|
const onDeleteClick = (acl: KafkaAcl | null) => {
|
||||||
|
if (acl) {
|
||||||
|
modal('Are you sure want to delete this ACL record?', () =>
|
||||||
|
deleteResource(acl)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = React.useMemo<ColumnDef<KafkaAcl>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
header: 'Principal',
|
||||||
|
accessorKey: 'principal',
|
||||||
|
size: 257,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'Resource',
|
||||||
|
accessorKey: 'resourceType',
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
cell: ({ getValue }) => (
|
||||||
|
<S.EnumCell>{getValue<string>().toLowerCase()}</S.EnumCell>
|
||||||
|
),
|
||||||
|
size: 145,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'Pattern',
|
||||||
|
accessorKey: 'resourceName',
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
cell: ({ getValue, row }) => {
|
||||||
|
let chipType;
|
||||||
|
if (
|
||||||
|
row.original.namePatternType === KafkaAclNamePatternType.PREFIXED
|
||||||
|
) {
|
||||||
|
chipType = 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
row.original.namePatternType === KafkaAclNamePatternType.LITERAL
|
||||||
|
) {
|
||||||
|
chipType = 'secondary';
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<S.PatternCell>
|
||||||
|
{getValue<string>()}
|
||||||
|
{chipType ? (
|
||||||
|
<S.Chip chipType={chipType}>
|
||||||
|
{row.original.namePatternType.toLowerCase()}
|
||||||
|
</S.Chip>
|
||||||
|
) : null}
|
||||||
|
</S.PatternCell>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
size: 257,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'Host',
|
||||||
|
accessorKey: 'host',
|
||||||
|
size: 257,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'Operation',
|
||||||
|
accessorKey: 'operation',
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
cell: ({ getValue }) => (
|
||||||
|
<S.EnumCell>{getValue<string>().toLowerCase()}</S.EnumCell>
|
||||||
|
),
|
||||||
|
size: 121,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: 'Permission',
|
||||||
|
accessorKey: 'permission',
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
cell: ({ getValue }) => (
|
||||||
|
<S.Chip
|
||||||
|
chipType={
|
||||||
|
getValue<string>() === KafkaAclPermissionEnum.ALLOW
|
||||||
|
? 'success'
|
||||||
|
: 'danger'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{getValue<string>().toLowerCase()}
|
||||||
|
</S.Chip>
|
||||||
|
),
|
||||||
|
size: 111,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'delete',
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
cell: ({ row }) => {
|
||||||
|
return (
|
||||||
|
<S.DeleteCell onClick={() => onDeleteClick(row.original)}>
|
||||||
|
<DeleteIcon
|
||||||
|
fill={
|
||||||
|
rowId === row.id ? theme.acl.table.deleteIcon : 'transparent'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</S.DeleteCell>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
size: 76,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[rowId]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onRowHover = (value: unknown) => {
|
||||||
|
if (value && typeof value === 'object' && 'id' in value) {
|
||||||
|
setRowId(value.id as string);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageHeading text="Access Control List" />
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
data={aclList ?? []}
|
||||||
|
emptyMessage="No ACL items found"
|
||||||
|
onRowHover={onRowHover}
|
||||||
|
onMouseLeave={() => setRowId('')}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ACList;
|
|
@ -0,0 +1,74 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { render, WithRoute } from 'lib/testHelpers';
|
||||||
|
import { screen } from '@testing-library/dom';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { clusterACLPath } from 'lib/paths';
|
||||||
|
import ACList from 'components/ACLPage/List/List';
|
||||||
|
import { useAcls, useDeleteAcl } from 'lib/hooks/api/acl';
|
||||||
|
import { aclPayload } from 'lib/fixtures/acls';
|
||||||
|
|
||||||
|
jest.mock('lib/hooks/api/acl', () => ({
|
||||||
|
useAcls: jest.fn(),
|
||||||
|
useDeleteAcl: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('ACLList Component', () => {
|
||||||
|
const clusterName = 'local';
|
||||||
|
const renderComponent = () =>
|
||||||
|
render(
|
||||||
|
<WithRoute path={clusterACLPath()}>
|
||||||
|
<ACList />
|
||||||
|
</WithRoute>,
|
||||||
|
{
|
||||||
|
initialEntries: [clusterACLPath(clusterName)],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('ACLList', () => {
|
||||||
|
describe('when the acls are loaded', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
(useAcls as jest.Mock).mockImplementation(() => ({
|
||||||
|
data: aclPayload,
|
||||||
|
}));
|
||||||
|
(useDeleteAcl as jest.Mock).mockImplementation(() => ({
|
||||||
|
deleteResource: jest.fn(),
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders ACLList with records', async () => {
|
||||||
|
renderComponent();
|
||||||
|
expect(screen.getByRole('table')).toBeInTheDocument();
|
||||||
|
expect(screen.getAllByRole('row').length).toEqual(4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows delete icon on hover', async () => {
|
||||||
|
const { container } = renderComponent();
|
||||||
|
const [trElement] = screen.getAllByRole('row');
|
||||||
|
await userEvent.hover(trElement);
|
||||||
|
const deleteElement = container.querySelector('svg');
|
||||||
|
expect(deleteElement).not.toHaveStyle({
|
||||||
|
fill: 'transparent',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when it has no acls', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
(useAcls as jest.Mock).mockImplementation(() => ({
|
||||||
|
data: [],
|
||||||
|
}));
|
||||||
|
(useDeleteAcl as jest.Mock).mockImplementation(() => ({
|
||||||
|
deleteResource: jest.fn(),
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders empty ACLList with message', async () => {
|
||||||
|
renderComponent();
|
||||||
|
expect(screen.getByRole('table')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByRole('row', { name: 'No ACL items found' })
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -13,6 +13,7 @@ import {
|
||||||
clusterTopicsRelativePath,
|
clusterTopicsRelativePath,
|
||||||
clusterConfigRelativePath,
|
clusterConfigRelativePath,
|
||||||
getNonExactPath,
|
getNonExactPath,
|
||||||
|
clusterAclRelativePath,
|
||||||
} from 'lib/paths';
|
} from 'lib/paths';
|
||||||
import ClusterContext from 'components/contexts/ClusterContext';
|
import ClusterContext from 'components/contexts/ClusterContext';
|
||||||
import PageLoader from 'components/common/PageLoader/PageLoader';
|
import PageLoader from 'components/common/PageLoader/PageLoader';
|
||||||
|
@ -30,6 +31,7 @@ const ClusterConfigPage = React.lazy(
|
||||||
const ConsumerGroups = React.lazy(
|
const ConsumerGroups = React.lazy(
|
||||||
() => import('components/ConsumerGroups/ConsumerGroups')
|
() => import('components/ConsumerGroups/ConsumerGroups')
|
||||||
);
|
);
|
||||||
|
const AclPage = React.lazy(() => import('components/ACLPage/ACLPage'));
|
||||||
|
|
||||||
const ClusterPage: React.FC = () => {
|
const ClusterPage: React.FC = () => {
|
||||||
const { clusterName } = useAppParams<ClusterNameRoute>();
|
const { clusterName } = useAppParams<ClusterNameRoute>();
|
||||||
|
@ -51,6 +53,9 @@ const ClusterPage: React.FC = () => {
|
||||||
ClusterFeaturesEnum.TOPIC_DELETION
|
ClusterFeaturesEnum.TOPIC_DELETION
|
||||||
),
|
),
|
||||||
hasKsqlDbConfigured: features.includes(ClusterFeaturesEnum.KSQL_DB),
|
hasKsqlDbConfigured: features.includes(ClusterFeaturesEnum.KSQL_DB),
|
||||||
|
hasAclViewConfigured:
|
||||||
|
features.includes(ClusterFeaturesEnum.KAFKA_ACL_VIEW) ||
|
||||||
|
features.includes(ClusterFeaturesEnum.KAFKA_ACL_EDIT),
|
||||||
};
|
};
|
||||||
}, [clusterName, data]);
|
}, [clusterName, data]);
|
||||||
|
|
||||||
|
@ -95,6 +100,12 @@ const ClusterPage: React.FC = () => {
|
||||||
element={<KsqlDb />}
|
element={<KsqlDb />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{contextValue.hasAclViewConfigured && (
|
||||||
|
<Route
|
||||||
|
path={getNonExactPath(clusterAclRelativePath)}
|
||||||
|
element={<AclPage />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{appInfo.hasDynamicConfig && (
|
{appInfo.hasDynamicConfig && (
|
||||||
<Route
|
<Route
|
||||||
path={getNonExactPath(clusterConfigRelativePath)}
|
path={getNonExactPath(clusterConfigRelativePath)}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
clusterSchemasPath,
|
clusterSchemasPath,
|
||||||
clusterConnectorsPath,
|
clusterConnectorsPath,
|
||||||
clusterKsqlDbPath,
|
clusterKsqlDbPath,
|
||||||
|
clusterACLPath,
|
||||||
} from 'lib/paths';
|
} from 'lib/paths';
|
||||||
|
|
||||||
import ClusterMenuItem from './ClusterMenuItem';
|
import ClusterMenuItem from './ClusterMenuItem';
|
||||||
|
@ -57,6 +58,10 @@ const ClusterMenu: React.FC<Props> = ({
|
||||||
{hasFeatureConfigured(ClusterFeaturesEnum.KSQL_DB) && (
|
{hasFeatureConfigured(ClusterFeaturesEnum.KSQL_DB) && (
|
||||||
<ClusterMenuItem to={clusterKsqlDbPath(name)} title="KSQL DB" />
|
<ClusterMenuItem to={clusterKsqlDbPath(name)} title="KSQL DB" />
|
||||||
)}
|
)}
|
||||||
|
{(hasFeatureConfigured(ClusterFeaturesEnum.KAFKA_ACL_VIEW) ||
|
||||||
|
hasFeatureConfigured(ClusterFeaturesEnum.KAFKA_ACL_EDIT)) && (
|
||||||
|
<ClusterMenuItem to={clusterACLPath(name)} title="ACL" />
|
||||||
|
)}
|
||||||
</S.List>
|
</S.List>
|
||||||
)}
|
)}
|
||||||
</S.List>
|
</S.List>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export interface ButtonProps {
|
export interface ButtonProps {
|
||||||
buttonType: 'primary' | 'secondary';
|
buttonType: 'primary' | 'secondary' | 'danger';
|
||||||
buttonSize: 'S' | 'M' | 'L';
|
buttonSize: 'S' | 'M' | 'L';
|
||||||
isInverted?: boolean;
|
isInverted?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ const ConfirmationModal: React.FC = () => {
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
buttonType="primary"
|
buttonType={context.dangerButton ? 'danger' : 'primary'}
|
||||||
buttonSize="M"
|
buttonSize="M"
|
||||||
onClick={context.confirm}
|
onClick={context.confirm}
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTheme } from 'styled-components';
|
import { useTheme } from 'styled-components';
|
||||||
|
|
||||||
const DeleteIcon: React.FC = () => {
|
const DeleteIcon: React.FC<{ fill?: string }> = ({ fill }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const curentFill = fill || theme.editFilter.deleteIconColor;
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 448 512"
|
viewBox="0 0 448 512"
|
||||||
fill={theme.editFilter.deleteIconColor}
|
fill={curentFill}
|
||||||
width="14"
|
width="14"
|
||||||
height="14"
|
height="14"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { MultiSelect as ReactMultiSelect } from 'react-multi-select-component';
|
import { MultiSelect as ReactMultiSelect } from 'react-multi-select-component';
|
||||||
|
|
||||||
const MultiSelect = styled(ReactMultiSelect)<{ minWidth?: string }>`
|
const MultiSelect = styled(ReactMultiSelect)<{
|
||||||
|
minWidth?: string;
|
||||||
|
height?: string;
|
||||||
|
}>`
|
||||||
min-width: ${({ minWidth }) => minWidth || '200px;'};
|
min-width: ${({ minWidth }) => minWidth || '200px;'};
|
||||||
height: 32px;
|
height: ${({ height }) => height ?? '32px'};
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
.search input {
|
.search input {
|
||||||
color: ${({ theme }) => theme.input.color.normal};
|
color: ${({ theme }) => theme.input.color.normal};
|
||||||
|
@ -36,13 +39,14 @@ const MultiSelect = styled(ReactMultiSelect)<{ minWidth?: string }>`
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: ${({ theme }) => theme.select.borderColor.hover} !important;
|
border-color: ${({ theme }) => theme.select.borderColor.hover} !important;
|
||||||
}
|
}
|
||||||
height: 32px;
|
|
||||||
|
height: ${({ height }) => height ?? '32px'};
|
||||||
* {
|
* {
|
||||||
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
|
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .dropdown-heading {
|
& > .dropdown-heading {
|
||||||
height: 32px;
|
height: ${({ height }) => height ?? '32px'};
|
||||||
color: ${({ disabled, theme }) =>
|
color: ${({ disabled, theme }) =>
|
||||||
disabled
|
disabled
|
||||||
? theme.select.color.disabled
|
? theme.select.color.disabled
|
||||||
|
|
|
@ -52,6 +52,9 @@ export interface TableProps<TData> {
|
||||||
|
|
||||||
// Handles row click. Can not be combined with `enableRowSelection` && expandable rows.
|
// Handles row click. Can not be combined with `enableRowSelection` && expandable rows.
|
||||||
onRowClick?: (row: Row<TData>) => void;
|
onRowClick?: (row: Row<TData>) => void;
|
||||||
|
|
||||||
|
onRowHover?: (row: Row<TData>) => void;
|
||||||
|
onMouseLeave?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdaterFn<T> = (previousState: T) => T;
|
type UpdaterFn<T> = (previousState: T) => T;
|
||||||
|
@ -127,6 +130,8 @@ const Table: React.FC<TableProps<any>> = ({
|
||||||
emptyMessage,
|
emptyMessage,
|
||||||
disabled,
|
disabled,
|
||||||
onRowClick,
|
onRowClick,
|
||||||
|
onRowHover,
|
||||||
|
onMouseLeave,
|
||||||
}) => {
|
}) => {
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
@ -194,6 +199,21 @@ const Table: React.FC<TableProps<any>> = ({
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRowHover = (row: Row<typeof data>) => (e: React.MouseEvent) => {
|
||||||
|
if (onRowHover) {
|
||||||
|
e.stopPropagation();
|
||||||
|
return onRowHover(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseLeave = () => {
|
||||||
|
if (onMouseLeave) {
|
||||||
|
onMouseLeave();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{BatchActionsBar && (
|
{BatchActionsBar && (
|
||||||
|
@ -227,6 +247,12 @@ const Table: React.FC<TableProps<any>> = ({
|
||||||
sortable={header.column.getCanSort()}
|
sortable={header.column.getCanSort()}
|
||||||
sortOrder={header.column.getIsSorted()}
|
sortOrder={header.column.getIsSorted()}
|
||||||
onClick={header.column.getToggleSortingHandler()}
|
onClick={header.column.getToggleSortingHandler()}
|
||||||
|
style={{
|
||||||
|
width:
|
||||||
|
header.column.getSize() !== 150
|
||||||
|
? header.column.getSize()
|
||||||
|
: undefined,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{flexRender(
|
{flexRender(
|
||||||
|
@ -245,6 +271,8 @@ const Table: React.FC<TableProps<any>> = ({
|
||||||
<S.Row
|
<S.Row
|
||||||
expanded={row.getIsExpanded()}
|
expanded={row.getIsExpanded()}
|
||||||
onClick={handleRowClick(row)}
|
onClick={handleRowClick(row)}
|
||||||
|
onMouseOver={onRowHover ? handleRowHover(row) : undefined}
|
||||||
|
onMouseLeave={onMouseLeave ? handleMouseLeave : undefined}
|
||||||
clickable={
|
clickable={
|
||||||
!enableRowSelection &&
|
!enableRowSelection &&
|
||||||
(row.getCanExpand() || onRowClick !== undefined)
|
(row.getCanExpand() || onRowClick !== undefined)
|
||||||
|
@ -269,7 +297,13 @@ const Table: React.FC<TableProps<any>> = ({
|
||||||
{row
|
{row
|
||||||
.getVisibleCells()
|
.getVisibleCells()
|
||||||
.map(({ id, getContext, column: { columnDef } }) => (
|
.map(({ id, getContext, column: { columnDef } }) => (
|
||||||
<td key={id} style={columnDef.meta}>
|
<td
|
||||||
|
key={id}
|
||||||
|
style={{
|
||||||
|
width:
|
||||||
|
columnDef.size !== 150 ? columnDef.size : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{flexRender(columnDef.cell, getContext())}
|
{flexRender(columnDef.cell, getContext())}
|
||||||
</td>
|
</td>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -6,6 +6,8 @@ interface ConfirmContextType {
|
||||||
setContent: React.Dispatch<React.SetStateAction<React.ReactNode>>;
|
setContent: React.Dispatch<React.SetStateAction<React.ReactNode>>;
|
||||||
setConfirm: React.Dispatch<React.SetStateAction<(() => void) | undefined>>;
|
setConfirm: React.Dispatch<React.SetStateAction<(() => void) | undefined>>;
|
||||||
cancel: () => void;
|
cancel: () => void;
|
||||||
|
dangerButton: boolean;
|
||||||
|
setDangerButton: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ConfirmContext = React.createContext<ConfirmContextType | null>(
|
export const ConfirmContext = React.createContext<ConfirmContextType | null>(
|
||||||
|
@ -17,6 +19,7 @@ export const ConfirmContextProvider: React.FC<
|
||||||
> = ({ children }) => {
|
> = ({ children }) => {
|
||||||
const [content, setContent] = useState<React.ReactNode>(null);
|
const [content, setContent] = useState<React.ReactNode>(null);
|
||||||
const [confirm, setConfirm] = useState<(() => void) | undefined>(undefined);
|
const [confirm, setConfirm] = useState<(() => void) | undefined>(undefined);
|
||||||
|
const [dangerButton, setDangerButton] = useState(false);
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
setContent(null);
|
setContent(null);
|
||||||
|
@ -31,6 +34,8 @@ export const ConfirmContextProvider: React.FC<
|
||||||
confirm,
|
confirm,
|
||||||
setConfirm,
|
setConfirm,
|
||||||
cancel,
|
cancel,
|
||||||
|
dangerButton,
|
||||||
|
setDangerButton,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
ConsumerGroupsApi,
|
ConsumerGroupsApi,
|
||||||
AuthorizationApi,
|
AuthorizationApi,
|
||||||
ApplicationConfigApi,
|
ApplicationConfigApi,
|
||||||
|
AclsApi,
|
||||||
} from 'generated-sources';
|
} from 'generated-sources';
|
||||||
import { BASE_PARAMS } from 'lib/constants';
|
import { BASE_PARAMS } from 'lib/constants';
|
||||||
|
|
||||||
|
@ -25,3 +26,4 @@ export const kafkaConnectApiClient = new KafkaConnectApi(apiClientConf);
|
||||||
export const consumerGroupsApiClient = new ConsumerGroupsApi(apiClientConf);
|
export const consumerGroupsApiClient = new ConsumerGroupsApi(apiClientConf);
|
||||||
export const authApiClient = new AuthorizationApi(apiClientConf);
|
export const authApiClient = new AuthorizationApi(apiClientConf);
|
||||||
export const appConfigApiClient = new ApplicationConfigApi(apiClientConf);
|
export const appConfigApiClient = new ApplicationConfigApi(apiClientConf);
|
||||||
|
export const aclApiClient = new AclsApi(apiClientConf);
|
||||||
|
|
37
kafka-ui-react-app/src/lib/fixtures/acls.ts
Normal file
37
kafka-ui-react-app/src/lib/fixtures/acls.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import {
|
||||||
|
KafkaAcl,
|
||||||
|
KafkaAclResourceType,
|
||||||
|
KafkaAclNamePatternType,
|
||||||
|
KafkaAclPermissionEnum,
|
||||||
|
KafkaAclOperationEnum,
|
||||||
|
} from 'generated-sources';
|
||||||
|
|
||||||
|
export const aclPayload: KafkaAcl[] = [
|
||||||
|
{
|
||||||
|
principal: 'User 1',
|
||||||
|
resourceName: 'Topic',
|
||||||
|
resourceType: KafkaAclResourceType.TOPIC,
|
||||||
|
host: '_host1',
|
||||||
|
namePatternType: KafkaAclNamePatternType.LITERAL,
|
||||||
|
permission: KafkaAclPermissionEnum.ALLOW,
|
||||||
|
operation: KafkaAclOperationEnum.READ,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
principal: 'User 2',
|
||||||
|
resourceName: 'Topic',
|
||||||
|
resourceType: KafkaAclResourceType.TOPIC,
|
||||||
|
host: '_host1',
|
||||||
|
namePatternType: KafkaAclNamePatternType.PREFIXED,
|
||||||
|
permission: KafkaAclPermissionEnum.ALLOW,
|
||||||
|
operation: KafkaAclOperationEnum.READ,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
principal: 'User 3',
|
||||||
|
resourceName: 'Topic',
|
||||||
|
resourceType: KafkaAclResourceType.TOPIC,
|
||||||
|
host: '_host1',
|
||||||
|
namePatternType: KafkaAclNamePatternType.LITERAL,
|
||||||
|
permission: KafkaAclPermissionEnum.DENY,
|
||||||
|
operation: KafkaAclOperationEnum.READ,
|
||||||
|
},
|
||||||
|
];
|
67
kafka-ui-react-app/src/lib/hooks/api/acl.ts
Normal file
67
kafka-ui-react-app/src/lib/hooks/api/acl.ts
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
import { aclApiClient as api } from 'lib/api';
|
||||||
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { ClusterName } from 'redux/interfaces';
|
||||||
|
import { showSuccessAlert } from 'lib/errorHandling';
|
||||||
|
import { KafkaAcl } from 'generated-sources';
|
||||||
|
|
||||||
|
export function useAcls(clusterName: ClusterName) {
|
||||||
|
return useQuery(
|
||||||
|
['clusters', clusterName, 'acls'],
|
||||||
|
() => api.listAcls({ clusterName }),
|
||||||
|
{
|
||||||
|
suspense: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateAclMutation(clusterName: ClusterName) {
|
||||||
|
return useMutation(
|
||||||
|
(data: KafkaAcl) =>
|
||||||
|
api.createAcl({
|
||||||
|
clusterName,
|
||||||
|
kafkaAcl: data,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
showSuccessAlert({
|
||||||
|
message: 'Your ACL was created successfully',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateAcl(clusterName: ClusterName) {
|
||||||
|
const mutate = useCreateAclMutation(clusterName);
|
||||||
|
|
||||||
|
return {
|
||||||
|
createResource: async (param: KafkaAcl) => {
|
||||||
|
return mutate.mutateAsync(param);
|
||||||
|
},
|
||||||
|
...mutate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteAclMutation(clusterName: ClusterName) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation(
|
||||||
|
(acl: KafkaAcl) => api.deleteAcl({ clusterName, kafkaAcl: acl }),
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
showSuccessAlert({ message: 'ACL deleted' });
|
||||||
|
queryClient.invalidateQueries(['clusters', clusterName, 'acls']);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteAcl(clusterName: ClusterName) {
|
||||||
|
const mutate = useDeleteAclMutation(clusterName);
|
||||||
|
|
||||||
|
return {
|
||||||
|
deleteResource: async (param: KafkaAcl) => {
|
||||||
|
return mutate.mutateAsync(param);
|
||||||
|
},
|
||||||
|
...mutate,
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
import { ConfirmContext } from 'components/contexts/ConfirmContext';
|
import { ConfirmContext } from 'components/contexts/ConfirmContext';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
|
|
||||||
export const useConfirm = () => {
|
export const useConfirm = (danger = false) => {
|
||||||
const context = useContext(ConfirmContext);
|
const context = useContext(ConfirmContext);
|
||||||
return (
|
return (
|
||||||
message: React.ReactNode,
|
message: React.ReactNode,
|
||||||
callback: () => void | Promise<unknown>
|
callback: () => void | Promise<unknown>
|
||||||
) => {
|
) => {
|
||||||
|
context?.setDangerButton(danger);
|
||||||
context?.setContent(message);
|
context?.setContent(message);
|
||||||
context?.setConfirm(() => async () => {
|
context?.setConfirm(() => async () => {
|
||||||
await callback();
|
await callback();
|
||||||
|
|
|
@ -285,3 +285,10 @@ export const clusterConfigPath = (
|
||||||
|
|
||||||
const clusterNewConfigRelativePath = 'create-new-cluster';
|
const clusterNewConfigRelativePath = 'create-new-cluster';
|
||||||
export const clusterNewConfigPath = `/ui/clusters/${clusterNewConfigRelativePath}`;
|
export const clusterNewConfigPath = `/ui/clusters/${clusterNewConfigRelativePath}`;
|
||||||
|
|
||||||
|
// ACL
|
||||||
|
export const clusterAclRelativePath = 'acl';
|
||||||
|
export const clusterAclNewRelativePath = 'create-new-acl';
|
||||||
|
export const clusterACLPath = (
|
||||||
|
clusterName: ClusterName = RouteParams.clusterName
|
||||||
|
) => `${clusterPath(clusterName)}/${clusterAclRelativePath}`;
|
||||||
|
|
|
@ -31,6 +31,7 @@ const Colors = {
|
||||||
'15': '#C2F0D1',
|
'15': '#C2F0D1',
|
||||||
'30': '#85E0A3',
|
'30': '#85E0A3',
|
||||||
'40': '#5CD685',
|
'40': '#5CD685',
|
||||||
|
'50': '#33CC66',
|
||||||
'60': '#29A352',
|
'60': '#29A352',
|
||||||
},
|
},
|
||||||
brand: {
|
brand: {
|
||||||
|
@ -231,6 +232,7 @@ const baseTheme = {
|
||||||
white: Colors.neutral[10],
|
white: Colors.neutral[10],
|
||||||
red: Colors.red[10],
|
red: Colors.red[10],
|
||||||
blue: Colors.blue[10],
|
blue: Colors.blue[10],
|
||||||
|
secondary: Colors.neutral[15],
|
||||||
},
|
},
|
||||||
color: Colors.neutral[90],
|
color: Colors.neutral[90],
|
||||||
},
|
},
|
||||||
|
@ -416,8 +418,8 @@ export const theme = {
|
||||||
disabled: Colors.red[20],
|
disabled: Colors.red[20],
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
normal: Colors.neutral[90],
|
normal: Colors.neutral[0],
|
||||||
disabled: Colors.neutral[30],
|
disabled: Colors.neutral[0],
|
||||||
},
|
},
|
||||||
invertedColors: {
|
invertedColors: {
|
||||||
normal: Colors.brand[50],
|
normal: Colors.brand[50],
|
||||||
|
@ -695,6 +697,44 @@ export const theme = {
|
||||||
textColor: Colors.brand[50],
|
textColor: Colors.brand[50],
|
||||||
deleteIconColor: Colors.brand[50],
|
deleteIconColor: Colors.brand[50],
|
||||||
},
|
},
|
||||||
|
acl: {
|
||||||
|
table: {
|
||||||
|
deleteIcon: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
radioButtons: {
|
||||||
|
green: {
|
||||||
|
normal: {
|
||||||
|
background: Colors.neutral[0],
|
||||||
|
text: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
active: {
|
||||||
|
background: Colors.green[50],
|
||||||
|
text: Colors.neutral[0],
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
background: Colors.green[10],
|
||||||
|
text: Colors.neutral[90],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gray: {
|
||||||
|
normal: {
|
||||||
|
background: Colors.neutral[0],
|
||||||
|
text: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
active: {
|
||||||
|
background: Colors.neutral[10],
|
||||||
|
text: Colors.neutral[90],
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
background: Colors.neutral[5],
|
||||||
|
text: Colors.neutral[90],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
red: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ThemeType = typeof theme;
|
export type ThemeType = typeof theme;
|
||||||
|
@ -818,8 +858,8 @@ export const darkTheme: ThemeType = {
|
||||||
disabled: Colors.red[20],
|
disabled: Colors.red[20],
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
normal: Colors.neutral[90],
|
normal: Colors.neutral[0],
|
||||||
disabled: Colors.neutral[30],
|
disabled: Colors.neutral[0],
|
||||||
},
|
},
|
||||||
invertedColors: {
|
invertedColors: {
|
||||||
normal: Colors.brand[50],
|
normal: Colors.brand[50],
|
||||||
|
@ -1155,4 +1195,42 @@ export const darkTheme: ThemeType = {
|
||||||
color: Colors.neutral[0],
|
color: Colors.neutral[0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
acl: {
|
||||||
|
table: {
|
||||||
|
deleteIcon: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
radioButtons: {
|
||||||
|
green: {
|
||||||
|
normal: {
|
||||||
|
background: Colors.neutral[0],
|
||||||
|
text: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
active: {
|
||||||
|
background: Colors.green[50],
|
||||||
|
text: Colors.neutral[0],
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
background: Colors.green[10],
|
||||||
|
text: Colors.neutral[0],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gray: {
|
||||||
|
normal: {
|
||||||
|
background: Colors.neutral[0],
|
||||||
|
text: Colors.neutral[50],
|
||||||
|
},
|
||||||
|
active: {
|
||||||
|
background: Colors.neutral[10],
|
||||||
|
text: Colors.neutral[90],
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
background: Colors.neutral[5],
|
||||||
|
text: Colors.neutral[90],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
red: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue