Skip to content

Commit 264c7da

Browse files
committed
Merge branch 'connect-react-preview' of github.com:PipedreamHQ/pipedream into connect-react-preview
2 parents 1dc232d + c64f35d commit 264c7da

20 files changed

+146
-4270
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default [
3737
"**/*.lock",
3838
"**/*.py",
3939
"**/*.png",
40+
"**/.next",
4041
],
4142
},
4243
...compat.extends(

packages/connect-react/.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/connect-react/src/components/ComponentForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import type {
88
} from "@pipedream/sdk";
99
import { InternalComponentForm } from "./InternalComponentForm";
1010

11-
export type ComponentFormProps<T extends ConfigurableProps = any> = {
11+
export type ComponentFormProps<T extends ConfigurableProps> = {
1212
userId: string;
1313
component: V1Component<T>;
1414
configuredProps?: ConfiguredProps<T>; // XXX value?
1515
disableQueryDisabling?: boolean;
1616
propNames?: string[]; // TODO PropNames<T>
17-
onSubmit?: (ctx: FormContext) => void | Promise<void>; // if passed, we include button
17+
onSubmit?: (ctx: FormContext<T>) => void | Promise<void>; // if passed, we include button
1818
onUpdateConfiguredProps?: (v: ConfiguredProps<T>) => void; // XXX onChange?
1919
hideOptionalProps?: boolean;
2020
};
2121

22-
export function ComponentForm(props: ComponentFormProps) {
22+
export function ComponentForm<T extends ConfigurableProps>(props: ComponentFormProps<T>) {
2323
return (
2424
<FormContextProvider props={props}>
2525
<InternalComponentForm />

packages/connect-react/src/components/ControlAny.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { useCustomize } from "../hooks/customization-context";
33
import type { CSSProperties } from "react";
44

55
export function ControlAny() {
6-
const props = useFormFieldContext();
6+
const formFieldContext = useFormFieldContext();
77
const {
88
id, onChange, value,
9-
} = props;
9+
} = formFieldContext;
1010
const {
1111
getProps, theme,
1212
} = useCustomize();
@@ -29,7 +29,7 @@ export function ControlAny() {
2929
id={id}
3030
value={jsonValue}
3131
onChange={(e) => onChange(e.target.value)}
32-
{...getProps("controlAny", baseStyles, props)}
32+
{...getProps("controlAny", baseStyles, formFieldContext)}
3333
/>
3434
);
3535
}

packages/connect-react/src/components/ControlApp.tsx

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { useCustomize } from "../hooks/customization-context";
66
import type { BaseReactSelectProps } from "../hooks/customization-context";
77
import { useMemo } from "react";
88
import type { CSSProperties } from "react";
9-
109
import type { OptionProps } from "react-select";
11-
import {
10+
import type {
1211
AppResponse, ConfigurablePropApp,
1312
} from "@pipedream/sdk";
1413

15-
const BaseOption = (props: OptionProps<any>) => {
14+
const BaseOption = (props: OptionProps<AppResponse>) => {
1615
// const imgSrc =
1716
// props.data.img_src ?? `https://pipedream.com/s.v0/${props.data.id}/logo/48`
1817
return (
@@ -56,7 +55,7 @@ export function ControlApp({ app }: ControlAppProps) {
5655
Option: BaseOption,
5756
},
5857
styles: {
59-
control: (base: {}) => ({
58+
control: (base) => ({
6059
...base,
6160
gridArea: "control",
6261
boxShadow: theme.boxShadow.input,
@@ -122,51 +121,51 @@ export function ControlApp({ app }: ControlAppProps) {
122121
app,
123122
...formFieldCtx,
124123
})}>
125-
{isLoadingAccounts ? (
124+
{isLoadingAccounts ?
126125
`Loading ${app.name} accounts...`
127-
) : accounts.length ? (
128-
<Select
129-
instanceId={id}
130-
value={selectValue}
131-
options={[
132-
...accounts,
133-
{
134-
id: "_new",
135-
name: `Connect new ${app.name} account...`,
136-
},
137-
]}
138-
{...selectProps}
139-
required={true}
140-
placeholder={`Select ${app.name} account...`}
141-
isLoading={isLoadingAccounts}
142-
isClearable={true}
143-
isSearchable={true}
144-
getOptionLabel={(a) => a.name}
145-
getOptionValue={(a) => a.id}
146-
onChange={(a) => {
147-
if (a) {
148-
if (a.id === "_new") {
126+
: accounts.length ?
127+
<Select
128+
instanceId={id}
129+
value={selectValue}
130+
options={[
131+
...accounts,
132+
{
133+
id: "_new",
134+
name: `Connect new ${app.name} account...`,
135+
},
136+
]}
137+
{...selectProps}
138+
required={true}
139+
placeholder={`Select ${app.name} account...`}
140+
isLoading={isLoadingAccounts}
141+
isClearable={true}
142+
isSearchable={true}
143+
getOptionLabel={(a) => a.name}
144+
getOptionValue={(a) => a.id}
145+
onChange={(a) => {
146+
if (a) {
147+
if (a.id === "_new") {
149148
// start connect account and then select it, etc.
150149
// TODO unset / put in loading state
151-
startConnectAccount();
150+
startConnectAccount();
151+
} else {
152+
onChange({
153+
authProvisionId: a.id,
154+
});
155+
}
152156
} else {
153-
onChange({
154-
authProvisionId: a.id,
155-
});
157+
onChange(undefined);
156158
}
157-
} else {
158-
onChange(undefined);
159-
}
160-
}}
161-
/>
162-
) : (
163-
<button type="button" {...getProps("connectButton", baseStylesConnectButton, {
164-
app,
165-
...formFieldCtx,
166-
})} onClick={() => startConnectAccount()}>
159+
}}
160+
/>
161+
:
162+
<button type="button" {...getProps("connectButton", baseStylesConnectButton, {
163+
app,
164+
...formFieldCtx,
165+
})} onClick={() => startConnectAccount()}>
167166
Connect {app.name}
168-
</button>
169-
)}
167+
</button>
168+
}
170169
</div>
171170
);
172171
}

packages/connect-react/src/components/ControlBoolean.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { useCustomize } from "../hooks/customization-context";
44
import type { CSSProperties } from "react";
55

66
export function ControlBoolean() {
7-
const props = useFormFieldContext<ConfigurablePropBoolean>();
7+
const formFieldContextProps = useFormFieldContext<ConfigurablePropBoolean>();
88
const {
99
id, value, onChange,
10-
} = props;
10+
} = formFieldContextProps;
1111
const { getProps } = useCustomize();
1212
const baseStyles: CSSProperties = {
1313
width: "16px",

packages/connect-react/src/components/ControlInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { useFormFieldContext } from "../hooks/form-field-context";
33
import { useCustomize } from "../hooks/customization-context";
44

55
export function ControlInput() {
6-
const props = useFormFieldContext();
6+
const formFieldContextProps = useFormFieldContext();
77
const {
88
id, onChange, prop, value,
9-
} = props;
9+
} = formFieldContextProps;
1010
const {
1111
getProps, theme,
1212
} = useCustomize();
@@ -53,7 +53,7 @@ export function ControlInput() {
5353
name={prop.name}
5454
value={value ?? ""}
5555
onChange={(e) => onChange(toOnChangeValue(e.target.value))}
56-
{...getProps("controlInput", baseStyles, props)}
56+
{...getProps("controlInput", baseStyles, formFieldContextProps)}
5757
min={"min" in prop
5858
? prop.min
5959
: undefined}

packages/connect-react/src/components/ControlSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function ControlSelect<T>({
2626

2727
const baseSelectProps: BaseReactSelectProps = {
2828
styles: {
29-
container: (base: {}): CSSObjectWithLabel => ({
29+
container: (base): CSSObjectWithLabel => ({
3030
...base,
3131
gridArea: "control",
3232
boxShadow: theme.boxShadow.input,

packages/connect-react/src/components/ErrorBoundary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { Component } from "react";
22

33
type Props = {
44
children: React.ReactNode;
5-
fallback: (err: any) => React.ReactNode;
5+
fallback: (err: unknown) => React.ReactNode;
66
};
77

88
export class ErrorBoundary extends Component<Props> {
99
state = {
1010
err: undefined,
1111
};
1212

13-
static getDerivedStateFromError(err: any) {
13+
static getDerivedStateFromError(err: unknown) {
1414
return {
1515
err,
1616
};

packages/connect-react/src/components/Errors.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { FormContext } from "../hooks/form-context";
22
import type { FormFieldContext } from "../hooks/form-field-context";
3-
import { ConfigurableProp } from "@pipedream/sdk";
4-
3+
import {
4+
ConfigurableProp, ConfigurableProps,
5+
} from "@pipedream/sdk";
56
import { useCustomize } from "../hooks/customization-context";
67
import type { CSSProperties } from "react";
78

8-
export type ErrorsProps<T extends ConfigurableProp> = {
9+
export type ErrorsProps<T extends ConfigurableProps, U extends ConfigurableProp> = {
910
errors: string[];
10-
field: FormFieldContext<T>;
11-
form: FormContext;
11+
field: FormFieldContext<U>;
12+
form: FormContext<T>;
1213
};
1314

14-
export function Errors<T extends ConfigurableProp>(props: ErrorsProps<T>) {
15+
export function Errors<T extends ConfigurableProps, U extends ConfigurableProp>(props: ErrorsProps<T, U>) {
1516
const { errors } = props;
1617

1718
const {
@@ -31,7 +32,7 @@ export function Errors<T extends ConfigurableProp>(props: ErrorsProps<T>) {
3132
// maybe that should just be handled by FormFieldContext instead of container?
3233
return (
3334
<ul {...getProps("errors", baseStyles, props)}>
34-
{errors.map((msg) => <li {...getProps("error", baseStyles, props)}>{msg}</li>)}
35+
{errors.map((msg) => <li key={msg} {...getProps("error", baseStyles, props)}>{msg}</li>)}
3536
</ul>
3637
);
3738
}

0 commit comments

Comments
 (0)