|
1 | 1 | import _ from 'lodash'; |
2 | | -import React from 'react'; |
| 2 | +import React, { useState } from 'react'; |
3 | 3 | import ReactTooltip from 'react-tooltip'; |
4 | 4 | import { iconColors, iconSizes, ID_MAX_LENGTH } from '../../../../../constants'; |
5 | 5 | import { |
@@ -43,6 +43,9 @@ export const GetHeaderCols = ({ |
43 | 43 | filteredConnectors, |
44 | 44 | }); |
45 | 45 |
|
| 46 | + const [showResourceTypes, setShowResourceTypes] = useState(false); |
| 47 | + const [connectorId, setConnectorId] = useState(''); |
| 48 | + |
46 | 49 | return [ |
47 | 50 | // { |
48 | 51 | // width: '3%', |
@@ -236,25 +239,90 @@ export const GetHeaderCols = ({ |
236 | 239 | renderRow: (connector: any) => { |
237 | 240 | return ( |
238 | 241 | <FlexBox alignItems="center"> |
239 | | - {connector?.connectorType?.resource_types?.map((e: any) => ( |
240 | | - <Box marginLeft="sm"> |
241 | | - <div data-tip data-for={e?.name}> |
242 | | - <FlexBox alignItems="center"> |
243 | | - <img |
244 | | - alt={e?.logo_url} |
245 | | - src={e?.logo_url} |
246 | | - style={{ |
247 | | - height: '28px', |
248 | | - width: '28px', |
249 | | - }} |
250 | | - /> |
| 242 | + {connector?.connectorType?.resource_types |
| 243 | + ?.slice(0, 2) |
| 244 | + ?.map((e: any, index: number) => ( |
| 245 | + <Box marginLeft={index !== 0 ? 'sm' : null}> |
| 246 | + <div data-tip data-for={e?.name}> |
| 247 | + <FlexBox alignItems="center"> |
| 248 | + <img |
| 249 | + alt={e?.logo_url} |
| 250 | + src={e?.logo_url} |
| 251 | + style={{ |
| 252 | + height: '28px', |
| 253 | + width: '28px', |
| 254 | + }} |
| 255 | + /> |
| 256 | + </FlexBox> |
| 257 | + </div> |
| 258 | + <ReactTooltip id={e?.name} place="top" effect="solid"> |
| 259 | + <Paragraph color="white">{e?.name}</Paragraph> |
| 260 | + </ReactTooltip> |
| 261 | + </Box> |
| 262 | + ))} |
| 263 | + |
| 264 | + {connector?.connectorType?.resource_types?.length > 2 && ( |
| 265 | + <Box marginLeft="sm" onClick={(e) => e.stopPropagation()}> |
| 266 | + <FlexBox |
| 267 | + alignItems="center" |
| 268 | + justifyContent="center" |
| 269 | + onClick={() => { |
| 270 | + setShowResourceTypes(!showResourceTypes); |
| 271 | + setConnectorId(connector?.id); |
| 272 | + }} |
| 273 | + style={{ |
| 274 | + height: '28px', |
| 275 | + width: '28px', |
| 276 | + border: '1.5px solid #424240', |
| 277 | + borderRadius: '100%', |
| 278 | + cursor: 'pointer', |
| 279 | + }} |
| 280 | + > |
| 281 | + <Paragraph> |
| 282 | + +{connector?.connectorType?.resource_types?.length - 2} |
| 283 | + </Paragraph> |
| 284 | + </FlexBox> |
| 285 | + |
| 286 | + {showResourceTypes && connectorId === connector?.id && ( |
| 287 | + <FlexBox |
| 288 | + padding="sm" |
| 289 | + alignItems="center" |
| 290 | + justifyContent="center" |
| 291 | + style={{ |
| 292 | + marginTop: '5px', |
| 293 | + backgroundColor: '#fff', |
| 294 | + position: 'absolute', |
| 295 | + border: '1px solid #e9eaec', |
| 296 | + borderRadius: '4px', |
| 297 | + boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.05)', |
| 298 | + zIndex: 100, |
| 299 | + }} |
| 300 | + > |
| 301 | + {connector?.connectorType?.resource_types |
| 302 | + ?.slice(2) |
| 303 | + ?.map((e: any, index: number) => ( |
| 304 | + <Box marginLeft={index !== 0 ? 'sm' : null}> |
| 305 | + <div data-tip data-for={e?.name}> |
| 306 | + <FlexBox alignItems="center"> |
| 307 | + <img |
| 308 | + alt={e?.logo_url} |
| 309 | + src={e?.logo_url} |
| 310 | + style={{ |
| 311 | + height: '28px', |
| 312 | + width: '28px', |
| 313 | + }} |
| 314 | + /> |
| 315 | + </FlexBox> |
| 316 | + </div> |
| 317 | + <ReactTooltip id={e?.name} place="top" effect="solid"> |
| 318 | + <Paragraph color="white">{e?.name}</Paragraph> |
| 319 | + </ReactTooltip> |
| 320 | + </Box> |
| 321 | + ))} |
251 | 322 | </FlexBox> |
252 | | - </div> |
253 | | - <ReactTooltip id={e?.name} place="top" effect="solid"> |
254 | | - <Paragraph color="white">{e?.name}</Paragraph> |
255 | | - </ReactTooltip> |
| 323 | + )} |
256 | 324 | </Box> |
257 | | - ))} |
| 325 | + )} |
258 | 326 | </FlexBox> |
259 | 327 | ); |
260 | 328 | }, |
|
0 commit comments