-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Adding support for the sql prop type in connect-react #17011
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5dc5e62
Getting the UI working, SQL isn't yet working
dannyroosevelt 3d080a6
SQL queries are working
dannyroosevelt acb021a
Update pnpm-lock.yaml
dannyroosevelt 9e6006c
Update pnpm-lock.yaml
dannyroosevelt f32642e
Fixing up sql prop handling and PR feedback
dannyroosevelt fd5de80
Merge branch 'master' into danny/connect-react/sql
dannyroosevelt 7c3674a
Changelog, versions, and linting
dannyroosevelt e59110d
Update ControlSql.tsx
dannyroosevelt 6d40539
Revert SDK changes to isolate connect-react changes
dannyroosevelt b102eb5
Reverting version and changelog from /sdk
dannyroosevelt 7195ac5
Merge branch 'master' into danny/connect-react/sql
dannyroosevelt 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 hidden or 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 hidden or 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,64 @@ | ||
| import { useFormFieldContext } from "../hooks/form-field-context"; | ||
| import { useFormContext } from "../hooks/form-context"; | ||
| import { useCustomize } from "../hooks/customization-context"; | ||
| import type { CSSProperties } from "react"; | ||
|
|
||
| export function ControlSql() { | ||
| const formFieldContext = useFormFieldContext(); | ||
| const formContext = useFormContext(); | ||
| const { | ||
| id, onChange, prop, value, | ||
| } = formFieldContext; | ||
| const { | ||
| getProps, theme, | ||
| } = useCustomize(); | ||
|
|
||
| // Find the first app prop to determine which database app to use | ||
| const appProp = formContext.configurableProps.find((p: any) => p.type === "app"); | ||
| const appName = appProp?.app || "postgresql"; // Default to postgresql | ||
|
|
||
| // Extract the query string from the structured value or use empty string | ||
| const queryValue = typeof value === "object" && value && "query" in value | ||
| ? (value as any).query | ||
| : typeof value === "string" | ||
| ? value | ||
| : ""; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const handleChange = (queryText: string) => { | ||
| // Transform the simple query string into the structured SQL object | ||
| const sqlObject = { | ||
| app: appName, | ||
| query: queryText, | ||
| params: [], // For now, always empty array | ||
| }; | ||
| onChange(sqlObject); | ||
| }; | ||
|
|
||
| const baseStyles: CSSProperties = { | ||
| color: theme.colors.neutral60, | ||
| display: "block", | ||
| border: "1px solid", | ||
| borderColor: theme.colors.neutral20, | ||
| padding: 6, | ||
| width: "100%", | ||
| borderRadius: theme.borderRadius, | ||
| gridArea: "control", | ||
| boxShadow: theme.boxShadow.input, | ||
| fontSize: "0.875rem", | ||
| fontFamily: "monospace", | ||
| minHeight: "120px", | ||
| resize: "vertical", | ||
| }; | ||
|
|
||
| return ( | ||
| <textarea | ||
| id={id} | ||
| name={prop.name} | ||
| value={queryValue} | ||
| onChange={(e) => handleChange(e.target.value)} | ||
| placeholder="SELECT * FROM table_name" | ||
| required={!prop.optional} | ||
| {...getProps("controlSql", baseStyles, formFieldContext)} | ||
| /> | ||
| ); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.