Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
25 changes: 25 additions & 0 deletions frontend/src/components/Connect/List/KafkaConnectLinkCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { LinkCell } from 'components/common/NewTable';
import useAppParams from 'lib/hooks/useAppParams';
import { clusterConnectConnectorPath, ClusterNameRoute } from 'lib/paths';
import { CellContext } from '@tanstack/react-table';
import { FullConnectorInfo } from 'generated-sources';

type KafkaConnectLinkCellProps = CellContext<FullConnectorInfo, string>;

export const KafkaConnectLinkCell = ({
getValue,
row,
}: KafkaConnectLinkCellProps) => {
const { clusterName } = useAppParams<ClusterNameRoute>();
const { connect, name } = row.original;
const value = getValue();

return (
<LinkCell
value={value}
to={clusterConnectConnectorPath(clusterName, connect, name)}
wordBreak
/>
);
};
19 changes: 8 additions & 11 deletions frontend/src/components/Connect/List/List.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React from 'react';
import useAppParams from 'lib/hooks/useAppParams';
import { clusterConnectConnectorPath, ClusterNameRoute } from 'lib/paths';
import { ClusterNameRoute } from 'lib/paths';
import Table, { TagCell } from 'components/common/NewTable';
import { FullConnectorInfo } from 'generated-sources';
import { useConnectors } from 'lib/hooks/api/kafkaConnect';
import { ColumnDef } from '@tanstack/react-table';
import { useNavigate, useSearchParams } from 'react-router-dom';
import BreakableTextCell from 'components/common/NewTable/BreakableTextCell';
import { useSearchParams } from 'react-router-dom';
import { useQueryPersister } from 'components/common/NewTable/ColumnFilter';
import { useLocalStoragePersister } from 'components/common/NewTable/ColumnResizer/lib';

import ActionsCell from './ActionsCell';
import TopicsCell from './TopicsCell';
import RunningTasksCell from './RunningTasksCell';
import { KafkaConnectLinkCell } from './KafkaConnectLinkCell';

const kafkaConnectColumns: ColumnDef<FullConnectorInfo>[] = [
const kafkaConnectColumns: ColumnDef<FullConnectorInfo, string>[] = [
{
header: 'Name',
accessorKey: 'name',
cell: BreakableTextCell,
cell: KafkaConnectLinkCell,
enableResizing: true,
},
{
header: 'Connect',
accessorKey: 'connect',
cell: BreakableTextCell,
cell: KafkaConnectLinkCell,
filterFn: 'arrIncludesSome',
meta: {
filterVariant: 'multi-select',
Expand All @@ -34,14 +34,15 @@ const kafkaConnectColumns: ColumnDef<FullConnectorInfo>[] = [
{
header: 'Type',
accessorKey: 'type',
cell: KafkaConnectLinkCell,
meta: { filterVariant: 'multi-select' },
filterFn: 'arrIncludesSome',
size: 120,
},
{
header: 'Plugin',
accessorKey: 'connectorClass',
cell: BreakableTextCell,
cell: KafkaConnectLinkCell,
meta: { filterVariant: 'multi-select' },
filterFn: 'arrIncludesSome',
enableResizing: true,
Expand Down Expand Up @@ -77,7 +78,6 @@ const kafkaConnectColumns: ColumnDef<FullConnectorInfo>[] = [
];

const List: React.FC = () => {
const navigate = useNavigate();
const { clusterName } = useAppParams<ClusterNameRoute>();
const [searchParams] = useSearchParams();
const { data: connectors } = useConnectors(
Expand All @@ -95,9 +95,6 @@ const List: React.FC = () => {
enableSorting
enableColumnResizing
columnSizingPersister={columnSizingPersister}
onRowClick={({ original: { connect, name } }) =>
navigate(clusterConnectConnectorPath(clusterName, connect, name))
}
emptyMessage="No connectors found"
setRowId={(originalRow) => `${originalRow.name}-${originalRow.connect}`}
filterPersister={filterPersister}
Expand Down
41 changes: 30 additions & 11 deletions frontend/src/components/Connect/List/__tests__/List.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,37 @@ describe('Connectors List', () => {

it('opens broker when row clicked', async () => {
renderComponent();
await userEvent.click(
screen.getByRole('row', {
name: 'hdfs-source-connector first SOURCE FileStreamSource a b c RUNNING 2 of 2',
})
screen.debug();
expect(screen.getByText('hdfs-source-connector')).toHaveAttribute(
'href',
clusterConnectConnectorPath(
clusterName,
'first',
'hdfs-source-connector'
)
);
expect(screen.getByText('first')).toHaveAttribute(
'href',
clusterConnectConnectorPath(
clusterName,
'first',
'hdfs-source-connector'
)
);
expect(screen.getByText('SOURCE')).toHaveAttribute(
'href',
clusterConnectConnectorPath(
clusterName,
'first',
'hdfs-source-connector'
)
);
await waitFor(() =>
expect(mockedUsedNavigate).toBeCalledWith(
clusterConnectConnectorPath(
clusterName,
'first',
'hdfs-source-connector'
)
expect(screen.getAllByText('FileStreamSource')[0]).toHaveAttribute(
'href',
clusterConnectConnectorPath(
clusterName,
'first',
'hdfs-source-connector'
)
);
});
Expand Down
Loading