diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.module.scss b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.module.scss index 71b885413fb9b..07287bff95d8c 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.module.scss +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.module.scss @@ -6,9 +6,13 @@ $large: 200px; .tableCell { flex: 1 0 $medium; min-width: $medium; - word-break: break-word; - overflow: hidden; - text-overflow: ellipsis; + + [data-type="text"] { + word-break: break-word; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } &.xsmall { flex-basis: $xsmall; @@ -25,3 +29,7 @@ $large: 200px; min-width: $large; } } + +.noEllipsis > * { + overflow: visible; +} diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.tsx index 6f31b7e59a389..82287e3ef5a54 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.tsx @@ -1,5 +1,8 @@ import classNames from "classnames"; -import React from "react"; +import React, { useCallback, useEffect, useRef, useState } from "react"; +import { useWindowSize } from "react-use"; + +import { Tooltip } from "components/ui/Tooltip"; import styles from "./CatalogTreeTableCell.module.scss"; @@ -8,6 +11,7 @@ type Sizes = "xsmall" | "small" | "medium" | "large"; interface CatalogTreeTableCellProps { size?: Sizes; className?: string; + withTooltip?: boolean; } // This lets us avoid the eslint complaint about unused styles @@ -18,10 +22,63 @@ const sizeMap: Record = { large: styles.large, }; +const TooltipText: React.FC<{ textNodes: Element[] }> = ({ textNodes }) => { + if (!textNodes.length) { + return null; + } + const text = textNodes.map((t) => decodeURIComponent(t.innerHTML)).join(" | "); + return
; +}; + export const CatalogTreeTableCell: React.FC> = ({ size = "medium", + withTooltip, className, children, }) => { - return
{children}
; + const [tooltipDisabled, setTooltipDisabled] = useState(true); + const [textNodes, setTextNodes] = useState([]); + const cell = useRef(null); + + const { width: windowWidth } = useWindowSize(); + + const getTextNodes = useCallback(() => { + if (withTooltip && cell.current) { + setTextNodes(Array.from(cell.current.querySelectorAll(`[data-type="text"]`))); + } + }, [withTooltip]); + + useEffect(() => { + // windowWidth is only here so this functionality changes based on window width + if (textNodes.length && windowWidth) { + const [scrollWidths, clientWidths] = textNodes.reduce( + ([scrollWidths, clientWidths], textNode) => { + if (textNode) { + scrollWidths += textNode.scrollWidth; + clientWidths += textNode.clientWidth; + } + return [scrollWidths, clientWidths]; + }, + [0, 0] + ); + + if (scrollWidths > clientWidths) { + setTooltipDisabled(false); + } else { + setTooltipDisabled(true); + } + } + }, [textNodes, windowWidth]); + + return ( +
+ {withTooltip ? ( + + + + ) : ( + children + )} +
+ ); }; diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx index 1c374fc1ced17..ddc04cc9ec981 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableRow.tsx @@ -67,17 +67,17 @@ export const CatalogTreeTableRow: React.FC = ({ {/* {fieldCount} */} - + {stream.stream?.namespace || } - + {stream.stream?.name} - + {disabled ? ( {syncSchema.syncMode} @@ -104,7 +104,7 @@ export const CatalogTreeTableRow: React.FC = ({ /> )} - + {pkType && ( = ({ - + {destNamespace} - + {destName} diff --git a/airbyte-webapp/src/components/connection/CatalogTree/next/__snapshots__/BulkEditPanel.test.tsx.snap b/airbyte-webapp/src/components/connection/CatalogTree/next/__snapshots__/BulkEditPanel.test.tsx.snap index b54ec16eacb42..255c798a153ad 100644 --- a/airbyte-webapp/src/components/connection/CatalogTree/next/__snapshots__/BulkEditPanel.test.tsx.snap +++ b/airbyte-webapp/src/components/connection/CatalogTree/next/__snapshots__/BulkEditPanel.test.tsx.snap @@ -84,6 +84,7 @@ exports[` should render 1`] = ` >
should render 1`] = ` > Not available @@ -210,6 +212,7 @@ exports[` should render 1`] = ` > Not available diff --git a/airbyte-webapp/src/components/connection/ConnectionForm/__snapshots__/SchemaChangesBackdrop.test.tsx.snap b/airbyte-webapp/src/components/connection/ConnectionForm/__snapshots__/SchemaChangesBackdrop.test.tsx.snap index 7cf429a873fc6..2e72e4c9cfa38 100644 --- a/airbyte-webapp/src/components/connection/ConnectionForm/__snapshots__/SchemaChangesBackdrop.test.tsx.snap +++ b/airbyte-webapp/src/components/connection/ConnectionForm/__snapshots__/SchemaChangesBackdrop.test.tsx.snap @@ -84,6 +84,7 @@ exports[`SchemaChangesBackdrop renders if there are non-breaking changes and pre

Please review the schema updates before making changes to the connection

@@ -181,6 +182,7 @@ exports[`SchemaChangesBackdrop renders with breaking changes and prevents backgr

Please review the schema updates before making changes to the connection

diff --git a/airbyte-webapp/src/components/connection/CreateConnectionForm/__snapshots__/CreateConnectionForm.test.tsx.snap b/airbyte-webapp/src/components/connection/CreateConnectionForm/__snapshots__/CreateConnectionForm.test.tsx.snap index a23179b461860..b3ab2efbb873a 100644 --- a/airbyte-webapp/src/components/connection/CreateConnectionForm/__snapshots__/CreateConnectionForm.test.tsx.snap +++ b/airbyte-webapp/src/components/connection/CreateConnectionForm/__snapshots__/CreateConnectionForm.test.tsx.snap @@ -392,6 +392,7 @@ exports[`CreateConnectionForm should render 1`] = `

Optional

@@ -1072,11 +1073,13 @@ exports[`CreateConnectionForm should render with an error 1`] = `

Failed to fetch schema. Please try again

Error: Test Error

diff --git a/airbyte-webapp/src/components/ui/Text/Text.tsx b/airbyte-webapp/src/components/ui/Text/Text.tsx index 2290ee5f083a4..763356fcdf28d 100644 --- a/airbyte-webapp/src/components/ui/Text/Text.tsx +++ b/airbyte-webapp/src/components/ui/Text/Text.tsx @@ -50,6 +50,7 @@ export const Text: React.FC> = React.memo( return React.createElement(as, { ...remainingProps, + "data-type": "text", className, children, }); diff --git a/airbyte-webapp/src/components/ui/Tooltip/Tooltip.tsx b/airbyte-webapp/src/components/ui/Tooltip/Tooltip.tsx index c2ae41260d6cd..41a48b896f1c0 100644 --- a/airbyte-webapp/src/components/ui/Tooltip/Tooltip.tsx +++ b/airbyte-webapp/src/components/ui/Tooltip/Tooltip.tsx @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/mouse-events-have-key-events */ import { autoUpdate, flip, offset, shift, useFloating, UseFloatingProps } from "@floating-ui/react-dom"; import classNames from "classnames"; -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useMemo } from "react"; import { createPortal } from "react-dom"; import { tooltipContext } from "./context"; @@ -54,7 +54,7 @@ export const Tooltip: React.FC> = (props) }; }, [isMouseOver]); - const canShowTooltip = isVisible && !disabled; + const canShowTooltip = useMemo(() => isVisible && !disabled, [disabled, isVisible]); const onMouseOver = () => { setIsMouseOver(true); @@ -75,8 +75,8 @@ export const Tooltip: React.FC> = (props) > {control} - {canShowTooltip && - createPortal( + {createPortal( + canShowTooltip ? (
> = (props) onMouseOut={onMouseOut} > {children} -
, - document.body - )} + + ) : null, + document.body + )} ); }; diff --git a/airbyte-webapp/src/pages/connections/ConnectionReplicationPage/__snapshots__/ConnectionReplicationPage.test.tsx.snap b/airbyte-webapp/src/pages/connections/ConnectionReplicationPage/__snapshots__/ConnectionReplicationPage.test.tsx.snap index 685a07a2f217a..e9b785ce8af52 100644 --- a/airbyte-webapp/src/pages/connections/ConnectionReplicationPage/__snapshots__/ConnectionReplicationPage.test.tsx.snap +++ b/airbyte-webapp/src/pages/connections/ConnectionReplicationPage/__snapshots__/ConnectionReplicationPage.test.tsx.snap @@ -323,6 +323,7 @@ exports[`ConnectionReplicationPage should render 1`] = `

Optional

@@ -883,6 +884,7 @@ exports[`ConnectionReplicationPage should show an error if there is a schemaErro

Failed to fetch schema. Please try again

diff --git a/airbyte-webapp/src/views/Connector/ConnectorForm/components/FrequentlyUsedConnectors/__snapshots__/FrequentlyUsedConnectorsCard.test.tsx.snap b/airbyte-webapp/src/views/Connector/ConnectorForm/components/FrequentlyUsedConnectors/__snapshots__/FrequentlyUsedConnectorsCard.test.tsx.snap index 1233916b162d2..970d2ef7d5569 100644 --- a/airbyte-webapp/src/views/Connector/ConnectorForm/components/FrequentlyUsedConnectors/__snapshots__/FrequentlyUsedConnectorsCard.test.tsx.snap +++ b/airbyte-webapp/src/views/Connector/ConnectorForm/components/FrequentlyUsedConnectors/__snapshots__/FrequentlyUsedConnectorsCard.test.tsx.snap @@ -14,6 +14,7 @@ exports[` should renders with mock data without >

Most frequently used destinations