Skip to content

Commit

Permalink
New Streams Table Column Sizing Fix (#20141)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
krishnaglick authored Jan 5, 2023
1 parent 23a1110 commit 045323d
Show file tree
Hide file tree
Showing 18 changed files with 483 additions and 427 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ export const Header = styled(Row)`
export const Cell = styled.div<{
flex?: number;
light?: boolean;
lighter?: boolean;
ellipsis?: boolean;
flush?: boolean;
}>`
flex: ${({ flex }) => (flex !== undefined ? flex : 1)} 0 0;
padding-right: ${({ flush }) => (flush ? 0 : 10)}px;
word-break: break-word;
color: ${({ theme, light, lighter }) => (light ? theme.greyColor40 : lighter ? theme.greyColor60 : "inherit")};
font-weight: ${({ light, lighter }) => (light || lighter ? "normal" : "inherit")};
color: ${({ theme, light }) => (light ? theme.greyColor60 : "inherit")};
font-weight: ${({ light }) => (light ? "normal" : "inherit")};
overflow: ${({ ellipsis }) => (ellipsis ? "hidden" : "inherit")};
text-overflow: ${({ ellipsis }) => (ellipsis ? "ellipsis" : "inherit")};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

.catalogTreeTable {
padding: variables.$spacing-lg variables.$spacing-xl 0;
overflow: auto;
border-radius: 10px;
margin-bottom: 29px;

&.newCatalogTreeTable {
padding: 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from "classnames";
import React, { useCallback, useMemo, useState } from "react";

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

import { BulkHeader } from "./BulkHeader";
import styles from "./CatalogTree.module.scss";
import { CatalogTreeBody } from "./CatalogTreeBody";
import { CatalogTreeHeader } from "./CatalogTreeHeader";
import { CatalogTreeSearch } from "./CatalogTreeSearch";
import { CatalogTreeSubheader } from "./CatalogTreeSubheader";
import { BulkEditPanel } from "./next/BulkEditPanel";
import { CatalogTreeTableHeader } from "./next/CatalogTreeTableHeader";
import { StreamConnectionHeader } from "./next/StreamConnectionHeader";

interface CatalogTreeProps {
streams: SyncSchemaStream[];
Expand Down Expand Up @@ -76,19 +72,9 @@ const CatalogTreeComponent: React.FC<React.PropsWithChildren<CatalogTreeProps>>
<BulkEditServiceProvider nodes={streams} update={onStreamsChanged}>
<LoadingBackdrop loading={isLoading}>
{mode !== "readonly" && <CatalogTreeSearch onSearch={setSearchString} />}
<div className={isNewStreamsTableEnabled ? undefined : styles.catalogTreeTable}>
{isNewStreamsTableEnabled ? (
<>
<StreamConnectionHeader />
<CatalogTreeTableHeader />
</>
) : (
<>
<CatalogTreeHeader />
<CatalogTreeSubheader />
<BulkHeader />
</>
)}
<div
className={classNames(styles.catalogTreeTable, { [styles.newCatalogTreeTable]: isNewStreamsTableEnabled })}
>
<CatalogTreeBody
streams={filteredStreams}
changedStreams={changedStreams}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.container {
margin-bottom: 29px;
max-height: 600px;
overflow-y: auto;
overflow: unset;
min-width: fit-content;

--webkit-overlay: true;

width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import { AirbyteStreamConfiguration } from "core/request/AirbyteClient";
import { useConnectionFormService } from "hooks/services/ConnectionForm/ConnectionFormService";
import { FormikConnectionFormValues } from "views/Connection/ConnectionForm/formConfig";

import { BulkHeader } from "./BulkHeader";
import { CatalogSection } from "./CatalogSection";
import styles from "./CatalogTreeBody.module.scss";
import { CatalogTreeHeader } from "./CatalogTreeHeader";
import { CatalogTreeSubheader } from "./CatalogTreeSubheader";
import { CatalogTreeTableHeader } from "./next/CatalogTreeTableHeader";
import { StreamConnectionHeader } from "./next/StreamConnectionHeader";

interface CatalogTreeBodyProps {
streams: SyncSchemaStream[];
changedStreams: SyncSchemaStream[];
onStreamChanged: (stream: SyncSchemaStream) => void;
}

const isNewStreamsTableEnabled = process.env.REACT_APP_NEW_STREAMS_TABLE ?? false;

export const CatalogTreeBody: React.FC<CatalogTreeBodyProps> = ({ streams, changedStreams, onStreamChanged }) => {
const { mode } = useConnectionFormService();

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

return (
<div className={styles.container}>
{isNewStreamsTableEnabled ? (
<>
<StreamConnectionHeader />
<CatalogTreeTableHeader />
</>
) : (
<>
<CatalogTreeHeader />
<CatalogTreeSubheader />
<BulkHeader />
</>
)}
{streams.map((streamNode) => (
<Field key={`schema.streams[${streamNode.id}].config`} name={`schema.streams[${streamNode.id}].config`}>
{({ form }: FieldProps<FormikConnectionFormValues>) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ export const CatalogTreeHeader: React.FC = () => {
</Cell>
)}
{mode !== "readonly" && <Cell flex={0.1} />}
<Cell lighter flex={0.4}>
<Cell light flex={0.4}>
<FormattedMessage id="sources.sync" />
</Cell>
<Cell lighter>
<Cell light>
<FormattedMessage id="sources.source" />
<InfoTooltip>
<FormattedMessage id="connectionForm.source.info" />
</InfoTooltip>
</Cell>
<Cell />
<Cell lighter flex={1.5}>
<Cell light flex={1.5}>
<FormattedMessage id="form.syncMode" />
<InfoTooltip>
<FormattedMessage id="connectionForm.syncType.info" />
<TooltipLearnMoreLink url={links.syncModeLink} />
</InfoTooltip>
</Cell>
<Cell lighter>
<Cell light>
<FormattedMessage id="form.cursorField" />
<InfoTooltip>
<FormattedMessage id="connectionForm.cursor.info" />
</InfoTooltip>
</Cell>
<Cell lighter>
<Cell light>
<FormattedMessage id="form.primaryKey" />
<InfoTooltip>
<FormattedMessage id="connectionForm.primaryKey.info" />
</InfoTooltip>
</Cell>
<Cell lighter>
<Cell light>
<FormattedMessage id="connector.destination" />
<InfoTooltip>
<FormattedMessage id="connectionForm.destinationName.info" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useConnectionFormService } from "hooks/services/ConnectionForm/Connecti

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

const SubtitleCell = styled(Cell).attrs(() => ({ lighter: true }))`
const SubtitleCell = styled(Cell).attrs(() => ({ light: true }))`
font-size: 10px;
line-height: 12px;
border-top: 1px solid ${({ theme }) => theme.greyColor0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,34 @@ const FieldHeaderInner: React.FC = () => {
return (
<>
{isColumnSelectionEnabled && (
<HeaderCell lighter flex={0}>
<HeaderCell light flex={0}>
<SyncHeaderContainer>
<FormattedMessage id="form.field.sync" />
</SyncHeaderContainer>
</HeaderCell>
)}
<HeaderCell lighter flex={1.5}>
<HeaderCell light flex={1.5}>
{!isColumnSelectionEnabled && (
<NameContainer>
<FormattedMessage id="form.field.name" />
</NameContainer>
)}
{isColumnSelectionEnabled && <FormattedMessage id="form.field.name" />}
</HeaderCell>
<HeaderCell lighter>
<HeaderCell light>
<FormattedMessage id="form.field.dataType" />
</HeaderCell>
<HeaderCell lighter>
<HeaderCell light>
<FormattedMessage id="form.field.cursorField" />
</HeaderCell>
<HeaderCell lighter>
<HeaderCell light>
<FormattedMessage id="form.field.primaryKey" />
</HeaderCell>
<HeaderCell lighter flex={1.5}>
<HeaderCell light flex={1.5}>
<FormattedMessage id="form.field.destinationName" />
</HeaderCell>
</>
);
};

const FieldHeader = memo(FieldHeaderInner);

export { FieldHeader };
export const FieldHeader = memo(FieldHeaderInner);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$xsmall: 20px;
$small: 50px;
$medium: 120px;
$large: 200px;

.tableCell {
flex: 1 0 $medium;
min-width: $medium;
word-break: break-word;
overflow: hidden;
text-overflow: ellipsis;

&.xsmall {
flex-basis: $xsmall;
min-width: $xsmall;
}

&.small {
flex-basis: $small;
min-width: $small;
}

&.large {
flex-basis: $large;
min-width: $large;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import classNames from "classnames";
import React from "react";

import styles from "./CatalogTreeTableCell.module.scss";

type Sizes = "xsmall" | "small" | "medium" | "large";

interface CatalogTreeTableCellProps {
size?: Sizes;
className?: string;
}

// This lets us avoid the eslint complaint about unused styles
const sizeMap: Record<Sizes, string> = {
xsmall: styles.xsmall,
small: styles.small,
medium: styles.medium,
large: styles.large,
};

export const CatalogTreeTableCell: React.FC<React.PropsWithChildren<CatalogTreeTableCellProps>> = ({
size = "medium",
className,
children,
}) => {
return <div className={classNames(styles.tableCell, className, sizeMap[size])}>{children}</div>;
};
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
@use "scss/_colors";
@use "scss/_variables";
@forward "./CatalogTreeTableRow.module.scss";

.cellText {
color: colors.$grey;
}

.headerContainer {
margin: variables.$spacing-md variables.$spacing-md variables.$spacing-sm variables.$spacing-md;
margin: variables.$spacing-md 0 variables.$spacing-sm 0;
gap: variables.$spacing-sm;
overflow: hidden;
scrollbar-gutter: stable;
min-height: 33px;
}

.checkboxCell {
margin-right: variables.$spacing-sm;
max-width: 43px;
font-size: 10px;
line-height: 13px;
display: flex;
flex-direction: row;
justify-content: flex-end;
padding-left: calc(#{variables.$spacing-xl} + #{variables.$spacing-sm});
&.newTable {
overflow: unset;
}
}

.arrowPlaceholder {
width: 20px;
.checkboxCell {
@extend %streamRowCheckboxCell;
}
Loading

0 comments on commit 045323d

Please sign in to comment.