Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🎨 Row highlighting for new streams table #19449

Merged
merged 26 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
09c1d57
initial pass and cleanup
teallarson Nov 15, 2022
c41f4d4
merge cleanup
teallarson Nov 16, 2022
6c61f99
get dropdowns colored correctly also
teallarson Nov 16, 2022
958b6c0
colors for modificationIcon
teallarson Nov 16, 2022
9b17e01
icon alignment
teallarson Nov 16, 2022
12f4fa3
testing skeleton
teallarson Nov 16, 2022
a05b465
move calculation to a hook
teallarson Nov 17, 2022
e2d76e7
update hover styles on rows with changes
teallarson Nov 21, 2022
6f3ce6e
add testing
teallarson Nov 21, 2022
425845f
clarify naming
teallarson Nov 21, 2022
f967831
add mixin, fix selected added/removed rows
teallarson Nov 22, 2022
aeabaf8
WIP test icons using snapshots
teallarson Nov 22, 2022
e8049d0
fix snapshots, tests for catalog tree table row hook
teallarson Nov 22, 2022
31c481f
fix order of logic for disabled rows (disabled trumps everything)
teallarson Nov 22, 2022
9d8d520
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Nov 22, 2022
0a3656b
move icon to its own component, clean up tests
teallarson Nov 23, 2022
41042ea
tidy up test linting disables
teallarson Nov 23, 2022
68a4527
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Dec 5, 2022
91c5825
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Dec 5, 2022
202687f
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Dec 5, 2022
da64e4a
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Dec 5, 2022
b5e3b87
Update airbyte-webapp/src/components/connection/CatalogTree/next/useC…
teallarson Dec 5, 2022
31a94ce
clean up tests
teallarson Dec 5, 2022
e9cb95f
make path-select dropdown full column width
teallarson Dec 5, 2022
749d257
cleanup from rebase
teallarson Dec 5, 2022
5939b74
Merge branch 'master' into teal/row-highlighting-sync-catalog
teallarson Dec 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
@use "scss/colors";
@use "scss/variables";

