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

Biz/dj 2780 add support for configurationerror in connect react #15479

Merged
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9b22d10
Fix linter error
bzwrk Jan 30, 2025
26fc774
Surface configuration and sdk errors
bzwrk Feb 1, 2025
a9b491f
Merge branch 'master' into biz/dj-2780-add-support-for-configuratione…
bzwrk Feb 1, 2025
b5374a3
Update pnpm lock
bzwrk Feb 1, 2025
915b0c7
Render SDK errors in an alert
bzwrk Feb 3, 2025
506f70e
Add getEnvironment to BaseClient
bzwrk Feb 3, 2025
7e7076e
Add isDevelopment flag to context
bzwrk Feb 3, 2025
f646285
Set sdk version to 1.3.1 in example app
bzwrk Feb 3, 2025
b5f9751
Update pnpm
bzwrk Feb 3, 2025
cfb755f
Merge branch 'master' into biz/dj-2780-add-support-for-configuratione…
bzwrk Feb 4, 2025
3d8d64a
Bump sdk version in nextjs app
bzwrk Feb 4, 2025
3c89a95
Json stringify sdk errors
bzwrk Feb 4, 2025
4b3d60e
Update sdk version
bzwrk Feb 4, 2025
03b0c25
Handle sdk errors
bzwrk Feb 4, 2025
efbe727
Cleanup
bzwrk Feb 5, 2025
412ba84
Cleanup page.tsx
bzwrk Feb 5, 2025
d65cb15
Merge branch 'master' into biz/dj-2780-add-support-for-configuratione…
bzwrk Feb 5, 2025
5e3468e
Commit pnpm-lock.yaml
bzwrk Feb 5, 2025
8a0d675
Undo sdk changes
bzwrk Feb 5, 2025
313cb49
Use enableDebugging flag instead of environment
bzwrk Feb 5, 2025
6ce06f9
Update version and README
bzwrk Feb 5, 2025
04e09cf
Cleanup
bzwrk Feb 5, 2025
ce4af02
Update version
bzwrk Feb 5, 2025
e469a89
Cleanup
bzwrk Feb 5, 2025
1a718b0
Merge pnpm changes
bzwrk Feb 5, 2025
f207c12
Merge branch 'master' into biz/dj-2780-add-support-for-configuratione…
bzwrk Feb 5, 2025
d8140cc
Refactor sdk error handler
bzwrk Feb 6, 2025
e79b262
Add types file
bzwrk Feb 6, 2025
745ca5a
Refactor Errors.tsx
bzwrk Feb 6, 2025
83daf26
Always show ConfigurationError
bzwrk Feb 6, 2025
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
2 changes: 1 addition & 1 deletion components/buysellads/buysellads.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/humanlayer/humanlayer.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/planhat/planhat.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/storerocket/storerocket.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
4 changes: 4 additions & 0 deletions packages/connect-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!-- markdownlint-disable MD024 -->
# Changelog

# [1.0.0-preview.28] - 2025-02-05

- Surface SDK errors in the form

# [1.0.0-preview.27] - 2025-01-30

- Add styling to alerts
Expand Down
5 changes: 5 additions & 0 deletions packages/connect-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ type ComponentFormProps = {
onUpdateConfiguredProps: (v: Record<string, any>) => void;
/** Hide optional props section */
hideOptionalProps: boolean;
/** SDK response payload or the error object from catching SDK request failures.
* Used in conjunction with enableDebugging to show errors in the form.*/
sdkErrors: unknown[] | unknown | undefined;
/** Whether to show show errors in the form. Requires sdkErrors to be set. */
enableDebugging?: boolean;
};
```

Expand Down
134 changes: 15 additions & 119 deletions packages/connect-react/examples/nextjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/connect-react/examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"@pipedream/connect-react": "file:../..",
"@pipedream/sdk": "^1.1.4",
"@pipedream/sdk": "^1.3.2",
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
Expand Down
12 changes: 10 additions & 2 deletions packages/connect-react/examples/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { fetchToken } from "./actions";
export default function Home() {
const userId = "my-authed-user-id";
const client = createFrontendClient({
environment: "development",
externalUserId: userId,
tokenCallback: fetchToken,
});
Expand All @@ -26,6 +25,11 @@ export default function Home() {
setDynamicPropsId,
] = useState<string | undefined>();

const [
sdkErrors,
setSdkErrors,
] = useState<unknown[] | unknown | undefined>(undefined);

const handleDynamicProps = (dynamicProps: { id: string | undefined }) => {
setDynamicPropsId(dynamicProps.id)
}
Expand All @@ -40,15 +44,19 @@ export default function Home() {
configuredProps={configuredProps}
onUpdateDynamicProps={handleDynamicProps}
onUpdateConfiguredProps={setConfiguredProps}
sdkErrors={sdkErrors}
enableDebugging={true}
onSubmit={async () => {
try {
await client.actionRun({
const result = await client.runAction({
userId,
actionId: "slack-send-message",
configuredProps,
dynamicPropsId,
});
setSdkErrors(result)
} catch (error) {
setSdkErrors(error as unknown)
console.error("Action run failed:", error);
}
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/connect-react",
"version": "1.0.0-preview.27",
"version": "1.0.0-preview.28",
"description": "Pipedream Connect library for React",
"files": [
"dist"
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-react/src/components/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ type AlertProps = {

export function Alert({ prop }: AlertProps) {
const baseStyles = {
width: "100%",
background: "#e2e3e5",
borderRadius: "10px",
borderRadius: "5px",
paddingTop: "2px",
paddingLeft: "10px",
paddingRight: "10px",
Expand Down
2 changes: 2 additions & 0 deletions packages/connect-react/src/components/ComponentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export type ComponentFormProps<T extends ConfigurableProps, U = ConfiguredProps<
onUpdateConfiguredProps?: (v: U) => void; // XXX onChange?
onUpdateDynamicProps?: (dp: DynamicProps<T>) => void;
hideOptionalProps?: boolean;
sdkErrors?: unknown[] | unknown | undefined;
enableDebugging?: string;
};

export function ComponentForm<T extends ConfigurableProps>(props: ComponentFormProps<T>) {
Expand Down
7 changes: 3 additions & 4 deletions packages/connect-react/src/components/Description.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { CSSProperties } from "react";
import Markdown from "react-markdown";
import { ConfigurableProp, ConfigurableProps } from "@pipedream/sdk";
import {
ConfigurableProp, ConfigurableProps,
} from "@pipedream/sdk";
import { useCustomize } from "../hooks/customization-context";
import { FormFieldContext } from "../hooks/form-field-context";
import { FormContext } from "../hooks/form-context";
Expand All @@ -14,9 +16,6 @@ export type DescriptionProps<T extends ConfigurableProps, U extends Configurable
// XXX should we rename to FieldDescription (so shared prefix + clear we need field context
// eg. cannot be used in OptionalFieldButton, or they need to be set up better)
export function Description<T extends ConfigurableProps, U extends ConfigurableProp>(props: DescriptionProps<T, U>) {
if (!props.field) {
console.log("props", props);
}
const {
field, markdown,
} = props;
Expand Down
Loading
Loading