-
Notifications
You must be signed in to change notification settings - Fork 83
feat(webui): Add guided query mode button; Add a temporary env var to enable the guided query mode. #1276
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
feat(webui): Add guided query mode button; Add a temporary env var to enable the guided query mode. #1276
Changes from 9 commits
8950097
6fb4130
0168234
05b9f93
306ef27
a2b89dc
f3319ee
6fc634d
396fe26
0590636
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,8 @@ | |||||||||||||||||||||||||||||
| "build": "tsc -b && vite build", | ||||||||||||||||||||||||||||||
| "lint:check": "eslint", | ||||||||||||||||||||||||||||||
| "lint:fix": "eslint --fix", | ||||||||||||||||||||||||||||||
| "start": "vite" | ||||||||||||||||||||||||||||||
| "start": "vite", | ||||||||||||||||||||||||||||||
| "guided": "VITE_GUIDED_DEV=true npm run start" | ||||||||||||||||||||||||||||||
|
Comment on lines
7
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add a production build variant for the guided mode. Ensure the flag is exercised in CI and producible bundles. "scripts": {
"build": "tsc -b && vite build",
+ "build:guided": "cross-env VITE_GUIDED_DEV=true vite build",Please confirm any runtime checks use string coercion, e.g., import.meta.env.VITE_GUIDED_DEV === "true". 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| "author": "YScope Inc. <[email protected]>", | ||||||||||||||||||||||||||||||
| "license": "Apache-2.0", | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import {EditOutlined} from "@ant-design/icons"; | ||
| import {Button} from "antd"; | ||
|
|
||
| import usePrestoSearchState from "../../../../SearchState/Presto"; | ||
| import {PRESTO_SQL_INTERFACE} from "../../../../SearchState/Presto/typings"; | ||
|
|
||
|
|
||
| /** | ||
| * Renders a button to switch to Freeform SQL interface. | ||
| * | ||
| * @return | ||
| */ | ||
| const FreeformButton = () => { | ||
| const setSqlInterface = usePrestoSearchState((state) => state.setSqlInterface); | ||
|
|
||
| const handleClick = () => { | ||
| setSqlInterface(PRESTO_SQL_INTERFACE.FREEFORM); | ||
| }; | ||
|
|
||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return ( | ||
| <Button | ||
| block={true} | ||
| color={"default"} | ||
| icon={<EditOutlined/>} | ||
| size={"middle"} | ||
| variant={"filled"} | ||
| onClick={handleClick} | ||
| > | ||
| Freeform | ||
| </Button> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| export default FreeformButton; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {AppstoreOutlined} from "@ant-design/icons"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {Button} from "antd"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import usePrestoSearchState from "../../../../SearchState/Presto"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {PRESTO_SQL_INTERFACE} from "../../../../SearchState/Presto/typings"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Renders a button to switch to Guided SQL interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const GuidedButton = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const setSqlInterface = usePrestoSearchState((state) => state.setSqlInterface); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleClick = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSqlInterface(PRESTO_SQL_INTERFACE.GUIDED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add accessible pressed state and avoid redundant no-op clicks. Expose Apply: -const GuidedButton = () => {
- const setSqlInterface = usePrestoSearchState((state) => state.setSqlInterface);
+const GuidedButton = () => {
+ const sqlInterface = usePrestoSearchState((s) => s.sqlInterface);
+ const setSqlInterface = usePrestoSearchState((s) => s.setSqlInterface);
- const handleClick = () => {
- setSqlInterface(PRESTO_SQL_INTERFACE.GUIDED);
- };
+ const handleClick = () => {
+ if (sqlInterface !== PRESTO_SQL_INTERFACE.GUIDED) {
+ setSqlInterface(PRESTO_SQL_INTERFACE.GUIDED);
+ }
+ };And in the Button: - <Button
+ <Button
+ aria-pressed={sqlInterface === PRESTO_SQL_INTERFACE.GUIDED}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| block={true} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| color={"default"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| icon={<AppstoreOutlined/>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| size={"middle"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant={"filled"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={handleClick} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guided | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default GuidedButton; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .sqlInterfaceButton { | ||
| width: 100px; | ||
| } | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import usePrestoSearchState from "../../../SearchState/Presto"; | ||
| import {PRESTO_SQL_INTERFACE} from "../../../SearchState/Presto/typings"; | ||
| import FreeformButton from "./FreeformButton"; | ||
| import GuidedButton from "./GuidedButton"; | ||
| import styles from "./index.module.css"; | ||
|
|
||
|
|
||
| /** | ||
| * Renders the button to switch Presto SQL interface. | ||
| * | ||
| * @return | ||
| */ | ||
| const SqlInterfaceButton = () => { | ||
| const sqlInterface = usePrestoSearchState((state) => state.sqlInterface); | ||
|
|
||
| return ( | ||
| <div className={styles["sqlInterfaceButton"]}> | ||
davemarco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {sqlInterface === PRESTO_SQL_INTERFACE.GUIDED ? | ||
| <FreeformButton/> : | ||
| <GuidedButton/>} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SqlInterfaceButton; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |||||||||||||||||||||||||
| } from "../../../config"; | ||||||||||||||||||||||||||
| import Dataset from "./Dataset"; | ||||||||||||||||||||||||||
| import styles from "./index.module.css"; | ||||||||||||||||||||||||||
| import SqlInterfaceButton from "./Presto/SqlInterfaceButton"; | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Code-split the guided button Avoid loading guided-mode UI when the flag is false by lazy-loading the component. -import SqlInterfaceButton from "./Presto/SqlInterfaceButton";
+import { lazy, Suspense } from "react";Outside the selected range, add the lazy binding near the imports: const SqlInterfaceButton = lazy(() => import("./Presto/SqlInterfaceButton"));🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| import SqlQueryInput from "./Presto/SqlQueryInput"; | ||||||||||||||||||||||||||
| import SqlSearchButton from "./Presto/SqlSearchButton"; | ||||||||||||||||||||||||||
| import QueryInput from "./QueryInput"; | ||||||||||||||||||||||||||
|
|
@@ -29,6 +30,10 @@ const handleSubmit = (ev: React.FormEvent<HTMLFormElement>) => { | |||||||||||||||||||||||||
| * @return | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| const SearchControls = () => { | ||||||||||||||||||||||||||
| /* eslint-disable-next-line no-warning-comments */ | ||||||||||||||||||||||||||
| // TODO: Remove flag and related logic when the new guide UI is fully implemented. | ||||||||||||||||||||||||||
| const isGuidedEnabled = "true" === import.meta.env.VITE_GUIDED_DEV; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||
| <form onSubmit={handleSubmit}> | ||||||||||||||||||||||||||
| {SETTINGS_QUERY_ENGINE !== CLP_QUERY_ENGINES.PRESTO ? | ||||||||||||||||||||||||||
|
|
@@ -48,11 +53,14 @@ const SearchControls = () => { | |||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||
| <div className={styles["searchControlsContainer"]}> | ||||||||||||||||||||||||||
| <SqlQueryInput/> | ||||||||||||||||||||||||||
| <div className={styles["buttonAndStatusRow"]}> | ||||||||||||||||||||||||||
| <div className={styles["statusAndButtonsRow"]}> | ||||||||||||||||||||||||||
| <div className={styles["status"]}> | ||||||||||||||||||||||||||
| <QueryStatus/> | ||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||
| <SqlSearchButton/> | ||||||||||||||||||||||||||
| <div className={styles["buttons"]}> | ||||||||||||||||||||||||||
| {isGuidedEnabled && <SqlInterfaceButton/>} | ||||||||||||||||||||||||||
| <SqlSearchButton/> | ||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||
|
Comment on lines
+60
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Wrap lazy component in Suspense Pairing with the lazy import above. - {isGuidedEnabled && <SqlInterfaceButton/>}
- <SqlSearchButton/>
+ {isGuidedEnabled && (
+ <Suspense fallback={null}>
+ <SqlInterfaceButton/>
+ </Suspense>
+ )}
+ <SqlSearchButton/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import {create} from "zustand"; | ||
|
|
||
| import {PRESTO_SQL_INTERFACE} from "./typings"; | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| /** | ||
| * Default values of the Presto search state. | ||
| */ | ||
| const PRESTO_SEARCH_STATE_DEFAULT = Object.freeze({ | ||
| sqlInterface: PRESTO_SQL_INTERFACE.FREEFORM, | ||
| }); | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| interface PrestoSearchState { | ||
| /** | ||
| * Presto SQL interface. | ||
| */ | ||
| sqlInterface: PRESTO_SQL_INTERFACE; | ||
|
|
||
| setSqlInterface: (iface: PRESTO_SQL_INTERFACE) => void; | ||
| } | ||
|
|
||
| const usePrestoSearchState = create<PrestoSearchState>((set) => ({ | ||
| ...PRESTO_SEARCH_STATE_DEFAULT, | ||
| setSqlInterface: (iface) => { | ||
| set({sqlInterface: iface}); | ||
| }, | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| })); | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export {PRESTO_SEARCH_STATE_DEFAULT}; | ||
| export default usePrestoSearchState; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /** | ||
| * Presto SQL interface types. | ||
| */ | ||
| export enum PRESTO_SQL_INTERFACE { | ||
| /** | ||
| * Guided interface with limited SQL dialect. | ||
| */ | ||
| GUIDED = "guided", | ||
|
|
||
| /** | ||
| * Freeform interface with SQL editor. | ||
| */ | ||
| FREEFORM = "freeform", | ||
| } | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.