.icon {
margin-right: 7px;
margin-top: -1px;
@mixin header-background($color, $hoverColor) {
background-color: $color;

&.plus {
color: colors.$green;
}

&.minus {
color: colors.$red;
&:hover {
background-color: $hoverColor;
cursor: pointer;
}
}

.streamHeaderContent {
background: colors.$white;
@include header-background(colors.$white, colors.$grey-30);

border-bottom: 1px solid colors.$grey-50;
padding: 0 variables.$spacing-md;
margin-bottom: 1px;
Expand All @@ -26,27 +23,22 @@
overflow-y: auto;
scrollbar-gutter: stable;

&:hover {
background: colors.$grey-30;
cursor: pointer;
&.removed {
teallarson marked this conversation as resolved.
Show resolved Hide resolved
@include header-background(colors.$red-30, colors.$red-40);
}

&.disabledChange {
background-color: colors.$red-50;
&.added {
@include header-background(colors.$green-30, colors.$green-40);
}

&.enabledChange {
background-color: colors.$green-50;
&.changed {
@include header-background(colors.$blue-30, colors.$blue-40);
}

&.error {
border: 1px solid colors.$red;
}

&.selected {
background-color: colors.$blue-transparent;
}

&.disabled {
background-color: colors.$grey-50;
}
Expand All @@ -62,6 +54,7 @@
flex-direction: row;
justify-content: flex-end;
padding-left: variables.$spacing-xl + variables.$spacing-sm;
align-items: center;
}

.arrowCell {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { faArrowRight, faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import classnames from "classnames";
import React, { useMemo } from "react";
Expand All @@ -12,9 +12,13 @@ import { Text } from "components/ui/Text";
import { useBulkEditSelect } from "hooks/services/BulkEdit/BulkEditService";

import { StreamHeaderProps } from "../StreamHeader";
// eslint-disable-next-line css-modules/no-unused-class
import styles from "./CatalogTreeTableRow.module.scss";
import { CatalogTreeTableRowIcon } from "./CatalogTreeTableRowIcon";
import { StreamPathSelect } from "./StreamPathSelect";
import { SyncModeSelect } from "./SyncModeSelect";
import { useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps";

export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
stream,
destName,
Expand All @@ -30,12 +34,9 @@ export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
// isRowExpanded,
fields,
onExpand,
changedSelected,
hasError,
disabled,
}) => {
const { primaryKey, cursorField, syncMode, destinationSyncMode } = stream.config ?? {};
const isStreamEnabled = stream.config?.selected;

const { defaultCursorField } = stream.stream ?? {};
const syncSchema = useMemo(
Expand All @@ -52,32 +53,15 @@ export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
const fieldCount = fields?.length ?? 0;
const onRowClick = fieldCount > 0 ? () => onExpand() : undefined;

const iconStyle = classnames(styles.icon, {
[styles.plus]: isStreamEnabled,
[styles.minus]: !isStreamEnabled,
});
const { streamHeaderContentStyle, pillButtonVariant } = useCatalogTreeTableRowProps(stream);

const streamHeaderContentStyle = classnames(styles.streamHeaderContent, {
[styles.enabledChange]: changedSelected && isStreamEnabled,
[styles.disabledChange]: changedSelected && !isStreamEnabled,
[styles.selected]: isSelected,
[styles.error]: hasError,
[styles.disabled]: !changedSelected && !isStreamEnabled,
});
const checkboxCellCustomStyle = classnames(styles.checkboxCell, styles.streamRowCheckboxCell);

return (
<Row onClick={onRowClick} className={streamHeaderContentStyle}>
{!disabled && (
<div className={styles.streamRowCheckboxCell}>
{changedSelected && (
<div>
{isStreamEnabled ? (
<FontAwesomeIcon icon={faPlus} size="2x" className={iconStyle} />
) : (
<FontAwesomeIcon icon={faMinus} size="2x" className={iconStyle} />
)}
</div>
)}
<div className={checkboxCellCustomStyle}>
<CatalogTreeTableRowIcon stream={stream} />
<CheckBox checked={isSelected} onChange={selectForBulkEdit} />
</div>
)}
Expand All @@ -104,7 +88,12 @@ export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
</Cell>
) : (
// todo: SyncModeSelect should probably have a Tooltip, append/dedupe ends up ellipsing
<SyncModeSelect options={availableSyncModes} onChange={onSelectSyncMode} value={syncSchema} />
<SyncModeSelect
options={availableSyncModes}
onChange={onSelectSyncMode}
value={syncSchema}
variant={pillButtonVariant}
/>
)}
</div>
<Cell flex={1}>
Expand All @@ -114,6 +103,7 @@ export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
paths={paths}
path={cursorType === "sourceDefined" ? defaultCursorField : cursorField}
onPathChange={onCursorChange}
variant={pillButtonVariant}
/>
)}
</Cell>
Expand All @@ -125,6 +115,7 @@ export const CatalogTreeTableRow: React.FC<StreamHeaderProps> = ({
path={primaryKey}
isMulti
onPathChange={onPrimaryKeyChange}
variant={pillButtonVariant}
/>
)}
</Cell>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@use "scss/colors";

.icon {
margin-right: 7px;

&.plus {
color: colors.$green;
}

&.minus {
color: colors.$red;
}

&.changed {
color: colors.$blue;
display: flex;
flex-direction: row;
align-items: center;
}
}

:export {
modificationIconColor: colors.$blue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import classNames from "classnames";

import { ModificationIcon } from "components/icons/ModificationIcon";

import { SyncSchemaStream } from "core/domain/catalog";

import styles from "./CatalogTreeTableRowIcon.module.scss";
import { useCatalogTreeTableRowProps } from "./useCatalogTreeTableRowProps";

interface CatalogTreeTableRowIconProps {
stream: SyncSchemaStream;
}
export const CatalogTreeTableRowIcon: React.FC<CatalogTreeTableRowIconProps> = ({ stream }) => {
const { statusToDisplay, isSelected } = useCatalogTreeTableRowProps(stream);

if (statusToDisplay === "added") {
return (
<FontAwesomeIcon
icon={faPlus}
size="2x"
className={classNames(styles.icon, { [styles.plus]: !isSelected, [styles.changed]: isSelected })}
/>
);
} else if (statusToDisplay === "removed") {
return (
<FontAwesomeIcon
icon={faMinus}
size="2x"
className={classNames(styles.icon, { [styles.minus]: !isSelected, [styles.changed]: isSelected })}
/>
);
} else if (statusToDisplay === "changed") {
return (
<div className={classNames(styles.icon, styles.changed)}>
<ModificationIcon color={styles.modificationIconColor} />
</div>
);
}
return <div />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
white-space: nowrap;
}

.pillSelect {
.streamPathSelect {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not an essential piece of this PR, but while digging around in the rows, I saw that the streamPathSelect did not stay the full width of its column like on Figma. Adjusted that.

width: 100%;
min-width: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export const StreamPathSelect: React.FC<PathPopoutProps> = (props) => {
<PillSelect
disabled={props.disabled}
variant={props.variant}
className={styles.pillSelect}
options={options}
value={props.path}
isMulti={props.isMulti}
onChange={(options: PathPopoutProps["isMulti"] extends true ? Array<{ value: Path }> : { value: Path }) => {
const finalValues = Array.isArray(options) ? options.map((op) => op.value) : options.value;
props.onPathChange(finalValues);
}}
className={styles.streamPathSelect}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, adjusting this to be full column-width. not related to the main purpose of this PR, but a small, quick fix.

/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface SyncModeSelectProps {
variant?: PillButtonVariant;
}

export const SyncModeSelect: React.FC<SyncModeSelectProps> = ({ className, variant, options, onChange, value }) => {
export const SyncModeSelect: React.FC<SyncModeSelectProps> = ({ className, options, onChange, value, variant }) => {
const pillSelectOptions = useMemo(() => {
return options.map(({ value }) => {
const { syncMode, destinationSyncMode } = value;
Expand All @@ -45,11 +45,11 @@ export const SyncModeSelect: React.FC<SyncModeSelectProps> = ({ className, varia

return (
<PillSelect
variant={variant}
options={pillSelectOptions}
value={value}
onChange={onChange}
className={classNames(styles.pillSelect, className)}
variant={variant}
/>
);
};
Loading