-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into tauri-main
- Loading branch information
Showing
30 changed files
with
487 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,36 @@ | ||
import { keymap } from "@uiw/react-codemirror"; | ||
|
||
// Extension that blurs the editor when the user presses "Escape" | ||
export const escapeKeymap = keymap.of([ | ||
{ | ||
key: "Escape", | ||
run: (view) => { | ||
view.contentDOM.blur(); | ||
return true; | ||
}, | ||
}, | ||
]); | ||
|
||
/** | ||
* Creates a keymap that calls the given (optional) onSubmit function when the user presses "Mod-Enter" | ||
* | ||
* @param onSubmit - Function to call when the user presses "Mod-Enter" | ||
* @param bubbleWhenNoHandler - If there is no onSubmit function, let another extension handle the key event | ||
* @returns - Keymap that calls the onSubmit function when the user presses "Mod-Enter" | ||
*/ | ||
export const createOnSubmitKeymap = ( | ||
onSubmit: (() => void) | undefined, | ||
bubbleWhenNoHandler = true, | ||
) => | ||
keymap.of([ | ||
{ | ||
key: "Mod-Enter", | ||
run: () => { | ||
if (onSubmit) { | ||
onSubmit(); | ||
return true; | ||
} | ||
return bubbleWhenNoHandler; | ||
}, | ||
}, | ||
]); |
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { CollapsibleKeyValueTableV2 } from "./KeyValueTableV2"; | ||
export { TimelineListDetails } from "./TimelineDetailsList"; | ||
export { BodyViewerV2 } from "./BodyViewerV2"; | ||
export { useFormattedNeonQuery } from "./spans"; |
This file contains 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
29 changes: 29 additions & 0 deletions
29
studio/src/components/Timeline/DetailsList/spans/FetchSpan/hooks.ts
This file contains 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,29 @@ | ||
import { useMemo } from "react"; | ||
import { format } from "sql-formatter"; | ||
|
||
export function useFormattedNeonQuery( | ||
sql: { | ||
query: string; | ||
params?: string[]; | ||
}, | ||
options?: { | ||
tabWidth?: number; | ||
}, | ||
) { | ||
return useMemo(() => { | ||
try { | ||
const paramsFromNeon = sql.params ?? []; | ||
// NOTE - sql-formatter expects the index in the array to match the `$nr` syntax from postgres | ||
// this makes the 0th index unused, but it makes the rest of the indices match the `$1`, `$2`, etc. | ||
const params = ["", ...paramsFromNeon]; | ||
return format(sql.query, { | ||
language: "postgresql", | ||
params, | ||
tabWidth: options?.tabWidth ?? 2, | ||
}); | ||
} catch (_e) { | ||
// Being very defensive soz | ||
return sql?.query ?? ""; | ||
} | ||
}, [sql, options?.tabWidth]); | ||
} |
2 changes: 2 additions & 0 deletions
2
studio/src/components/Timeline/DetailsList/spans/FetchSpan/index.ts
This file contains 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,2 @@ | ||
export { FetchSpan } from "./FetchSpan"; | ||
export { useFormattedNeonQuery } from "./hooks"; |
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { GenericSpan } from "./GenericSpan"; | ||
export { IncomingRequest } from "./IncomingRequest"; | ||
export { FetchSpan } from "./FetchSpan"; | ||
export { useFormattedNeonQuery } from "./FetchSpan"; |
This file contains 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 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.