-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 authentication #20645
Merged
flash1293
merged 14 commits into
flash1293/allow-configuring-inputs
from
flash1293/connector-builder-authentication
Dec 22, 2022
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
04d87cf
allow auth configuration
b796201
check for conflicts with the inferred inputs
18498c7
fix invisible inputs
8c4b6c7
Merge branch 'flash1293/allow-configuring-inputs' into flash1293/conn…
lmossman fb1ec21
Merge branch 'flash1293/allow-configuring-inputs' into flash1293/conn…
fbeb2e1
Merge branch 'flash1293/allow-configuring-inputs' into flash1293/conn…
1bccbbd
reduce redundancy and hide advanced input options for inferred inputs
eaec279
unnecessary validation
a338590
typo
2429d29
unnecessary effect hook
6dd02d9
build spec even for invalid forms but do not update stream list
750c383
fix keys
fca9305
🪟🎉 Connector builder: Session token and oauth authentication (#20712)
30c60b8
🪟🎉 Connector builder: Always validate inputs form (#20664)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
airbyte-webapp/src/components/connectorBuilder/Builder/BuilderOneOf.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useField } from "formik"; | ||
import React, { useEffect } from "react"; | ||
|
||
import GroupControls from "components/GroupControls"; | ||
import { ControlLabels } from "components/LabeledControl"; | ||
import { DropDown } from "components/ui/DropDown"; | ||
|
||
interface Option { | ||
label: string; | ||
value: string; | ||
default?: object; | ||
} | ||
|
||
interface OneOfOption { | ||
label: string; // label shown in the dropdown menu | ||
typeValue: string; // value to set on the `type` field for this component - should match the oneOf type definition | ||
default?: object; // default values for the path | ||
children?: React.ReactNode; | ||
} | ||
|
||
interface BuilderOneOfProps { | ||
options: OneOfOption[]; | ||
path: string; // path to the oneOf component in the json schema | ||
label: string; | ||
tooltip: string; | ||
} | ||
|
||
export const BuilderOneOf: React.FC<BuilderOneOfProps> = ({ options, path, label, tooltip }) => { | ||
const [, , oneOfPathHelpers] = useField(path); | ||
const typePath = `${path}.type`; | ||
const [typePathField, , typePathHelpers] = useField(typePath); | ||
const value = typePathField.value ?? options[0].typeValue; | ||
|
||
useEffect(() => { | ||
typePathHelpers.setValue(value); | ||
}, []); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
const selectedOption = options.find((option) => option.typeValue === value); | ||
|
||
return ( | ||
<GroupControls | ||
label={<ControlLabels label={label} infoTooltipContent={tooltip} />} | ||
dropdown={ | ||
<DropDown | ||
{...typePathField} | ||
options={options.map((option) => { | ||
return { label: option.label, value: option.typeValue, default: option.default }; | ||
})} | ||
value={value ?? options[0].typeValue} | ||
onChange={(selectedOption: Option) => { | ||
if (selectedOption.value === value) { | ||
return; | ||
} | ||
// clear all values for this oneOf and set selected option and default values | ||
oneOfPathHelpers.setValue({ | ||
type: selectedOption.value, | ||
...selectedOption.default, | ||
}); | ||
}} | ||
/> | ||
} | ||
> | ||
{selectedOption?.children} | ||
</GroupControls> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this at one point but later removed it from BuilderFields since I didn't think it was actually needed anymore. Could you double check if this is necessary to keep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, we don't and I think it's better to truthfully show no selected option instead of defaulting to the first one as that wouldn't be reflected in the actual form state.