File tree Expand file tree Collapse file tree 2 files changed +35
-24
lines changed
frontend/src/components/Connect/Details/Topics Expand file tree Collapse file tree 2 files changed +35
-24
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import useAppParams from 'lib/hooks/useAppParams' ;
3- import {
4- clusterTopicPath ,
5- RouterParamsClusterConnectConnector ,
6- } from 'lib/paths' ;
3+ import { RouterParamsClusterConnectConnector } from 'lib/paths' ;
74import { useConnector } from 'lib/hooks/api/kafkaConnect' ;
85import Table from 'components/common/NewTable' ;
96import { ColumnDef } from '@tanstack/react-table' ;
10- import { Link } from 'react-router-dom' ;
11- import { TableKeyLink } from 'components/common/table/Table/TableKeyLink.styled' ;
7+
8+ import { TopicNameCell } from './cells/TopicNameCell' ;
9+
10+ const columns : ColumnDef < { topicName : string } > [ ] = [
11+ {
12+ header : 'Topic' ,
13+ accessorKey : 'topicName' ,
14+ cell : TopicNameCell ,
15+ } ,
16+ ] ;
1217
1318const Topics = ( ) => {
1419 const routerProps = useAppParams < RouterParamsClusterConnectConnector > ( ) ;
@@ -17,24 +22,6 @@ const Topics = () => {
1722
1823 const connector = { ...raw , topics : [ 'wikimedia.recentchange.connect' ] } ;
1924
20- const columns : ColumnDef < { topicName : string } > [ ] = [
21- {
22- header : 'Topic' ,
23- accessorKey : 'topicName' ,
24- cell : ( { getValue } ) => {
25- const topicName = getValue < string > ( ) ;
26-
27- return (
28- < TableKeyLink >
29- < Link to = { clusterTopicPath ( routerProps . clusterName , topicName ) } >
30- { topicName }
31- </ Link >
32- </ TableKeyLink >
33- ) ;
34- } ,
35- } ,
36- ] ;
37-
3825 const tableData = ( connector ?. topics ?? [ ] ) . map ( ( topicName ) => ( {
3926 topicName,
4027 } ) ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import useAppParams from 'lib/hooks/useAppParams' ;
3+ import {
4+ clusterTopicPath ,
5+ RouterParamsClusterConnectConnector ,
6+ } from 'lib/paths' ;
7+ import { CellContext } from '@tanstack/react-table' ;
8+ import { TableKeyLink } from 'components/common/table/Table/TableKeyLink.styled' ;
9+ import { Link } from 'react-router-dom' ;
10+
11+ type TopicNameCellProps = CellContext < { topicName : string } , unknown > ;
12+
13+ export const TopicNameCell = ( { getValue } : TopicNameCellProps ) => {
14+ const routerProps = useAppParams < RouterParamsClusterConnectConnector > ( ) ;
15+ const topicName = getValue < string > ( ) ;
16+
17+ return (
18+ < TableKeyLink >
19+ < Link to = { clusterTopicPath ( routerProps . clusterName , topicName ) } >
20+ { topicName }
21+ </ Link >
22+ </ TableKeyLink >
23+ ) ;
24+ } ;
You can’t perform that action at this time.
0 commit comments