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]Add ability to convert from YAML manifest to UI #21142

Merged
merged 33 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3ab9607
save
lmossman Jan 4, 2023
6834479
save more progress
lmossman Jan 5, 2023
e2c0a44
try setting values directly
lmossman Jan 5, 2023
546e308
toggle editor
lmossman Jan 6, 2023
b4ec687
merge and expand conversion logic
lmossman Jan 7, 2023
c208d95
fix primary key
lmossman Jan 7, 2023
5bc6ac0
enforce consistency in name and primary key
lmossman Jan 7, 2023
3578222
refactor conversion method to be more readable
lmossman Jan 10, 2023
12bf3cb
save progress
lmossman Jan 10, 2023
75e4c5b
allow custom input keys to be used for inferred auth values
lmossman Jan 11, 2023
27b9a57
fix isMatch bug and remove console logs
lmossman Jan 13, 2023
9707a0a
merge with master
lmossman Jan 13, 2023
8111c90
fix type issues with reflect
lmossman Jan 13, 2023
2550ade
properly handle undefined
lmossman Jan 13, 2023
0e58d98
format schema and gracefully handle non-inline schemas
lmossman Jan 13, 2023
a83331b
verify no custom components
lmossman Jan 13, 2023
113751c
refactor and fix request options type
lmossman Jan 13, 2023
b224f8b
rest of refactor
lmossman Jan 13, 2023
17f4112
move manifest to builder form conversion logic into its own file, and…
lmossman Jan 13, 2023
0f8ee5a
convert substream slicers
lmossman Jan 13, 2023
8e6ad4d
restore warning modal for switching back to UI
lmossman Jan 14, 2023
7a7b03b
remove console logs
lmossman Jan 14, 2023
5d2d065
Merge branch 'master' into lmossman/yaml-to-ui-poc
lmossman Jan 14, 2023
fe403ad
Merge branch 'master' into lmossman/yaml-to-ui-poc
lmossman Jan 18, 2023
e7f3705
remove unneeded traceback filtering
lmossman Jan 18, 2023
f3c8e1a
set http method when converting to manifest
lmossman Jan 18, 2023
2fdc20a
remove commented import
lmossman Jan 18, 2023
1e02232
add unsupported fields to builder form values
lmossman Jan 18, 2023
3338722
save check stream values from manifest
lmossman Jan 18, 2023
cccc35b
save progress
lmossman Jan 19, 2023
059d8df
add more tests
lmossman Jan 19, 2023
6e428ad
save record filter in unsupported fields
lmossman Jan 19, 2023
c0abbf0
use type coersion instead of yaml strings
lmossman Jan 19, 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,10 +1,10 @@
import { inferredAuthValues } from "../types";
import { BuilderCard } from "./BuilderCard";
import { BuilderField } from "./BuilderField";
import { BuilderFieldWithInputs } from "./BuilderFieldWithInputs";
import { BuilderOneOf } from "./BuilderOneOf";
import { BuilderOptional } from "./BuilderOptional";
import { KeyValueListField } from "./KeyValueListField";
import { UserInputField } from "./UserInputField";

