Skip to content

Commit 045323d

Browse files
authored
New Streams Table Column Sizing Fix (#20141)
* Better flex handling * flex scaling off * flex! * Added comment * Cleanup Cell props * Re-adding the padding for most use cases. This "fixes" the old table. * Fixing bold table header * Move scrolling to the correct level * Further styling fixes * Everything is working * Added new table cell so we don't use the old one * cleanup * Everything is working on the new table??? * Fixing header * Snapshots * Consolidate checkbox styles * Cleanup * Fixing old table * Don't want padding on new table * Overflow and padding changes
1 parent 23a1110 commit 045323d

18 files changed

+483
-427
lines changed

airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap

Lines changed: 143 additions & 143 deletions
Large diffs are not rendered by default.

airbyte-webapp/src/components/SimpleTableComponents/SimpleTableComponents.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ export const Header = styled(Row)`
2525
export const Cell = styled.div<{
2626
flex?: number;
2727
light?: boolean;
28-
lighter?: boolean;
2928
ellipsis?: boolean;
3029
flush?: boolean;
3130
}>`
3231
flex: ${({ flex }) => (flex !== undefined ? flex : 1)} 0 0;
3332
padding-right: ${({ flush }) => (flush ? 0 : 10)}px;
3433
word-break: break-word;
35-
color: ${({ theme, light, lighter }) => (light ? theme.greyColor40 : lighter ? theme.greyColor60 : "inherit")};
36-
font-weight: ${({ light, lighter }) => (light || lighter ? "normal" : "inherit")};
34+
color: ${({ theme, light }) => (light ? theme.greyColor60 : "inherit")};
35+
font-weight: ${({ light }) => (light ? "normal" : "inherit")};
3736
3837
overflow: ${({ ellipsis }) => (ellipsis ? "hidden" : "inherit")};
3938
text-overflow: ${({ ellipsis }) => (ellipsis ? "ellipsis" : "inherit")};

airbyte-webapp/src/components/connection/CatalogTree/CatalogTree.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22

33
.catalogTreeTable {
44
padding: variables.$spacing-lg variables.$spacing-xl 0;
5+
overflow: auto;
6+
border-radius: 10px;
7+
margin-bottom: 29px;
8+
9+
&.newCatalogTreeTable {
10+
padding: 0;
11+
}
512
}

airbyte-webapp/src/components/connection/CatalogTree/CatalogTree.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import classNames from "classnames";
12
import React, { useCallback, useMemo, useState } from "react";
23

34
import { LoadingBackdrop } from "components/ui/LoadingBackdrop";
@@ -7,15 +8,10 @@ import { BulkEditServiceProvider } from "hooks/services/BulkEdit/BulkEditService
78
import { useConnectionFormService } from "hooks/services/ConnectionForm/ConnectionFormService";
89
import { naturalComparatorBy } from "utils/objects";
910

10-
import { BulkHeader } from "./BulkHeader";
1111
import styles from "./CatalogTree.module.scss";
1212
import { CatalogTreeBody } from "./CatalogTreeBody";
13-
import { CatalogTreeHeader } from "./CatalogTreeHeader";
1413
import { CatalogTreeSearch } from "./CatalogTreeSearch";
15-
import { CatalogTreeSubheader } from "./CatalogTreeSubheader";
1614
import { BulkEditPanel } from "./next/BulkEditPanel";
17-
import { CatalogTreeTableHeader } from "./next/CatalogTreeTableHeader";
18-
import { StreamConnectionHeader } from "./next/StreamConnectionHeader";
1915

2016
interface CatalogTreeProps {
2117
streams: SyncSchemaStream[];
@@ -76,19 +72,9 @@ const CatalogTreeComponent: React.FC<React.PropsWithChildren<CatalogTreeProps>>
7672
<BulkEditServiceProvider nodes={streams} update={onStreamsChanged}>
7773
<LoadingBackdrop loading={isLoading}>
7874
{mode !== "readonly" && <CatalogTreeSearch onSearch={setSearchString} />}
79-
<div className={isNewStreamsTableEnabled ? undefined : styles.catalogTreeTable}>
80-
{isNewStreamsTableEnabled ? (
81-
<>
82-
<StreamConnectionHeader />
83-
<CatalogTreeTableHeader />
84-
</>
85-
) : (
86-
<>
87-
<CatalogTreeHeader />
88-
<CatalogTreeSubheader />
89-
<BulkHeader />
90-
</>
91-
)}
75+
<div
76+
className={classNames(styles.catalogTreeTable, { [styles.newCatalogTreeTable]: isNewStreamsTableEnabled })}
77+
>
9278
<CatalogTreeBody
9379
streams={filteredStreams}
9480
changedStreams={changedStreams}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.container {
2-
margin-bottom: 29px;
32
max-height: 600px;
4-
overflow-y: auto;
3+
overflow: unset;
4+
min-width: fit-content;
55

66
--webkit-overlay: true;
7-
8-
width: 100%;
97
}

airbyte-webapp/src/components/connection/CatalogTree/CatalogTreeBody.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import { AirbyteStreamConfiguration } from "core/request/AirbyteClient";
66
import { useConnectionFormService } from "hooks/services/ConnectionForm/ConnectionFormService";
77
import { FormikConnectionFormValues } from "views/Connection/ConnectionForm/formConfig";
88

9+
import { BulkHeader } from "./BulkHeader";
910
import { CatalogSection } from "./CatalogSection";
1011
import styles from "./CatalogTreeBody.module.scss";
12+
import { CatalogTreeHeader } from "./CatalogTreeHeader";
13+
import { CatalogTreeSubheader } from "./CatalogTreeSubheader";
14+
import { CatalogTreeTableHeader } from "./next/CatalogTreeTableHeader";
15+
import { StreamConnectionHeader } from "./next/StreamConnectionHeader";
1116

1217
interface CatalogTreeBodyProps {
1318
streams: SyncSchemaStream[];
1419
changedStreams: SyncSchemaStream[];
1520
onStreamChanged: (stream: SyncSchemaStream) => void;
1621
}
1722

23+
const isNewStreamsTableEnabled = process.env.REACT_APP_NEW_STREAMS_TABLE ?? false;
24+
1825
export const CatalogTreeBody: React.FC<CatalogTreeBodyProps> = ({ streams, changedStreams, onStreamChanged }) => {
1926
const { mode } = useConnectionFormService();
2027

@@ -33,6 +40,18 @@ export const CatalogTreeBody: React.FC<CatalogTreeBodyProps> = ({ streams, chang
3340

3441
return (
3542
<div className={styles.container}>
43+
{isNewStreamsTableEnabled ? (
44+
<>
45+
<StreamConnectionHeader />
46+
<CatalogTreeTableHeader />
47+
</>
48+
) : (
49+
<>
50+
<CatalogTreeHeader />
51+
<CatalogTreeSubheader />
52+
<BulkHeader />
53+
</>
54+
)}
3655
{streams.map((streamNode) => (
3756
<Field key={`schema.streams[${streamNode.id}].config`} name={`schema.streams[${streamNode.id}].config`}>
3857
{({ form }: FieldProps<FormikConnectionFormValues>) => (

airbyte-webapp/src/components/connection/CatalogTree/CatalogTreeHeader.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,36 @@ export const CatalogTreeHeader: React.FC = () => {
3232
</Cell>
3333
)}
3434
{mode !== "readonly" && <Cell flex={0.1} />}
35-
<Cell lighter flex={0.4}>
35+
<Cell light flex={0.4}>
3636
<FormattedMessage id="sources.sync" />
3737
</Cell>
38-
<Cell lighter>
38+
<Cell light>
3939
<FormattedMessage id="sources.source" />
4040
<InfoTooltip>
4141
<FormattedMessage id="connectionForm.source.info" />
4242
</InfoTooltip>
4343
</Cell>
4444
<Cell />
45-
<Cell lighter flex={1.5}>
45+
<Cell light flex={1.5}>
4646
<FormattedMessage id="form.syncMode" />
4747
<InfoTooltip>
4848
<FormattedMessage id="connectionForm.syncType.info" />
4949
<TooltipLearnMoreLink url={links.syncModeLink} />
5050
</InfoTooltip>
5151
</Cell>
52-
<Cell lighter>
52+
<Cell light>
5353
<FormattedMessage id="form.cursorField" />
5454
<InfoTooltip>
5555
<FormattedMessage id="connectionForm.cursor.info" />
5656
</InfoTooltip>
5757
</Cell>
58-
<Cell lighter>
58+
<Cell light>
5959
<FormattedMessage id="form.primaryKey" />
6060
<InfoTooltip>
6161
<FormattedMessage id="connectionForm.primaryKey.info" />
6262
</InfoTooltip>
6363
</Cell>
64-
<Cell lighter>
64+
<Cell light>
6565
<FormattedMessage id="connector.destination" />
6666
<InfoTooltip>
6767
<FormattedMessage id="connectionForm.destinationName.info" />

airbyte-webapp/src/components/connection/CatalogTree/CatalogTreeSubheader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useConnectionFormService } from "hooks/services/ConnectionForm/Connecti
99

1010
import styles from "./CatalogTreeSubheader.module.scss";
1111

12-
const SubtitleCell = styled(Cell).attrs(() => ({ lighter: true }))`
12+
const SubtitleCell = styled(Cell).attrs(() => ({ light: true }))`
1313
font-size: 10px;
1414
line-height: 12px;
1515
border-top: 1px solid ${({ theme }) => theme.greyColor0};

airbyte-webapp/src/components/connection/CatalogTree/FieldHeader.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,34 @@ const FieldHeaderInner: React.FC = () => {
1111
return (
1212
<>
1313
{isColumnSelectionEnabled && (
14-
<HeaderCell lighter flex={0}>
14+
<HeaderCell light flex={0}>
1515
<SyncHeaderContainer>
1616
<FormattedMessage id="form.field.sync" />
1717
</SyncHeaderContainer>
1818
</HeaderCell>
1919
)}
20-
<HeaderCell lighter flex={1.5}>
20+
<HeaderCell light flex={1.5}>
2121
{!isColumnSelectionEnabled && (
2222
<NameContainer>
2323
<FormattedMessage id="form.field.name" />
2424
</NameContainer>
2525
)}
2626
{isColumnSelectionEnabled && <FormattedMessage id="form.field.name" />}
2727
</HeaderCell>
28-
<HeaderCell lighter>
28+
<HeaderCell light>
2929
<FormattedMessage id="form.field.dataType" />
3030
</HeaderCell>
31-
<HeaderCell lighter>
31+
<HeaderCell light>
3232
<FormattedMessage id="form.field.cursorField" />
3333
</HeaderCell>
34-
<HeaderCell lighter>
34+
<HeaderCell light>
3535
<FormattedMessage id="form.field.primaryKey" />
3636
</HeaderCell>
37-
<HeaderCell lighter flex={1.5}>
37+
<HeaderCell light flex={1.5}>
3838
<FormattedMessage id="form.field.destinationName" />
3939
</HeaderCell>
4040
</>
4141
);
4242
};
4343

44-
const FieldHeader = memo(FieldHeaderInner);
45-
46-
export { FieldHeader };
44+
export const FieldHeader = memo(FieldHeaderInner);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$xsmall: 20px;
2+
$small: 50px;
3+
$medium: 120px;
4+
$large: 200px;
5+
6+
.tableCell {
7+
flex: 1 0 $medium;
8+
min-width: $medium;
9+
word-break: break-word;
10+
overflow: hidden;
11+
text-overflow: ellipsis;
12+
13+
&.xsmall {
14+
flex-basis: $xsmall;
15+
min-width: $xsmall;
16+
}
17+
18+
&.small {
19+
flex-basis: $small;
20+
min-width: $small;
21+
}
22+
23+
&.large {
24+
flex-basis: $large;
25+
min-width: $large;
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import classNames from "classnames";
2+
import React from "react";
3+
4+
import styles from "./CatalogTreeTableCell.module.scss";
5+
6+
type Sizes = "xsmall" | "small" | "medium" | "large";
7+
8+
interface CatalogTreeTableCellProps {
9+
size?: Sizes;
10+
className?: string;
11+
}
12+
13+
// This lets us avoid the eslint complaint about unused styles
14+
const sizeMap: Record<Sizes, string> = {
15+
xsmall: styles.xsmall,
16+
small: styles.small,
17+
medium: styles.medium,
18+
large: styles.large,
19+
};
20+
21+
export const CatalogTreeTableCell: React.FC<React.PropsWithChildren<CatalogTreeTableCellProps>> = ({
22+
size = "medium",
23+
className,
24+
children,
25+
}) => {
26+
return <div className={classNames(styles.tableCell, className, sizeMap[size])}>{children}</div>;
27+
};
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
@use "scss/_colors";
22
@use "scss/_variables";
3+
@forward "./CatalogTreeTableRow.module.scss";
34

45
.cellText {
56
color: colors.$grey;
67
}
78

89
.headerContainer {
9-
margin: variables.$spacing-md variables.$spacing-md variables.$spacing-sm variables.$spacing-md;
10+
margin: variables.$spacing-md 0 variables.$spacing-sm 0;
1011
gap: variables.$spacing-sm;
1112
overflow: hidden;
1213
scrollbar-gutter: stable;
1314
min-height: 33px;
14-
}
1515

16-
.checkboxCell {
17-
margin-right: variables.$spacing-sm;
18-
max-width: 43px;
19-
font-size: 10px;
20-
line-height: 13px;
21-
display: flex;
22-
flex-direction: row;
23-
justify-content: flex-end;
24-
padding-left: calc(#{variables.$spacing-xl} + #{variables.$spacing-sm});
16+
&.newTable {
17+
overflow: unset;
18+
}
2519
}
2620

27-
.arrowPlaceholder {
28-
width: 20px;
21+
.checkboxCell {
22+
@extend %streamRowCheckboxCell;
2923
}

0 commit comments

Comments
 (0)