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

🪟🎉 Connector builder: Available inputs dropdown #20983

Merged
merged 112 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
d2ed762
improve some types
Dec 5, 2022
f474a1c
Merge remote-tracking branch 'upstream/master' into chore-improve-con…
Dec 5, 2022
5b0521f
improve further
Dec 5, 2022
af659fd
Merge remote-tracking branch 'upstream/master' into chore-improve-con…
Dec 6, 2022
1cd3bbb
clean up a bit more
Dec 6, 2022
807c436
refactor loading state
Dec 6, 2022
6c76e0f
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
05c3107
move loading state up
Dec 6, 2022
eee4303
remove isLoading references
Dec 6, 2022
7d6f977
remove unused props and make fetch connector error work
Dec 6, 2022
0fe11f0
remove special component for name
Dec 6, 2022
34d4814
remove top level state for unifinished flows
Dec 6, 2022
67d62c5
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
afea882
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 6, 2022
c7e7475
Merge branch 'master' into flash1293/connector-form-loading-state
Dec 6, 2022
cc7f65f
Merge branch 'chore-improve-connector-form-types' into flash1293/conn…
Dec 6, 2022
a1c6cbd
start removing uiwidget
Dec 6, 2022
9be8337
Update airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard…
Dec 6, 2022
37cee8f
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 6, 2022
5686241
Merge branch 'flash1293/connector-form-loading-state' of github.com:a…
Dec 6, 2022
7b73364
remove undefined option for selected id
Dec 6, 2022
7058d26
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 6, 2022
dd7e82a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 6, 2022
6d4c7d3
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 7, 2022
d624792
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 7, 2022
36cf941
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 7, 2022
b7a6322
Merge remote-tracking branch 'upstream/master' into flash1293/connect…
Dec 7, 2022
72b602a
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 7, 2022
5e47a4a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 7, 2022
6c71028
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 8, 2022
809625f
remove unused prop
Dec 8, 2022
10446eb
Merge branch 'flash1293/connector-form-loading-state' into flash1293/…
Dec 8, 2022
4a7a885
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 8, 2022
2024b60
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 8, 2022
ee30092
fix types
Dec 8, 2022
d91df38
remove uiwidget state
Dec 8, 2022
93fe558
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 9, 2022
cbc023a
Merge branch 'flash1293/connector-form-name-override' into flash1293/…
Dec 9, 2022
ec54d38
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 9, 2022
47152ea
clean up
Dec 9, 2022
6ec0e10
adjust comment
Dec 9, 2022
1aa7829
handle errors in a nice way
Dec 9, 2022
7b90088
do not respect default on oneOf fields
Dec 9, 2022
fbefbdd
rename to formblock
Dec 9, 2022
6b3e5e2
reduce re-renders
Dec 9, 2022
9aa3f80
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 12, 2022
c765003
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 12, 2022
5cd77ec
pass error to secure inputs
Dec 12, 2022
5dfbc22
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 13, 2022
a6aa741
simplify and improve styling
Dec 13, 2022
95717d2
align top
Dec 13, 2022
40d162d
Merge branch 'flash1293/connector-form-unifinished-flows' into flash1…
Dec 13, 2022
b9384ee
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 13, 2022
582a5f2
code review
Dec 13, 2022
18d6ce8
remove comment
Dec 13, 2022
60c1f1c
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 14, 2022
9cb595d
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 15, 2022
fe74a45
review comments
Dec 15, 2022
5c00ad0
rename file
Dec 15, 2022
bd0dffc
be strict about boolean values
Dec 15, 2022
1ff8c13
add example
Dec 15, 2022
c6ee526
track form error in error boundary
Dec 15, 2022
05bbd6f
Merge branch 'flash1293/connector-form-remove-ui-widget-state' of git…
Dec 15, 2022
fff4703
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 16, 2022
94ba866
review comments
Dec 16, 2022
97bb0a7
handle unexpected cases better
Dec 16, 2022
633b9b2
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 16, 2022
e47517f
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 16, 2022
e931956
Merge remote-tracking branch 'origin/master' into feature/connector-b…
Dec 16, 2022
6889f66
enrich error with connector id
Dec 19, 2022
7b60406
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 19, 2022
d5e56eb
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 19, 2022
35a74ba
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 19, 2022
02c8096
🪟🎉 Add copy stream button (#20577)
Dec 19, 2022
526adfc
rename prop
Dec 20, 2022
7d49233
🪟🎉 Connector builder: Integrate connector form for test input (#20385)
Dec 20, 2022
c5da764
Merge remote-tracking branch 'origin/master' into flash1293/connector…
Dec 20, 2022
6c0bf9d
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 20, 2022
477977f
use request_body_json instead of request_body_data
lmossman Dec 20, 2022
200cfe7
:window: :art: Move `Add` button into the line of Connector Builder k…
lmossman Dec 21, 2022
c7fd310
🪟🎉 Connector builder: Allow defining inputs (#20431)
Dec 22, 2022
e0e3796
fix merge conflict with dropdown prop being renamed to control
Dec 22, 2022
e23a6d8
[Connector Builder] Add paginator (#20698)
lmossman Dec 22, 2022
610e668
[Connector Builder] Add stream slicer (#20748)
lmossman Dec 22, 2022
e68ff49
debounce form builder values update to reduce load
Dec 22, 2022
9ccf294
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Dec 22, 2022
ae9a229
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Dec 22, 2022
a9e1d09
🪟🔧 Connector builder: use new lowcode manifest (#20715)
Dec 22, 2022
e4f7bba
debounce validation as well
Dec 27, 2022
16c71ae
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Jan 2, 2023
54c070d
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Jan 2, 2023
2e20fa6
akways show stream test button in error state if there are errors
Jan 2, 2023
65199d0
fix type of oauth input
Jan 2, 2023
92722e0
Merge branch 'master' into flash1293/connector-form-remove-ui-widget-…
Jan 3, 2023
718c233
Merge branch 'flash1293/connector-form-remove-ui-widget-state' into f…
Jan 3, 2023
6a8be0b
Merge remote-tracking branch 'origin/master' into feature/connector-b…
Jan 3, 2023
16b8d53
available inputs dropdown
Jan 3, 2023
16ce351
add validation schema for add stream form
lmossman Jan 3, 2023
25d6586
validate all views on test click
lmossman Jan 3, 2023
64a5eb9
add type to prevent console warning
lmossman Jan 4, 2023
5041667
Merge branch 'feature/connector-builder' into flash1293/available-inp…
Jan 4, 2023
d68cbf2
Merge remote-tracking branch 'origin/master' into flash1293/available…
Jan 4, 2023
1f89b62
improve styling
Jan 4, 2023
bdc8b0e
make sure padding is set correctly
Jan 4, 2023
1b72f90
make sure focus is set right
Jan 4, 2023
b08a7e6
comment
Jan 4, 2023
b0176ec
Merge remote-tracking branch 'origin/master' into flash1293/available…
Jan 5, 2023
b2469e1
merge with master
lmossman Jan 5, 2023
7be7725
use correct state hook
lmossman Jan 5, 2023
a62b3ef
Merge branch 'master' into flash1293/available-inputs-dropdown
lmossman Jan 5, 2023
3b05ad1
Merge branch 'master' into flash1293/available-inputs-dropdown
lmossman Jan 5, 2023
62bd54e
add tooltip to user input button and fix wording for new user input o…
lmossman Jan 6, 2023
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,5 +1,6 @@
import { BuilderCard } from "./BuilderCard";
import { BuilderField } from "./BuilderField";
import { BuilderFieldWithInputs } from "./BuilderFieldWithInputs";
import { BuilderOneOf } from "./BuilderOneOf";
import { BuilderOptional } from "./BuilderOptional";
import { KeyValueListField } from "./KeyValueListField";
Expand All @@ -23,7 +24,7 @@ export const AuthenticationSection: React.FC = () => {
},
children: (
<>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.header"
label="Header"
Expand Down Expand Up @@ -75,7 +76,7 @@ export const AuthenticationSection: React.FC = () => {
},
children: (
<>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.token_refresh_endpoint"
label="Token refresh endpoint"
Expand All @@ -92,28 +93,28 @@ export const AuthenticationSection: React.FC = () => {
label="Scopes"
tooltip="Scopes to request"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.token_expiry_date_format"
optional
label="Token expiry date format"
tooltip="The format of the expiry date of the access token as obtained from the refresh endpoint"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.expires_in_name"
optional
label="Token expiry property name"
tooltip="The name of the property which contains the token exipiry date in the response from the token refresh endpoint"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.access_token_name"
optional
label="Access token property name"
tooltip="The name of the property which contains the access token in the response from the token refresh endpoint"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.grant_type"
optional
Expand All @@ -139,25 +140,25 @@ export const AuthenticationSection: React.FC = () => {
},
children: (
<>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.header"
label="Header"
tooltip="Specific HTTP header of source API for providing session token"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.session_token_response_key"
label="Session token response key"
tooltip="Key for retrieving session token from api response"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.login_url"
label="Login url"
tooltip="Url for getting a specific session token"
/>
<BuilderField
<BuilderFieldWithInputs
type="string"
path="global.authenticator.validate_session_url"
label="Validate session url"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useField } from "formik";
import { ReactNode } from "react";
import { FormattedMessage } from "react-intl";

import { ControlLabels } from "components/LabeledControl";
Expand Down Expand Up @@ -33,9 +34,11 @@ interface BaseFieldProps {
readOnly?: boolean;
optional?: boolean;
pattern?: RegExp;
adornment?: ReactNode;
className?: string;
}

type BuilderFieldProps = BaseFieldProps &
export type BuilderFieldProps = BaseFieldProps &
(
| { type: "string" | "number" | "integer"; onChange?: (newValue: string) => void }
| { type: "boolean"; onChange?: (newValue: boolean) => void }
Expand Down Expand Up @@ -68,6 +71,7 @@ export const BuilderField: React.FC<BuilderFieldProps> = ({
optional = false,
readOnly,
pattern,
adornment,
...props
}) => {
const [field, meta, helpers] = useField(path);
Expand Down Expand Up @@ -104,10 +108,12 @@ export const BuilderField: React.FC<BuilderFieldProps> = ({
}
props.onChange?.(e.target.value);
}}
className={props.className}
type={props.type}
value={field.value ?? ""}
error={hasError}
readOnly={readOnly}
adornment={adornment}
/>
)}
{props.type === "array" && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@use "scss/variables";
@use "scss/colors";

.button {
align-self: flex-end;
width: auto;
border: none;
background: none;
color: colors.$grey-300;

&:hover {
background: none;
border: none;
color: colors.$blue-500;
}
}

.selectedOption {
margin-top: variables.$spacing-lg;
background: none;
font-size: 12px;
color: colors.$blue-500;

&:hover {
color: colors.$blue-900;
}

& > span {
padding-top: 0;
padding-bottom: 0;
}
}

.container {
position: absolute;
right: variables.$spacing-sm;
top: 0;
display: flex;
flex-direction: column;
max-width: 400px;
width: 100%;

// make the element click through, but all children should behave as normal so the input can be clicked as normal
pointer-events: none;

& > * {
pointer-events: all;
}
}

.buttonContent {
background: none;
border: none;
display: flex;
gap: variables.$spacing-xs;
color: inherit;
align-items: center;
cursor: pointer;
}

.inputWithHelper {
padding-right: 55px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { faPlus, faUser } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useField } from "formik";
import { useMemo, useState } from "react";

import { ListBox, ListBoxControlButtonProps, Option } from "components/ui/ListBox";

import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService";

import { getInferredInputs } from "../types";
import { BuilderField, BuilderFieldProps } from "./BuilderField";
import styles from "./BuilderFieldWithInputs.module.scss";
import { InputForm, newInputInEditing } from "./InputsForm";

export const BuilderFieldWithInputs: React.FC<BuilderFieldProps> = (props) => {
const [field, , helpers] = useField(props.path);

return (
<BuilderField
{...props}
adornment={<UserInputHelper setValue={helpers.setValue} currentValue={field.value} />}
className={styles.inputWithHelper}
/>
);
};

export const UserInputHelper = ({
setValue,
currentValue,
}: {
setValue: (value: string) => void;
currentValue: string;
}) => {
Comment on lines +29 to +35
Copy link
Contributor

@lmossman lmossman Jan 5, 2023

Choose a reason for hiding this comment

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

More of a meta-question for my own learning: why do you use the React.FC<> approach for the component that the file is named after, but use this alternate approach for secondary components in the file?

What is the difference between these approaches? I know that this approach results in the component's type being JSX.Element instead of React.FC<>, but what are the consequences of that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just forgot to add it here, but it's more a code-style thing in this scenario.

Using the React.FC type is more explicit about this being a function component which improves typing, but only a very little bit.

For example take a look at this "function":

const MyFn = () => {
  if (Math.random() < 0.5) return undefined;
  return <span></span>;
};

it's actually slightly invalid because a function component is not allowed to return undefined (has to be null). However, as this is just a function as far as Typescript is concerned, there won't be a type error at definition time (it will complain if you actually try to use it though).

If you do

const MyFn: React.FC = () => {
  if (Math.random() < 0.5) return undefined;
  return <span></span>;
};

however, it will complain directly with

Type '() => JSX.Element | undefined' is not assignable to type 'FC<{}>'.
  Type 'Element | undefined' is not assignable to type 'ReactElement<any, any> | null'.
    Type 'undefined' is not assignable to type 'ReactElement<any, any> | null'.ts(2322)

Also, there are a few additional keys you can set on the function object itself (functions are also objects in Javascript, so you can set arbitrary stuff on them) that are picked up by react:

    interface FunctionComponent<P = {}> {
        (props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
        propTypes?: WeakValidationMap<P> | undefined;
        contextTypes?: ValidationMap<any> | undefined;
        defaultProps?: Partial<P> | undefined;
        displayName?: string | undefined;
    }

However, they are not really important in our setup as it's mostly about an ad-hoc runtime typing React can do (which we don't really need as all our code is typed via Typescript already).

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, that makes sense. So it is probably better to always defer to using React.FC since it applies stricter typing constraints and will therefore fail faster

const [modalOpen, setModalOpen] = useState(false);
const { builderFormValues } = useConnectorBuilderFormState();
const listOptions = useMemo(() => {
const options: Array<Option<string | undefined>> = [
...builderFormValues.inputs,
...getInferredInputs(builderFormValues),
].map((input) => ({
label: input.definition.title || input.key,
value: input.key,
}));
options.push({ value: undefined, label: "Add new input", icon: <FontAwesomeIcon icon={faPlus} /> });
return options;
}, [builderFormValues]);
return (
<>
<ListBox<string | undefined>
buttonClassName={styles.button}
optionClassName={styles.option}
className={styles.container}
selectedOptionClassName={styles.selectedOption}
controlButton={UserInputHelperControlButton}
selectedValue={undefined}
onSelect={(selectedValue) => {
if (selectedValue) {
setValue(`${currentValue || ""}{{ config['${selectedValue}'] }}`);
} else {
// This hack is necessary because listbox will put the focus back when the option list gets hidden, which conflicts with the auto-focus setting of the modal.
// As it's not possible to prevent listbox from forcing the focus back on the button component, this will wait until the focus went to the button, then opens the modal
// so it can move it to the first input
setTimeout(() => {
setModalOpen(true);
}, 50);
}
}}
options={listOptions}
/>
{modalOpen && (
<InputForm
inputInEditing={newInputInEditing()}
onClose={(newInput) => {
setModalOpen(false);
if (!newInput) {
return;
}
setValue(`${currentValue}{{ config['${newInput.key}'] }}`);
}}
/>
)}
</>
);
};

const UserInputHelperControlButton: React.FC<ListBoxControlButtonProps<string | undefined>> = () => {
return (
<div className={styles.buttonContent}>
{"{{"}
<FontAwesomeIcon icon={faUser} />
{"}}"}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RequestOption } from "core/request/ConnectorManifest";

import { injectIntoValues } from "../types";
import { BuilderField } from "./BuilderField";
import { BuilderFieldWithInputs } from "./BuilderFieldWithInputs";

interface InjectRequestOptionFieldsProps {
path: string;
Expand Down Expand Up @@ -37,7 +38,7 @@ export const InjectRequestOptionFields: React.FC<InjectRequestOptionFieldsProps>
tooltip={`Configures where the ${descriptor} should be set on the HTTP requests`}
/>
{field.value.inject_into !== "path" && (
<BuilderField
<BuilderFieldWithInputs
type="string"
path={`${path}.field_name`}
label="Field name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@use "scss/variables";
@use "scss/colors";

.inputForm {
gap: variables.$spacing-lg;
display: flex;
flex-direction: column;
}

.deleteButtonContainer {
flex-grow: 1;
}
Loading