Skip to content

Commit fc66209

Browse files
Joe ReuterTim Roeslmossman
authored andcommitted
🪟🔧 Connector builder: Performance improvements (#20620)
* improve some types * improve further * clean up a bit more * refactor loading state * move loading state up * remove isLoading references * remove unused props and make fetch connector error work * remove special component for name * remove top level state for unifinished flows * start removing uiwidget * Update airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.module.scss Co-authored-by: Tim Roes <[email protected]> * remove undefined option for selected id * remove unused prop * fix types * remove uiwidget state * clean up * adjust comment * handle errors in a nice way * do not respect default on oneOf fields * rename to formblock * reduce re-renders * pass error to secure inputs * simplify and improve styling * align top * code review * remove comment * review comments * rename file * be strict about boolean values * add example * track form error in error boundary * review comments * handle unexpected cases better * speed up some bits * more changes * enrich error with connector id * 🪟🎉 Add copy stream button (#20577) * add copy stream button * review comments * rename prop * 🪟🎉 Connector builder: Integrate connector form for test input (#20385) * move connector builder components into the same shared components/connectorBuilder directory * move diff over from poc branch * save current progress * add modal for adding streams * focus stream after adding and reset button style * add reset confirm modal and select view on add * style global config and streams buttons * styling improvements * handle long stream names better * pull in connector manifest schema directly * add box shadows to resizable panels * upgrade orval and use connector manifest schema directly * remove airbyte protocol from connector builder api spec * generate python models from openapi change * fix position of yaml toggle * handle no stream case with better looking message * group global fields into single object and fix console error * confirmation modal on toggling dirty form + cleanup * fix connector name display * undo change to manifest schema * remove commented code * remove unnecessary change * fix spacing * use shadow mixin for connector img * add comment about connector img * change onSubmit to no-op * remove console log * clean up styling * simplify sidebar to remove StreamSelectButton component * swap colors of toggle * move FormikPatch to src/core/form * move types up to connectorBuilder/ level * use grid display for ui yaml toggle button * use spread instead of setting array index directly * add intl in missing places * pull connector manifest schema in through separate openapi spec * use correct intl string id * throttle setting json manifest in yaml editor * use button prop instead of manually styling * consolidate AddStreamButton styles * fix sidebar flex styles * use specific flex properties instead of flex * clean up download and reset button styles * use row-reverse for yaml editor download button * fix stream selector styles to remove margins * give connector setup guide panel same corner and shadow styles * remove blur from page display * set view to stream when selected in test panel * add placeholder when stream name is empty * switch to index-based stream selection to preserve testing panel selected stream on rename * handle empty name in stream selector * make connector form work in connector builder * fix small stuff * add warning label * review comments * adjust translation Co-authored-by: lmossman <[email protected]> * use request_body_json instead of request_body_data * 🪟 🎨 Move `Add` button into the line of Connector Builder key value list fields (#20699) * move add button into line * add stories for empty with control, and content + control * change button name to Control * 🪟🎉 Connector builder: Allow defining inputs (#20431) * move connector builder components into the same shared components/connectorBuilder directory * move diff over from poc branch * save current progress * add modal for adding streams * focus stream after adding and reset button style * add reset confirm modal and select view on add * style global config and streams buttons * styling improvements * handle long stream names better * pull in connector manifest schema directly * add box shadows to resizable panels * upgrade orval and use connector manifest schema directly * remove airbyte protocol from connector builder api spec * generate python models from openapi change * fix position of yaml toggle * handle no stream case with better looking message * group global fields into single object and fix console error * confirmation modal on toggling dirty form + cleanup * fix connector name display * undo change to manifest schema * remove commented code * remove unnecessary change * fix spacing * use shadow mixin for connector img * add comment about connector img * change onSubmit to no-op * remove console log * clean up styling * simplify sidebar to remove StreamSelectButton component * swap colors of toggle * move FormikPatch to src/core/form * move types up to connectorBuilder/ level * use grid display for ui yaml toggle button * use spread instead of setting array index directly * add intl in missing places * pull connector manifest schema in through separate openapi spec * use correct intl string id * throttle setting json manifest in yaml editor * use button prop instead of manually styling * consolidate AddStreamButton styles * fix sidebar flex styles * use specific flex properties instead of flex * clean up download and reset button styles * use row-reverse for yaml editor download button * fix stream selector styles to remove margins * give connector setup guide panel same corner and shadow styles * remove blur from page display * set view to stream when selected in test panel * add placeholder when stream name is empty * switch to index-based stream selection to preserve testing panel selected stream on rename * handle empty name in stream selector * make connector form work in connector builder * wip * fix small stuff * add basic input UI * user inputs * make most of inputs configuration work * fix a bunch of stuff * handle unknown config types * add warning label * fix label * fix some styling * review comments * improve state management and error handling * handle stored form values that don't contain new fields properly * Update airbyte-webapp/src/locales/en.json Co-authored-by: Lake Mossman <[email protected]> * Update airbyte-webapp/src/components/connectorBuilder/Builder/InputsView.tsx Co-authored-by: Lake Mossman <[email protected]> * inputs editing weirdness * input form reset * using the Label component * 🪟🎉 Connector builder authentication (#20645) * allow auth configuration * check for conflicts with the inferred inputs * fix invisible inputs * reduce redundancy and hide advanced input options for inferred inputs * unnecessary validation * typo * unnecessary effect hook * build spec even for invalid forms but do not update stream list * fix keys * 🪟🎉 Connector builder: Session token and oauth authentication (#20712) * session token and oauth authentication * fill in session token variable * typos * make sure validation error does not go away * 🪟🎉 Connector builder: Always validate inputs form (#20664) * validate user input outside of form * review comments Co-authored-by: lmossman <[email protected]> Co-authored-by: lmossman <[email protected]> * fix merge conflict with dropdown prop being renamed to control * [Connector Builder] Add paginator (#20698) * move connector builder components into the same shared components/connectorBuilder directory * move diff over from poc branch * save current progress * add modal for adding streams * focus stream after adding and reset button style * add reset confirm modal and select view on add * style global config and streams buttons * styling improvements * handle long stream names better * pull in connector manifest schema directly * add box shadows to resizable panels * upgrade orval and use connector manifest schema directly * remove airbyte protocol from connector builder api spec * generate python models from openapi change * fix position of yaml toggle * handle no stream case with better looking message * group global fields into single object and fix console error * confirmation modal on toggling dirty form + cleanup * fix connector name display * undo change to manifest schema * remove commented code * remove unnecessary change * fix spacing * use shadow mixin for connector img * add comment about connector img * change onSubmit to no-op * remove console log * clean up styling * simplify sidebar to remove StreamSelectButton component * swap colors of toggle * move FormikPatch to src/core/form * move types up to connectorBuilder/ level * use grid display for ui yaml toggle button * use spread instead of setting array index directly * add intl in missing places * pull connector manifest schema in through separate openapi spec * use correct intl string id * throttle setting json manifest in yaml editor * use button prop instead of manually styling * consolidate AddStreamButton styles * fix sidebar flex styles * use specific flex properties instead of flex * clean up download and reset button styles * use row-reverse for yaml editor download button * fix stream selector styles to remove margins * give connector setup guide panel same corner and shadow styles * remove blur from page display * set view to stream when selected in test panel * add placeholder when stream name is empty * switch to index-based stream selection to preserve testing panel selected stream on rename * handle empty name in stream selector * make connector form work in connector builder * wip * fix small stuff * add basic input UI * user inputs * make most of inputs configuration work * fix a bunch of stuff * handle unknown config types * add warning label * fix label * fix some styling * review comments * improve state management and error handling * allow auth configuration * check for conflicts with the inferred inputs * fix invisible inputs * handle stored form values that don't contain new fields properly * session token and oauth authentication * fill in session token variable * fix merge of default values * add primaryKey and cursorField to builder types, and consolidate default valeues to types.ts * add cursor and primary key fields to ui * save * add page size and token option inputs * fixes after rebase * add pagination * fix pagination types * handle empty field_name better * Update airbyte-webapp/src/locales/en.json Co-authored-by: Lake Mossman <[email protected]> * Update airbyte-webapp/src/components/connectorBuilder/Builder/InputsView.tsx Co-authored-by: Lake Mossman <[email protected]> * inputs editing weirdness * input form reset * using the Label component * reduce redundancy and hide advanced input options for inferred inputs * unnecessary validation * typo * unnecessary effect hook * build spec even for invalid forms but do not update stream list * typos * make sure validation error does not go away * make primary key and cursor optional, and reorder * save toggle group progress * fix style of toggle label * handle empty values better * fix page size/token option field validation and rendering * handle cursor pagination page size option correctly Co-authored-by: Joe Reuter <[email protected]> * [Connector Builder] Add stream slicer (#20748) * move connector builder components into the same shared components/connectorBuilder directory * move diff over from poc branch * save current progress * add modal for adding streams * focus stream after adding and reset button style * add reset confirm modal and select view on add * style global config and streams buttons * styling improvements * handle long stream names better * pull in connector manifest schema directly * add box shadows to resizable panels * upgrade orval and use connector manifest schema directly * remove airbyte protocol from connector builder api spec * generate python models from openapi change * fix position of yaml toggle * handle no stream case with better looking message * group global fields into single object and fix console error * confirmation modal on toggling dirty form + cleanup * fix connector name display * undo change to manifest schema * remove commented code * remove unnecessary change * fix spacing * use shadow mixin for connector img * add comment about connector img * change onSubmit to no-op * remove console log * clean up styling * simplify sidebar to remove StreamSelectButton component * swap colors of toggle * move FormikPatch to src/core/form * move types up to connectorBuilder/ level * use grid display for ui yaml toggle button * use spread instead of setting array index directly * add intl in missing places * pull connector manifest schema in through separate openapi spec * use correct intl string id * throttle setting json manifest in yaml editor * use button prop instead of manually styling * consolidate AddStreamButton styles * fix sidebar flex styles * use specific flex properties instead of flex * clean up download and reset button styles * use row-reverse for yaml editor download button * fix stream selector styles to remove margins * give connector setup guide panel same corner and shadow styles * remove blur from page display * set view to stream when selected in test panel * add placeholder when stream name is empty * switch to index-based stream selection to preserve testing panel selected stream on rename * handle empty name in stream selector * make connector form work in connector builder * wip * fix small stuff * add basic input UI * user inputs * make most of inputs configuration work * fix a bunch of stuff * handle unknown config types * add warning label * fix label * fix some styling * review comments * improve state management and error handling * allow auth configuration * check for conflicts with the inferred inputs * fix invisible inputs * handle stored form values that don't contain new fields properly * session token and oauth authentication * fill in session token variable * fix merge of default values * add primaryKey and cursorField to builder types, and consolidate default valeues to types.ts * add cursor and primary key fields to ui * save * add page size and token option inputs * fixes after rebase * add pagination * fix pagination types * handle empty field_name better * Update airbyte-webapp/src/locales/en.json Co-authored-by: Lake Mossman <[email protected]> * Update airbyte-webapp/src/components/connectorBuilder/Builder/InputsView.tsx Co-authored-by: Lake Mossman <[email protected]> * inputs editing weirdness * input form reset * using the Label component * reduce redundancy and hide advanced input options for inferred inputs * unnecessary validation * typo * unnecessary effect hook * build spec even for invalid forms but do not update stream list * typos * make sure validation error does not go away * make primary key and cursor optional, and reorder * save toggle group progress * fix style of toggle label * handle empty values better * fix page size/token option field validation and rendering * handle cursor pagination page size option correctly * save stream slicer progress * finish stream slicer * fix stream slicer fields and validation Co-authored-by: Joe Reuter <[email protected]> * debounce form builder values update to reduce load * 🪟🔧 Connector builder: use new lowcode manifest (#20715) * use new manifest yaml * Update airbyte-webapp/src/components/connectorBuilder/types.ts Co-authored-by: Lake Mossman <[email protected]> * use updated manifest types Co-authored-by: Lake Mossman <[email protected]> * debounce validation as well * akways show stream test button in error state if there are errors * fix type of oauth input * review comments * fix more * add validation schema for add stream form * validate all views on test click * add type to prevent console warning * review comment * make sure testing state and form state stay consistent * improve builder errors * remove test state from streamconfig view * remove console log * remove unnecessary positive index check Co-authored-by: Tim Roes <[email protected]> Co-authored-by: lmossman <[email protected]>
1 parent d684daf commit fc66209

File tree

13 files changed

+232
-158
lines changed

13 files changed

+232
-158
lines changed

airbyte-webapp/src/components/connectorBuilder/Builder/Builder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Form } from "formik";
22
import debounce from "lodash/debounce";
33
import { useEffect, useMemo } from "react";
44

5-
import { BuilderView, useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
5+
import { BuilderView, useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
66

77
import { builderFormValidationSchema, BuilderFormValues } from "../types";
88
import styles from "./Builder.module.scss";
@@ -29,7 +29,7 @@ function getView(selectedView: BuilderView, hasMultipleStreams: boolean) {
2929
}
3030

3131
export const Builder: React.FC<BuilderProps> = ({ values, toggleYamlEditor, validateForm }) => {
32-
const { setBuilderFormValues, selectedView } = useConnectorBuilderState();
32+
const { setBuilderFormValues, selectedView } = useConnectorBuilderFormState();
3333
const debouncedSetBuilderFormValues = useMemo(
3434
() =>
3535
debounce((values) => {

airbyte-webapp/src/components/connectorBuilder/Builder/BuilderSidebar.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { faSliders, faUser } from "@fortawesome/free-solid-svg-icons";
22
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
33
import classnames from "classnames";
44
import { useFormikContext } from "formik";
5+
import React from "react";
56
import { FormattedMessage, useIntl } from "react-intl";
67

78
import Indicator from "components/Indicator";
@@ -10,7 +11,7 @@ import { Heading } from "components/ui/Heading";
1011
import { Text } from "components/ui/Text";
1112

1213
import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
13-
import { BuilderView, useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
14+
import { BuilderView, useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
1415

1516
import { DownloadYamlButton } from "../DownloadYamlButton";
1617
import { BuilderFormValues, DEFAULT_BUILDER_FORM_VALUES, getInferredInputs } from "../types";
@@ -52,11 +53,11 @@ interface BuilderSidebarProps {
5253
toggleYamlEditor: () => void;
5354
}
5455

55-
export const BuilderSidebar: React.FC<BuilderSidebarProps> = ({ className, toggleYamlEditor }) => {
56+
export const BuilderSidebar: React.FC<BuilderSidebarProps> = React.memo(({ className, toggleYamlEditor }) => {
5657
const { formatMessage } = useIntl();
5758
const { hasErrors } = useBuilderErrors();
5859
const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
59-
const { yamlManifest, selectedView, setSelectedView, setTestStreamIndex } = useConnectorBuilderState();
60+
const { yamlManifest, selectedView, setSelectedView } = useConnectorBuilderFormState();
6061
const { values, setValues } = useFormikContext<BuilderFormValues>();
6162
const handleResetForm = () => {
6263
openConfirmationModal({
@@ -72,9 +73,6 @@ export const BuilderSidebar: React.FC<BuilderSidebarProps> = ({ className, toggl
7273
};
7374
const handleViewSelect = (selectedView: BuilderView) => {
7475
setSelectedView(selectedView);
75-
if (selectedView !== "global" && selectedView !== "inputs") {
76-
setTestStreamIndex(selectedView);
77-
}
7876
};
7977

8078
return (
@@ -150,4 +148,4 @@ export const BuilderSidebar: React.FC<BuilderSidebarProps> = ({ className, toggl
150148
</Button>
151149
</div>
152150
);
153-
};
151+
});

airbyte-webapp/src/components/connectorBuilder/Builder/StreamConfigView.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CodeEditor } from "components/ui/CodeEditor";
1010
import { Text } from "components/ui/Text";
1111

1212
import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
13-
import { BuilderView, useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
13+
import { BuilderView, useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
1414

1515
import { BuilderStream } from "../types";
1616
import { AddStreamButton } from "./AddStreamButton";
@@ -33,7 +33,7 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
3333
const [field, , helpers] = useField<BuilderStream[]>("streams");
3434
const [selectedTab, setSelectedTab] = useState<"configuration" | "schema">("configuration");
3535
const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
36-
const { setSelectedView, setTestStreamIndex } = useConnectorBuilderState();
36+
const { setSelectedView } = useConnectorBuilderFormState();
3737

3838
const streamPath = `streams[${streamNum}]`;
3939
const streamFieldPath = (fieldPath: string) => `${streamPath}.${fieldPath}`;
@@ -49,7 +49,6 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
4949
const viewToSelect: BuilderView = updatedStreams.length === 0 ? "global" : streamToSelect;
5050
helpers.setValue(updatedStreams);
5151
setSelectedView(viewToSelect);
52-
setTestStreamIndex(streamToSelect);
5352
closeConfirmationModal();
5453
},
5554
});
@@ -80,7 +79,6 @@ export const StreamConfigView: React.FC<StreamConfigViewProps> = ({ streamNum, h
8079
<AddStreamButton
8180
onAddStream={(addedStreamNum) => {
8281
setSelectedView(addedStreamNum);
83-
setTestStreamIndex(addedStreamNum);
8482
}}
8583
initialValues={field.value[streamNum]}
8684
button={

airbyte-webapp/src/components/connectorBuilder/DownloadYamlButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FormattedMessage } from "react-intl";
55
import { Button } from "components/ui/Button";
66
import { Tooltip } from "components/ui/Tooltip";
77

8-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
8+
import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
99
import { downloadFile } from "utils/file";
1010

1111
import styles from "./DownloadYamlButton.module.scss";
@@ -18,7 +18,7 @@ interface DownloadYamlButtonProps {
1818
}
1919

2020
export const DownloadYamlButton: React.FC<DownloadYamlButtonProps> = ({ className, yaml, yamlIsValid }) => {
21-
const { editorView } = useConnectorBuilderState();
21+
const { editorView } = useConnectorBuilderFormState();
2222
const { hasErrors, validateAndTouch } = useBuilderErrors();
2323

2424
const downloadYaml = () => {

airbyte-webapp/src/components/connectorBuilder/StreamTestingPanel/ConfigMenu.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ import { Tooltip } from "components/ui/Tooltip";
1212

1313
import { SourceDefinitionSpecificationDraft } from "core/domain/connector";
1414
import { StreamReadRequestBodyConfig } from "core/request/ConnectorBuilderClient";
15-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
15+
import { useConnectorBuilderTestState } from "services/connectorBuilder/ConnectorBuilderStateService";
16+
import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
1617
import { ConnectorForm } from "views/Connector/ConnectorForm";
1718

1819
import styles from "./ConfigMenu.module.scss";
1920
import { ConfigMenuErrorBoundaryComponent } from "./ConfigMenuErrorBoundary";
2021

2122
interface ConfigMenuProps {
2223
className?: string;
23-
configJsonErrors: number;
24+
testInputJsonErrors: number;
2425
isOpen: boolean;
2526
setIsOpen: (open: boolean) => void;
2627
}
2728

28-
export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className, configJsonErrors, isOpen, setIsOpen }) => {
29+
export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className, testInputJsonErrors, isOpen, setIsOpen }) => {
2930
const { formatMessage } = useIntl();
30-
const { configJson, setConfigJson, jsonManifest, editorView, setEditorView } = useConnectorBuilderState();
31+
const { jsonManifest, editorView, setEditorView } = useConnectorBuilderFormState();
32+
33+
const { testInputJson, setTestInputJson } = useConnectorBuilderTestState();
3134

3235
const [showInputsWarning, setShowInputsWarning] = useLocalStorage<boolean>("connectorBuilderInputsWarning", true);
3336

@@ -64,8 +67,8 @@ export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className, configJsonErr
6467
>
6568
<FormattedMessage id="connectorBuilder.inputsButton" />
6669
</Button>
67-
{configJsonErrors > 0 && (
68-
<NumberBadge className={styles.inputsErrorBadge} value={configJsonErrors} color="red" />
70+
{testInputJsonErrors > 0 && (
71+
<NumberBadge className={styles.inputsErrorBadge} value={testInputJsonErrors} color="red" />
6972
)}
7073
</>
7174
}
@@ -110,16 +113,16 @@ export const ConfigMenu: React.FC<ConfigMenuProps> = ({ className, configJsonErr
110113
bodyClassName={styles.formContent}
111114
footerClassName={styles.inputFormModalFooter}
112115
selectedConnectorDefinitionSpecification={connectorDefinitionSpecification}
113-
formValues={{ connectionConfiguration: configJson }}
116+
formValues={{ connectionConfiguration: testInputJson }}
114117
onSubmit={async (values) => {
115-
setConfigJson(values.connectionConfiguration as StreamReadRequestBodyConfig);
118+
setTestInputJson(values.connectionConfiguration as StreamReadRequestBodyConfig);
116119
setIsOpen(false);
117120
}}
118121
onCancel={() => {
119122
setIsOpen(false);
120123
}}
121124
onReset={() => {
122-
setConfigJson({});
125+
setTestInputJson({});
123126
}}
124127
submitLabel={formatMessage({ id: "connectorBuilder.saveInputsForm" })}
125128
/>

airbyte-webapp/src/components/connectorBuilder/StreamTestingPanel/StreamSelector.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { useIntl } from "react-intl";
55
import { Heading } from "components/ui/Heading";
66
import { ListBox, ListBoxControlButtonProps } from "components/ui/ListBox";
77

8-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
8+
import {
9+
useConnectorBuilderTestState,
10+
useConnectorBuilderFormState,
11+
} from "services/connectorBuilder/ConnectorBuilderStateService";
912

1013
import { ReactComponent as CaretDownIcon } from "../../ui/ListBox/CaretDownIcon.svg";
1114
import styles from "./StreamSelector.module.scss";
@@ -27,7 +30,8 @@ const ControlButton: React.FC<ListBoxControlButtonProps<string>> = ({ selectedOp
2730

2831
export const StreamSelector: React.FC<StreamSelectorProps> = ({ className }) => {
2932
const { formatMessage } = useIntl();
30-
const { streams, selectedView, testStreamIndex, setSelectedView, setTestStreamIndex } = useConnectorBuilderState();
33+
const { selectedView, setSelectedView } = useConnectorBuilderFormState();
34+
const { streams, testStreamIndex, setTestStreamIndex } = useConnectorBuilderTestState();
3135
const options = streams.map((stream) => {
3236
const label =
3337
stream.name && stream.name.trim() ? capitalize(stream.name) : formatMessage({ id: "connectorBuilder.emptyName" });
@@ -39,7 +43,7 @@ export const StreamSelector: React.FC<StreamSelectorProps> = ({ className }) =>
3943
if (selectedStreamIndex >= 0) {
4044
setTestStreamIndex(selectedStreamIndex);
4145

42-
if (selectedView !== "global" && selectedStreamIndex >= 0) {
46+
if (selectedView !== "global") {
4347
setSelectedView(selectedStreamIndex);
4448
}
4549
}

airbyte-webapp/src/components/connectorBuilder/StreamTestingPanel/StreamTestButton.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import { Button } from "components/ui/Button";
77
import { Text } from "components/ui/Text";
88
import { Tooltip } from "components/ui/Tooltip";
99

10-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
10+
import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
1111

1212
import { useBuilderErrors } from "../useBuilderErrors";
1313
import styles from "./StreamTestButton.module.scss";
1414

1515
interface StreamTestButtonProps {
1616
readStream: () => void;
17-
hasConfigJsonErrors: boolean;
17+
hasTestInputJsonErrors: boolean;
1818
setTestInputOpen: (open: boolean) => void;
1919
}
2020

2121
export const StreamTestButton: React.FC<StreamTestButtonProps> = ({
2222
readStream,
23-
hasConfigJsonErrors,
23+
hasTestInputJsonErrors,
2424
setTestInputOpen,
2525
}) => {
26-
const { editorView, yamlIsValid } = useConnectorBuilderState();
26+
const { editorView, yamlIsValid } = useConnectorBuilderFormState();
2727
const { hasErrors, validateAndTouch } = useBuilderErrors();
2828

2929
const handleClick = () => {
30-
if (hasConfigJsonErrors) {
30+
if (hasTestInputJsonErrors) {
3131
setTestInputOpen(true);
3232
return;
3333
}
@@ -49,7 +49,7 @@ export const StreamTestButton: React.FC<StreamTestButtonProps> = ({
4949
tooltipContent = <FormattedMessage id="connectorBuilder.invalidYamlTest" />;
5050
}
5151

52-
if ((editorView === "ui" && hasErrors(false)) || hasConfigJsonErrors) {
52+
if ((editorView === "ui" && hasErrors(false)) || hasTestInputJsonErrors) {
5353
showWarningIcon = true;
5454
tooltipContent = <FormattedMessage id="connectorBuilder.configErrorsTest" />;
5555
}

airbyte-webapp/src/components/connectorBuilder/StreamTestingPanel/StreamTester.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ import { Spinner } from "components/ui/Spinner";
66
import { Text } from "components/ui/Text";
77

88
import { useReadStream } from "services/connectorBuilder/ConnectorBuilderApiService";
9-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
9+
import {
10+
useConnectorBuilderTestState,
11+
useConnectorBuilderFormState,
12+
} from "services/connectorBuilder/ConnectorBuilderStateService";
1013

1114
import { LogsDisplay } from "./LogsDisplay";
1215
import { ResultDisplay } from "./ResultDisplay";
1316
import { StreamTestButton } from "./StreamTestButton";
1417
import styles from "./StreamTester.module.scss";
1518

1619
export const StreamTester: React.FC<{
17-
hasConfigJsonErrors: boolean;
20+
hasTestInputJsonErrors: boolean;
1821
setTestInputOpen: (open: boolean) => void;
19-
}> = ({ hasConfigJsonErrors, setTestInputOpen }) => {
22+
}> = ({ hasTestInputJsonErrors, setTestInputOpen }) => {
2023
const { formatMessage } = useIntl();
21-
const { jsonManifest, configJson, streams, testStreamIndex } = useConnectorBuilderState();
24+
const { jsonManifest } = useConnectorBuilderFormState();
25+
const { streams, testInputJson, testStreamIndex } = useConnectorBuilderTestState();
2226
const {
2327
data: streamReadData,
2428
refetch: readStream,
@@ -28,7 +32,7 @@ export const StreamTester: React.FC<{
2832
} = useReadStream({
2933
manifest: jsonManifest,
3034
stream: streams[testStreamIndex]?.name,
31-
config: configJson,
35+
config: testInputJson,
3236
});
3337

3438
const [logsFlex, setLogsFlex] = useState(0);
@@ -60,7 +64,7 @@ export const StreamTester: React.FC<{
6064

6165
<StreamTestButton
6266
readStream={readStream}
63-
hasConfigJsonErrors={hasConfigJsonErrors}
67+
hasTestInputJsonErrors={hasTestInputJsonErrors}
6468
setTestInputOpen={setTestInputOpen}
6569
/>
6670

airbyte-webapp/src/components/connectorBuilder/StreamTestingPanel/StreamTestingPanel.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { jsonSchemaToFormBlock } from "core/form/schemaToFormBlock";
1010
import { buildYupFormForJsonSchema } from "core/form/schemaToYup";
1111
import { StreamReadRequestBodyConfig } from "core/request/ConnectorBuilderClient";
1212
import { Spec } from "core/request/ConnectorManifest";
13-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
13+
import {
14+
useConnectorBuilderTestState,
15+
useConnectorBuilderFormState,
16+
} from "services/connectorBuilder/ConnectorBuilderStateService";
1417
import { links } from "utils/links";
1518

1619
import { ConfigMenu } from "./ConfigMenu";
@@ -20,28 +23,29 @@ import styles from "./StreamTestingPanel.module.scss";
2023

2124
const EMPTY_SCHEMA = {};
2225

23-
function useConfigJsonErrors(configJson: StreamReadRequestBodyConfig, spec?: Spec): number {
26+
function useTestInputJsonErrors(testInputJson: StreamReadRequestBodyConfig, spec?: Spec): number {
2427
return useMemo(() => {
2528
try {
2629
const jsonSchema = spec && spec.connection_specification ? spec.connection_specification : EMPTY_SCHEMA;
2730
const formFields = jsonSchemaToFormBlock(jsonSchema);
2831
const validationSchema = buildYupFormForJsonSchema(jsonSchema, formFields);
29-
validationSchema.validateSync(configJson, { abortEarly: false });
32+
validationSchema.validateSync(testInputJson, { abortEarly: false });
3033
return 0;
3134
} catch (e) {
3235
if (ValidationError.isError(e)) {
3336
return e.errors.length;
3437
}
3538
return 1;
3639
}
37-
}, [configJson, spec]);
40+
}, [testInputJson, spec]);
3841
}
3942

4043
export const StreamTestingPanel: React.FC<unknown> = () => {
4144
const [isTestInputOpen, setTestInputOpen] = useState(false);
42-
const { jsonManifest, configJson, streamListErrorMessage, yamlEditorIsMounted } = useConnectorBuilderState();
45+
const { jsonManifest, yamlEditorIsMounted } = useConnectorBuilderFormState();
46+
const { testInputJson, streamListErrorMessage } = useConnectorBuilderTestState();
4347

44-
const configJsonErrors = useConfigJsonErrors(configJson, jsonManifest.spec);
48+
const testInputJsonErrors = useTestInputJsonErrors(testInputJson, jsonManifest.spec);
4549

4650
if (!yamlEditorIsMounted) {
4751
return (
@@ -57,7 +61,7 @@ export const StreamTestingPanel: React.FC<unknown> = () => {
5761
<div className={styles.container}>
5862
<ConfigMenu
5963
className={styles.configButton}
60-
configJsonErrors={configJsonErrors}
64+
testInputJsonErrors={testInputJsonErrors}
6165
isOpen={isTestInputOpen}
6266
setIsOpen={setTestInputOpen}
6367
/>
@@ -72,7 +76,7 @@ export const StreamTestingPanel: React.FC<unknown> = () => {
7276
{hasStreams && streamListErrorMessage === undefined && (
7377
<div className={styles.selectAndTestContainer}>
7478
<StreamSelector className={styles.streamSelector} />
75-
<StreamTester hasConfigJsonErrors={configJsonErrors > 0} setTestInputOpen={setTestInputOpen} />
79+
<StreamTester hasTestInputJsonErrors={testInputJsonErrors > 0} setTestInputOpen={setTestInputOpen} />
7680
</div>
7781
)}
7882
{hasStreams && streamListErrorMessage !== undefined && (

airbyte-webapp/src/components/connectorBuilder/YamlEditor/YamlEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CodeEditor } from "components/ui/CodeEditor";
99

1010
import { ConnectorManifest } from "core/request/ConnectorManifest";
1111
import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
12-
import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService";
12+
import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";
1313

1414
import { UiYamlToggleButton } from "../Builder/UiYamlToggleButton";
1515
import { DownloadYamlButton } from "../DownloadYamlButton";
@@ -31,7 +31,7 @@ export const YamlEditor: React.FC<YamlEditorProps> = ({ toggleYamlEditor }) => {
3131
setYamlEditorIsMounted,
3232
setYamlIsValid,
3333
setJsonManifest,
34-
} = useConnectorBuilderState();
34+
} = useConnectorBuilderFormState();
3535
const [yamlValue, setYamlValue] = useState(yamlManifest);
3636

3737
// debounce the setJsonManifest calls so that it doesnt result in a network call for every keystroke

0 commit comments

Comments
 (0)