Skip to content

Commit 6782fe0

Browse files
authored
Je/connect react triggers (#14985)
* some progress, need to add apphook support * cleanup * . * remove * linting * package.json * lock * add timer to skips for now * don't need to remove apphook * changelog and package.json updates * Don't need this since we're punting on the timer control for now * fix * lock
1 parent 101db92 commit 6782fe0

File tree

8 files changed

+31
-8
lines changed

8 files changed

+31
-8
lines changed

components/boldsign/boldsign.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/callerapi/callerapi.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/calllerapi/calllerapi.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

packages/connect-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.13] - 2024-12-17
5+
6+
- Added skippable prop types to support triggers
7+
48
# [1.0.0-preview.12] - 2024-12-13
59

610
- Don't throw when validating unexpected values from the api

packages/connect-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.0.0-preview.12",
3+
"version": "1.0.0-preview.13",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { FormContext } from "../hooks/form-context";
22
import { FormFieldContext } from "../hooks/form-field-context";
3-
import { ConfigurableProp, ConfigurableProps } from "@pipedream/sdk";
3+
import {
4+
ConfigurableProp,
5+
ConfigurableProps,
6+
} from "@pipedream/sdk";
47
// import { ControlAny } from "./ControlAny"
58
import { ControlApp } from "./ControlApp";
69
import { ControlBoolean } from "./ControlBoolean";

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import type {
33
CSSProperties, FormEventHandler,
44
} from "react";
55
import { useCustomize } from "../hooks/customization-context";
6-
import { useFormContext } from "../hooks/form-context";
6+
import {
7+
useFormContext,
8+
skippablePropTypes,
9+
} from "../hooks/form-context";
710
import { InternalField } from "./InternalField";
811
import { Alert } from "./Alert";
912
import { ErrorBoundary } from "./ErrorBoundary";
@@ -73,6 +76,9 @@ export function InternalComponentForm() {
7376
if (prop.hidden) {
7477
continue;
7578
}
79+
if (skippablePropTypes.includes(prop.type)) {
80+
continue;
81+
}
7682
if (prop.optional) {
7783
const enabled = optionalPropIsEnabled(prop);
7884
optionalProps.push([

packages/connect-react/src/hooks/form-context.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ export type FormContext<T extends ConfigurableProps> = {
3838
userId: string;
3939
};
4040

41+
export const skippablePropTypes = [
42+
"$.service.db",
43+
"$.interface.http",
44+
"$.interface.apphook",
45+
"$.interface.timer", // TODO add support for this (cron string and timers)
46+
]
47+
4148
export const FormContext = createContext<FormContext<any /* XXX fix */> | undefined>(undefined); // eslint-disable-line @typescript-eslint/no-explicit-any
4249

4350
export const useFormContext = () => {
@@ -172,7 +179,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
172179
// so can't rely on that base control form validation
173180
const propErrors = (prop: ConfigurableProp, value: unknown): string[] => {
174181
const errs: string[] = [];
175-
if (prop.optional || prop.hidden || prop.disabled) return []
182+
if (prop.optional || prop.hidden || prop.disabled || skippablePropTypes.includes(prop.type)) return []
176183
if (prop.type === "app") {
177184
const field = fields[prop.name]
178185
if (field) {
@@ -247,6 +254,9 @@ export const FormContextProvider = <T extends ConfigurableProps>({
247254
if (prop.hidden) {
248255
continue;
249256
}
257+
if (skippablePropTypes.includes(prop.type)) {
258+
continue;
259+
}
250260
// if prop.optional and not shown, we skip and do on un-collapse
251261
if (prop.optional && !optionalPropIsEnabled(prop)) {
252262
continue;
@@ -336,7 +346,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
336346
const checkPropsNeedConfiguring = () => {
337347
const _propsNeedConfiguring = []
338348
for (const prop of configurableProps) {
339-
if (!prop || prop.optional || prop.hidden) continue
349+
if (!prop || prop.optional || prop.hidden || skippablePropTypes.includes(prop.type)) continue
340350
const value = configuredProps[prop.name as keyof ConfiguredProps<T>]
341351
const errors = propErrors(prop, value)
342352
if (errors.length) {

0 commit comments

Comments
 (0)