Skip to content

Commit 8b5494b

Browse files
UX: Open KC connectors in a separate tab (#1165)
Co-authored-by: German Osin <[email protected]>
1 parent 76164a6 commit 8b5494b

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { LinkCell } from 'components/common/NewTable';
3+
import useAppParams from 'lib/hooks/useAppParams';
4+
import { clusterConnectConnectorPath, ClusterNameRoute } from 'lib/paths';
5+
import { CellContext } from '@tanstack/react-table';
6+
import { FullConnectorInfo } from 'generated-sources';
7+
8+
type KafkaConnectLinkCellProps = CellContext<FullConnectorInfo, string>;
9+
10+
export const KafkaConnectLinkCell = ({
11+
getValue,
12+
row,
13+
}: KafkaConnectLinkCellProps) => {
14+
const { clusterName } = useAppParams<ClusterNameRoute>();
15+
const { connect, name } = row.original;
16+
const value = getValue();
17+
18+
return (
19+
<LinkCell
20+
value={value}
21+
to={clusterConnectConnectorPath(clusterName, connect, name)}
22+
wordBreak
23+
/>
24+
);
25+
};

frontend/src/components/Connect/List/List.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import React from 'react';
22
import useAppParams from 'lib/hooks/useAppParams';
3-
import { clusterConnectConnectorPath, ClusterNameRoute } from 'lib/paths';
3+
import { ClusterNameRoute } from 'lib/paths';
44
import Table, { TagCell } from 'components/common/NewTable';
55
import { FullConnectorInfo } from 'generated-sources';
66
import { useConnectors } from 'lib/hooks/api/kafkaConnect';
77
import { ColumnDef } from '@tanstack/react-table';
8-
import { useNavigate, useSearchParams } from 'react-router-dom';
9-
import BreakableTextCell from 'components/common/NewTable/BreakableTextCell';
8+
import { useSearchParams } from 'react-router-dom';
109
import { useQueryPersister } from 'components/common/NewTable/ColumnFilter';
1110
import { useLocalStoragePersister } from 'components/common/NewTable/ColumnResizer/lib';
11+
import BreakableTextCell from 'components/common/NewTable/BreakableTextCell';
1212

1313
import ActionsCell from './ActionsCell';
1414
import TopicsCell from './TopicsCell';
1515
import RunningTasksCell from './RunningTasksCell';
16+
import { KafkaConnectLinkCell } from './KafkaConnectLinkCell';
1617

17-
const kafkaConnectColumns: ColumnDef<FullConnectorInfo>[] = [
18+
const kafkaConnectColumns: ColumnDef<FullConnectorInfo, string>[] = [
1819
{
1920
header: 'Name',
2021
accessorKey: 'name',
21-
cell: BreakableTextCell,
22+
cell: KafkaConnectLinkCell,
2223
enableResizing: true,
2324
},
2425
{
@@ -77,7 +78,6 @@ const kafkaConnectColumns: ColumnDef<FullConnectorInfo>[] = [
7778
];
7879

7980
const List: React.FC = () => {
80-
const navigate = useNavigate();
8181
const { clusterName } = useAppParams<ClusterNameRoute>();
8282
const [searchParams] = useSearchParams();
8383
const { data: connectors } = useConnectors(
@@ -95,9 +95,6 @@ const List: React.FC = () => {
9595
enableSorting
9696
enableColumnResizing
9797
columnSizingPersister={columnSizingPersister}
98-
onRowClick={({ original: { connect, name } }) =>
99-
navigate(clusterConnectConnectorPath(clusterName, connect, name))
100-
}
10198
emptyMessage="No connectors found"
10299
setRowId={(originalRow) => `${originalRow.name}-${originalRow.connect}`}
103100
filterPersister={filterPersister}

frontend/src/components/Connect/List/__tests__/List.spec.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,13 @@ describe('Connectors List', () => {
6464

6565
it('opens broker when row clicked', async () => {
6666
renderComponent();
67-
await userEvent.click(
68-
screen.getByRole('row', {
69-
name: 'hdfs-source-connector first SOURCE FileStreamSource a b c RUNNING 2 of 2',
70-
})
71-
);
72-
await waitFor(() =>
73-
expect(mockedUsedNavigate).toBeCalledWith(
74-
clusterConnectConnectorPath(
75-
clusterName,
76-
'first',
77-
'hdfs-source-connector'
78-
)
67+
screen.debug();
68+
expect(screen.getByText('hdfs-source-connector')).toHaveAttribute(
69+
'href',
70+
clusterConnectConnectorPath(
71+
clusterName,
72+
'first',
73+
'hdfs-source-connector'
7974
)
8075
);
8176
});

0 commit comments

Comments
 (0)