Skip to content

Commit 850ff58

Browse files
authored
Highlight removed and added streams in Connection form (#13392)
* ugly but works * make it prettier * move StreamHeader to scss modules, add CatalogSection scss * better... todo: spacing between rows, border radii * fix size/spacing to match figma * bug fix - page title * only show on edit mode * improve spacing of header rows * fix styling for dropdown section * adjust styles for readonly mode * Changes from PR review * justify flex-end instead of end
1 parent 94dc191 commit 850ff58

File tree

10 files changed

+331
-179
lines changed

10 files changed

+331
-179
lines changed

airbyte-webapp/src/pages/ConnectionPage/pages/CreationFormPage/CreationFormPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export const CreationFormPage: React.FC = () => {
223223

224224
return (
225225
<>
226-
<HeadTitle titles={[{ id: "sources.newSourceTitle" }]} />
226+
<HeadTitle titles={[{ id: "connection.newConnectionTitle" }]} />
227227
<ConnectorDocumentationWrapper>
228228
<PageTitle
229229
title={<FormattedMessage id={titleId} />}

airbyte-webapp/src/scss/_colors.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
$primaryColor: #615eff;
2-
$primaryColor25: rgba(98, 94, 255, 0.25);
2+
$primaryColor10: rgba(98, 94, 255, 0.1);
33
$primaryColor12: rgba(103, 87, 255, 0.12);
4+
$primaryColor25: rgba(98, 94, 255, 0.25);
45
$mediumPrimaryColor: #36348f;
56
$mediumPrimaryColor20: rgba(73, 68, 193, 0.2);
67
$darkPrimaryColor: #010047;
@@ -11,6 +12,7 @@ $lightPrimaryColor: #edebff;
1112
$brightColor: #f7f6ff;
1213

1314
$dangerColor: #ff5e7b;
15+
$dangerColor14: rgba(255, 94, 123, 0.14);
1416
$dangerColor25: rgba(255, 94, 123, 0.25);
1517
$warningColor: #ffbf00;
1618
$warningBackgroundColor: rgba(255, 191, 0, 0.2);
@@ -19,6 +21,7 @@ $dangerTransparentColor: rgba(247, 77, 88, 0.1);
1921
$attentionColor: #ffbd2e;
2022
$successColor: #67dae1;
2123
$successColor10: rgba(69, 230, 152, 0.1);
24+
$successColor14: rgb(103, 218, 225, 0.14);
2225
$successColor20: rgba(69, 230, 152, 0.2);
2326
$backgroundColor: #fef9f4;
2427
$shadowColor: rgba(0, 0, 0, 0.25);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@use "../../../scss/colors";
2+
3+
.streamFieldTableContainer {
4+
margin-left: 83px;
5+
background: colors.$greyColor0;
6+
}
7+
8+
.catalogSection:first-of-type > div:nth-child(1) > div:nth-child(3) {
9+
border-radius: 8px 8px 0 0;
10+
}
11+
12+
.catalogSection:last-of-type > div:nth-child(1) > div:nth-child(3) {
13+
border-radius: 0 0 8px 8px;
14+
}

airbyte-webapp/src/views/Connection/CatalogTree/CatalogSection.tsx

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { FormikErrors, getIn } from "formik";
22
import React, { memo, useCallback, useMemo } from "react";
33
import { useToggle } from "react-use";
4-
import styled from "styled-components";
54

65
import { DropDownRow } from "components";
76

87
import { getDestinationNamespace, SyncSchemaField, SyncSchemaFieldObject, SyncSchemaStream } from "core/domain/catalog";
98
import { traverseSchemaToField } from "core/domain/catalog/fieldUtil";
10-
import { useBulkEditSelect } from "hooks/services/BulkEdit/BulkEditService";
119
import { equal, naturalComparatorBy } from "utils/objects";
1210
import { ConnectionFormValues, SUPPORTED_MODES } from "views/Connection/ConnectionForm/formConfig";
1311

@@ -18,26 +16,12 @@ import {
1816
SyncMode,
1917
} from "../../../core/request/AirbyteClient";
2018
import { ConnectionFormMode } from "../ConnectionForm/ConnectionForm";
21-
import { TreeRowWrapper } from "./components/TreeRowWrapper";
19+
import styles from "./CatalogSection.module.scss";
2220
import { StreamFieldTable } from "./StreamFieldTable";
2321
import { StreamHeader } from "./StreamHeader";
2422
import { flatten, getPathType } from "./utils";
2523

26-
const Section = styled.div<{ error?: boolean; isSelected: boolean }>`
27-
border: 1px solid ${(props) => (props.error ? props.theme.dangerColor : "none")};
28-
background: ${({ theme, isSelected }) => (isSelected ? "rgba(97, 94, 255, 0.1);" : theme.greyColor0)};
29-
padding: 2px;
30-
31-
&:first-child {
32-
border-radius: 8px 8px 0 0;
33-
}
34-
35-
&:last-child {
36-
border-radius: 0 0 8px 8px;
37-
}
38-
`;
39-
40-
type TreeViewRowProps = {
24+
interface CatalogSectionInnerProps {
4125
streamNode: SyncSchemaStream;
4226
errors: FormikErrors<ConnectionFormValues>;
4327
destinationSupportedSyncModes: DestinationSyncMode[];
@@ -46,9 +30,10 @@ type TreeViewRowProps = {
4630
prefix: string;
4731
updateStream: (id: string | undefined, newConfiguration: Partial<AirbyteStreamConfiguration>) => void;
4832
mode?: ConnectionFormMode;
49-
};
33+
changedSelected: boolean;
34+
}
5035

51-
const CatalogSectionInner: React.FC<TreeViewRowProps> = ({
36+
const CatalogSectionInner: React.FC<CatalogSectionInnerProps> = ({
5237
streamNode,
5338
updateStream,
5439
namespaceDefinition,
@@ -57,12 +42,11 @@ const CatalogSectionInner: React.FC<TreeViewRowProps> = ({
5742
errors,
5843
destinationSupportedSyncModes,
5944
mode,
45+
changedSelected,
6046
}) => {
6147
const [isRowExpanded, onExpand] = useToggle(false);
6248
const { stream, config } = streamNode;
6349

64-
const [isSelected] = useBulkEditSelect(streamNode.id);
65-
6650
const updateStreamWithConfig = useCallback(
6751
(config: Partial<AirbyteStreamConfiguration>) => updateStream(streamNode.id, config),
6852
[updateStream, streamNode]
@@ -146,37 +130,39 @@ const CatalogSectionInner: React.FC<TreeViewRowProps> = ({
146130
const hasChildren = fields && fields.length > 0;
147131

148132
return (
149-
<Section error={hasError} isSelected={isSelected}>
150-
<TreeRowWrapper>
151-
<StreamHeader
152-
stream={streamNode}
153-
destNamespace={destNamespace}
154-
destName={prefix + (streamNode.stream?.name ?? "")}
155-
availableSyncModes={availableSyncModes}
156-
onSelectStream={onSelectStream}
157-
onSelectSyncMode={onSelectSyncMode}
158-
isRowExpanded={isRowExpanded}
159-
primitiveFields={primitiveFields}
160-
pkType={getPathType(pkRequired, shouldDefinePk)}
161-
onPrimaryKeyChange={onPkUpdate}
162-
cursorType={getPathType(cursorRequired, shouldDefineCursor)}
163-
onCursorChange={onCursorSelect}
164-
hasFields={hasChildren}
165-
onExpand={onExpand}
166-
mode={mode}
167-
/>
168-
</TreeRowWrapper>
133+
<div className={styles.catalogSection}>
134+
<StreamHeader
135+
stream={streamNode}
136+
destNamespace={destNamespace}
137+
destName={prefix + (streamNode.stream?.name ?? "")}
138+
availableSyncModes={availableSyncModes}
139+
onSelectStream={onSelectStream}
140+
onSelectSyncMode={onSelectSyncMode}
141+
isRowExpanded={isRowExpanded}
142+
primitiveFields={primitiveFields}
143+
pkType={getPathType(pkRequired, shouldDefinePk)}
144+
onPrimaryKeyChange={onPkUpdate}
145+
cursorType={getPathType(cursorRequired, shouldDefineCursor)}
146+
onCursorChange={onCursorSelect}
147+
hasFields={hasChildren}
148+
onExpand={onExpand}
149+
mode={mode}
150+
changedSelected={changedSelected}
151+
hasError={hasError}
152+
/>
169153
{isRowExpanded && hasChildren && (
170-
<StreamFieldTable
171-
config={config}
172-
syncSchemaFields={flattenedFields}
173-
onCursorSelect={onCursorSelect}
174-
onPkSelect={onPkSelect}
175-
shouldDefinePk={shouldDefinePk}
176-
shouldDefineCursor={shouldDefineCursor}
177-
/>
154+
<div className={styles.streamFieldTableContainer}>
155+
<StreamFieldTable
156+
config={config}
157+
syncSchemaFields={flattenedFields}
158+
onCursorSelect={onCursorSelect}
159+
onPkSelect={onPkSelect}
160+
shouldDefinePk={shouldDefinePk}
161+
shouldDefineCursor={shouldDefineCursor}
162+
/>
163+
</div>
178164
)}
179-
</Section>
165+
</div>
180166
);
181167
};
182168

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// These are utility classes that will be used by multiple sub-components
2+
// of the CatalogTree component once we finish migrating to scss,
3+
// not only styles used directly in CatalogTree
4+
5+
.headerCell {
6+
font-size: 10px;
7+
line-height: 13px;
8+
}
9+
10+
.checkboxCell {
11+
@extend .headerCell;
12+
max-width: 43px;
13+
text-align: center;
14+
display: flex;
15+
flex-direction: row;
16+
}

airbyte-webapp/src/views/Connection/CatalogTree/CatalogTree.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Field, FieldProps, setIn } from "formik";
1+
import { Field, FieldProps, setIn, useFormikContext } from "formik";
22
import React, { useCallback } from "react";
33

44
import { SyncSchemaStream } from "core/domain/catalog";
55
import { AirbyteStreamConfiguration, DestinationSyncMode } from "core/request/AirbyteClient";
6-
import { FormikConnectionFormValues } from "views/Connection/ConnectionForm/formConfig";
6+
import { ConnectionFormValues, FormikConnectionFormValues } from "views/Connection/ConnectionForm/formConfig";
77

88
import { ConnectionFormMode } from "../ConnectionForm/ConnectionForm";
99
import { CatalogSection } from "./CatalogSection";
@@ -29,6 +29,12 @@ const CatalogTree: React.FC<CatalogTreeProps> = ({ streams, destinationSupported
2929
[streams, onChangeStream]
3030
);
3131

32+
const { initialValues } = useFormikContext<ConnectionFormValues>();
33+
34+
const changedStreams = streams.filter((stream, idx) => {
35+
return stream.config?.selected !== initialValues.syncCatalog.streams[idx].config?.selected;
36+
});
37+
3238
return (
3339
<>
3440
{streams.map((streamNode) => (
@@ -44,6 +50,7 @@ const CatalogTree: React.FC<CatalogTreeProps> = ({ streams, destinationSupported
4450
destinationSupportedSyncModes={destinationSupportedSyncModes}
4551
updateStream={onUpdateStream}
4652
mode={mode}
53+
changedSelected={changedStreams.includes(streamNode) && mode === "edit"}
4754
/>
4855
)}
4956
</Field>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@use "../../../scss/colors";
2+
@use "../../../scss/variables";
3+
@forward "./CatalogTree.module.scss";
4+
5+
.removedStream {
6+
color: colors.$dangerColor;
7+
}
8+
9+
.icon {
10+
margin-right: 7px;
11+
margin-top: -1px;
12+
&.plus {
13+
color: colors.$successColor;
14+
}
15+
&.minus {
16+
color: colors.$dangerColor;
17+
}
18+
}
19+
20+
.streamRowCheckboxCell {
21+
width: 100%;
22+
display: flex;
23+
flex-direction: row;
24+
justify-content: flex-end;
25+
}
26+
27+
.streamHeaderContent {
28+
background: colors.$greyColor0;
29+
transition: background-color variables.$transition;
30+
width: 100%;
31+
padding: 2px;
32+
padding-left: 10px;
33+
display: flex;
34+
flex-direction: row;
35+
align-items: center;
36+
vertical-align: middle;
37+
height: 50px;
38+
}
39+
40+
.catalogSectionRow {
41+
height: 100%;
42+
white-space: nowrap;
43+
font-size: 12px;
44+
display: flex;
45+
flex-direction: row;
46+
margin-top: 18px;
47+
margin-bottom: 9px;
48+
}
49+
50+
.redBackground {
51+
background-color: colors.$dangerColor14;
52+
}
53+
54+
.greenBackground {
55+
background-color: colors.$successColor14;
56+
}
57+
58+
.redBorder {
59+
border: 1px solid colors.$dangerColor;
60+
}
61+
62+
.purpleBackground {
63+
background-color: colors.$primaryColor10;
64+
}

0 commit comments

Comments
 (0)