-
Notifications
You must be signed in to change notification settings - Fork 83
feat(webui): Replace FROM input on guided Presto UI with a dataset selector. #1314
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 all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
004a12d
latest
7194d78
latest
d5fc91f
Merge branch 'main' into inputMona
dc79169
latest
52e83a3
latest
630a360
Merge branch 'main' into inputMona
davemarco aa3968c
latest
fb61505
latest
af4a2b0
latest
202d002
latest
6aa31be
latest
2cc9f2f
merge
e30211e
latest
a8daeb2
latest
148379c
latest
d8ec46c
latest
84a5840
latest
6c3a065
Merge branch 'main' into playout
davemarco 8da8133
lint
cfae7cc
Merge branch 'playout' of https://github.com/davemarco/clp into playout
7a3b7f9
latest
8d41f91
latest
10f9a2d
latest
1f2a97d
Merge branch 'main' into playout
96b46a1
latest
7eb61ac
Merge branch 'main' into playout
davemarco 847da48
latest
0631199
latest
96e8965
Merge branch 'playout' of https://github.com/davemarco/clp into playout
0db25b1
latest
a18abc3
Merge branch 'main' into playout
davemarco 1a30f7e
latest
c4e7840
Merge branch 'main' into newFrom2
davemarco e6c8d93
latest
d9ee25e
Merge branch 'main' into newFrom2
davemarco edefa6e
Merge branch 'main' into newFrom2
hoophalab 6b85632
Merge branch 'main' into newFrom2
davemarco 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
70 changes: 70 additions & 0 deletions
70
components/webui/client/src/pages/SearchPage/SearchControls/Dataset/DatasetSelect.tsx
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,70 @@ | ||
| import {useEffect} from "react"; | ||
| import {useQuery} from "@tanstack/react-query"; | ||
| import {message, Select, SelectProps} from "antd"; | ||
| import useSearchStore from "../../SearchState/index"; | ||
| import {SEARCH_UI_STATE} from "../../SearchState/typings"; | ||
| import {fetchDatasetNames} from "./sql"; | ||
|
|
||
| const DatasetSelect = (selectProps: SelectProps) => { | ||
| const dataset = useSearchStore((state) => state.selectDataset); | ||
| const updateDataset = useSearchStore((state) => state.updateSelectDataset); | ||
| const searchUiState = useSearchStore((state) => state.searchUiState); | ||
|
|
||
| const [messageApi, contextHolder] = message.useMessage(); | ||
|
|
||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const {data, isPending, isSuccess, error} = useQuery({ | ||
| queryKey: ["datasets"], | ||
| queryFn: fetchDatasetNames, | ||
| }); | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| useEffect(() => { | ||
| if (isSuccess) { | ||
| if ("undefined" !== typeof data[0] && null === dataset) { | ||
| updateDataset(data[0]); | ||
| } | ||
| } | ||
| }, [isSuccess, data, dataset, updateDataset]); | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| useEffect(() => { | ||
| if (error) { | ||
| messageApi.error({ | ||
| key: "fetchError", | ||
| content: "Error fetching datasets.", | ||
| }); | ||
| } | ||
| }, [error, messageApi]); | ||
|
|
||
| useEffect(() => { | ||
| if (isSuccess && 0 === data.length) { | ||
| messageApi.warning({ | ||
| key: "noData", | ||
| content: "No data has been ingested. Please ingest data to search.", | ||
| }); | ||
| updateDataset(null); | ||
| } | ||
| }, [data, isSuccess, messageApi, updateDataset]); | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const handleDatasetChange = (value: string) => { | ||
| updateDataset(value); | ||
| }; | ||
|
|
||
| return ( | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <> | ||
| {contextHolder} | ||
| <Select | ||
| loading={isPending} | ||
| options={(data || []).map((option) => ({label: option, value: option}))} | ||
| value={dataset} | ||
| size="middle" | ||
| disabled={ | ||
| searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING || | ||
| searchUiState === SEARCH_UI_STATE.QUERYING | ||
| } | ||
| onChange={handleDatasetChange} | ||
| {...selectProps} | ||
| /> | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default DatasetSelect; | ||
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.