11// Libraries
22import React , { CSSProperties , FC , Suspense } from 'react'
3- import { useSelector } from 'react-redux'
4- import { useHistory } from 'react-router-dom'
53
64// Components
75import { SelectableCard , SquareGrid , ComponentSize } from '@influxdata/clockface'
86const LazySVG = React . lazy ( ( ) => import ( 'src/perf/components/LazySVG' ) )
97
10- // Utils
11- import { getOrg } from 'src/organizations/selectors'
12- import { event } from 'src/cloud/utils/reporting'
13-
148// Graphics
159import placeholderLogo from 'src/writeData/graphics/placeholderLogo.svg'
1610
17- // Constants
18- import { ORGS } from 'src/shared/constants/routes'
19-
2011// Styles
2112import 'src/writeData/components/WriteDataItem.scss'
2213
2314interface Props {
2415 id : string
2516 name : string
26- url : string
2717 image ?: string
2818 style ?: CSSProperties
2919 selected ?: boolean
30- onClick ? : any
20+ onClick : any
3121 testID ?: string
3222}
3323
3424const WriteDataItem : FC < Props > = ( {
3525 id,
3626 name,
37- url,
3827 image,
3928 style,
4029 selected,
4130 onClick,
4231 testID,
4332} ) => {
44- const history = useHistory ( )
45- const org = useSelector ( getOrg )
46-
47- const handleClick = ( ) : void => {
48- event ( `sources.load_data.${ name } .clicked` )
49- history . push ( `/${ ORGS } /${ org . id } /load-data/${ url } ` )
50- }
51-
5233 let thumb = < img src = { placeholderLogo } />
5334 const svgStyle = style ? style : ( { } as CSSProperties )
5435
@@ -60,34 +41,15 @@ const WriteDataItem: FC<Props> = ({
6041 )
6142 }
6243
63- if ( onClick ) {
64- return (
65- < SquareGrid . Card key = { id } >
66- < SelectableCard
67- id = { id }
68- formName = "load-data-cards"
69- label = { name }
70- selected = { selected }
71- onClick = { onClick }
72- testID = { testID }
73- fontSize = { ComponentSize . ExtraSmall }
74- className = "write-data--item"
75- >
76- < div className = "write-data--item-thumb" > { thumb } </ div >
77- </ SelectableCard >
78- </ SquareGrid . Card >
79- )
80- }
81-
8244 return (
8345 < SquareGrid . Card key = { id } >
8446 < SelectableCard
8547 id = { id }
8648 formName = "load-data-cards"
8749 label = { name }
88- testID = { `load-data-item ${ id } ` }
89- selected = { false }
90- onClick = { handleClick }
50+ selected = { selected }
51+ onClick = { onClick }
52+ testID = { testID || `load-data-item ${ id } ` }
9153 fontSize = { ComponentSize . ExtraSmall }
9254 className = "write-data--item"
9355 >
0 commit comments