export const AuthenticationSection: React.FC = () => {
return (
Expand All @@ -19,7 +19,7 @@ export const AuthenticationSection: React.FC = () => {
label: "API Key",
typeValue: "ApiKeyAuthenticator",
default: {
api_token: "{{ config['api_key'] }}",
...inferredAuthValues("ApiKeyAuthenticator"),
header: "",
},
children: (
Expand All @@ -30,9 +30,12 @@ export const AuthenticationSection: React.FC = () => {
label="Header"
tooltip="HTTP header which should be set to the API Key"
/>
<UserInputField
<BuilderField
type="string"
path="global.authenticator.api_token"
label="API Key"
tooltip="The API key issued by the service. Fill it in in the user inputs"
readOnly
/>
</>
),
Expand All @@ -41,36 +44,48 @@ export const AuthenticationSection: React.FC = () => {
label: "Bearer",
typeValue: "BearerAuthenticator",
default: {
api_token: "{{ config['api_key'] }}",
...inferredAuthValues("BearerAuthenticator"),
},
children: (
<UserInputField
<BuilderField
type="string"
path="global.authenticator.api_token"
label="API Key"
tooltip="The API key issued by the service. Fill it in in the user inputs"
readOnly
/>
),
},
{
label: "Basic HTTP",
typeValue: "BasicHttpAuthenticator",
default: {
username: "{{ config['username'] }}",
password: "{{ config['password'] }}",
...inferredAuthValues("BasicHttpAuthenticator"),
},
children: (
<>
<UserInputField label="Username" tooltip="The username for the login. Fill it in in the user inputs" />
<UserInputField label="Password" tooltip="The password for the login. Fill it in in the user inputs" />
<BuilderField
type="string"
path="global.authenticator.username"
label="Username"
tooltip="The username for the login. Fill it in in the user inputs"
readOnly
/>
<BuilderField
type="string"
path="global.authenticator.password"
label="Password"
tooltip="The password for the login. Fill it in in the user inputs"
readOnly
/>
</>
),
},
{
label: "OAuth",
typeValue: "OAuthAuthenticator",
default: {
client_id: "{{ config['client_id'] }}",
client_secret: "{{ config['client_secret'] }}",
refresh_token: "{{ config['client_refresh_token'] }}",
...inferredAuthValues("OAuthAuthenticator"),
refresh_request_body: [],
token_refresh_endpoint: "",
},
Expand All @@ -82,9 +97,27 @@ export const AuthenticationSection: React.FC = () => {
label="Token refresh endpoint"
tooltip="The URL to call to obtain a new access token"
/>
<UserInputField label="Client ID" tooltip="The OAuth client ID" />
<UserInputField label="Client secret" tooltip="The OAuth client secret" />
<UserInputField label="Refresh token" tooltip="The OAuth refresh token" />
<BuilderField
type="string"
path="global.authenticator.client_id"
label="Client ID"
tooltip="The OAuth client ID. Fill it in in the user inputs"
readOnly
/>
<BuilderField
type="string"
path="global.authenticator.client_secret"
label="Client secret"
tooltip="The OAuth client secret. Fill it in in the user inputs"
readOnly
/>
<BuilderField
type="string"
path="global.authenticator.refresh_token"
label="Refresh token"
tooltip="The OAuth refresh token. Fill it in in the user inputs"
readOnly
/>
<BuilderOptional>
<BuilderField
type="array"
Expand Down Expand Up @@ -134,9 +167,7 @@ export const AuthenticationSection: React.FC = () => {
label: "Session token",
typeValue: "SessionTokenAuthenticator",
default: {
username: "{{ config['username'] }}",
password: "{{ config['password'] }}",
session_token: "{{ config['session_token'] }}",
...inferredAuthValues("SessionTokenAuthenticator"),
},
children: (
<>
Expand Down Expand Up @@ -164,11 +195,26 @@ export const AuthenticationSection: React.FC = () => {
label="Validate session url"
tooltip="Url to validate passed session token"
/>
<UserInputField label="Username" tooltip="The username" />
<UserInputField label="Password" tooltip="The password" />
<UserInputField
<BuilderField
type="string"
path="global.authenticator.username"
label="Username"
tooltip="The username for the login. Fill it in in the user inputs"
readOnly
/>
<BuilderField
type="string"
path="global.authenticator.password"
label="Password"
tooltip="The password for the login. Fill it in in the user inputs"
readOnly
/>
<BuilderField
type="string"
path="global.authenticator.session_token"
label="Session token"
tooltip="Session token generated by user (if provided username and password are not required)"
tooltip="Session token generated by user (if provided, username and password are not required). Fill it in in the user inputs"
readOnly
/>
</>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMonaco } from "@monaco-editor/react";
import { useFormikContext } from "formik";
import { load, YAMLException } from "js-yaml";
import debounce from "lodash/debounce";
import isMatch from "lodash/isMatch";
Expand All @@ -8,20 +9,21 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { CodeEditor } from "components/ui/CodeEditor";

import { ConnectorManifest } from "core/request/ConnectorManifest";
import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
// import { useConfirmationModalService } from "hooks/services/ConfirmationModal";
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover

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

import { UiYamlToggleButton } from "../Builder/UiYamlToggleButton";
import { DownloadYamlButton } from "../DownloadYamlButton";
import { convertToManifest } from "../types";
import { convertToBuilderFormValues, convertToManifest } from "../types";
import styles from "./YamlEditor.module.scss";

interface YamlEditorProps {
toggleYamlEditor: () => void;
}

export const YamlEditor: React.FC<YamlEditorProps> = ({ toggleYamlEditor }) => {
const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
const { setValues } = useFormikContext();
// const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
const yamlEditorRef = useRef<editor.IStandaloneCodeEditor>();
const {
yamlManifest,
Expand Down Expand Up @@ -82,16 +84,23 @@ export const YamlEditor: React.FC<YamlEditorProps> = ({ toggleYamlEditor }) => {

const handleToggleYamlEditor = () => {
if (yamlIsDirty) {
openConfirmationModal({
text: "connectorBuilder.toggleModal.text",
title: "connectorBuilder.toggleModal.title",
submitButtonText: "connectorBuilder.toggleModal.submitButton",
onSubmit: () => {
setYamlIsValid(true);
toggleYamlEditor();
closeConfirmationModal();
},
});
// openConfirmationModal({
// text: "connectorBuilder.toggleModal.text",
// title: "connectorBuilder.toggleModal.title",
// submitButtonText: "connectorBuilder.toggleModal.submitButton",
// onSubmit: () => {
// setYamlIsValid(true);
// toggleYamlEditor();
// closeConfirmationModal();
// },
// });
// setBuilderFormValues(convertToBuilderFormValues(jsonManifest), false);
try {
setValues(convertToBuilderFormValues(jsonManifest, builderFormValues));
toggleYamlEditor();
} catch (e) {
alert(e.message);
}
} else {
setYamlIsValid(true);
toggleYamlEditor();
Expand Down
Loading