Repository navigation
feat(new-webui): Adds search job ID and number of search results to search page. #962
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
Changes from 12 commits
2144448
d88bb6b
740644b
658bf0f
0cf2801
17e0c26
1ac83b1
8d0e7f6
e125f6f
2d5beb6
6cfdb86
eae67a6
cf476f5
83ce6db
ef93fb2
4792bf0
71644fb
5edc36a
1f2c938
6452d31
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import {useMemo} from "react"; | ||
|
|
||
| import { | ||
| GetProps, | ||
| Typography, | ||
| } from "antd"; | ||
|
|
||
| import useSearchStore from "../SearchState/index"; | ||
| import {SEARCH_UI_STATE} from "../SearchState/typings"; | ||
|
|
||
|
|
||
| const {Text} = Typography; | ||
| type TextTypes = GetProps<typeof Text>["type"]; | ||
|
|
||
|
|
||
| /** | ||
| * Displays the number of search results. | ||
| * | ||
| * @return | ||
| */ | ||
| const Results = () => { | ||
| const { | ||
| numSearchResultsTimeline, | ||
| numSearchResultsTable, | ||
| searchUiState, | ||
| } = useSearchStore(); | ||
|
davemarco marked this conversation as resolved.
Resolved
|
||
|
|
||
| // Number of results is the maximum of the number of results in the timeline and table. The | ||
| // timeline may have more results since the table results are capped. Having two sources may | ||
| // be provide more timely update to the user. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| const numResults = useMemo( | ||
| () => Math.max(numSearchResultsTimeline, numSearchResultsTable), | ||
| [ | ||
| numSearchResultsTimeline, | ||
| numSearchResultsTable, | ||
| ] | ||
| ); | ||
|
|
||
| let textType: TextTypes; | ||
| switch (searchUiState) { | ||
| case SEARCH_UI_STATE.QUERYING: | ||
| textType = "warning"; | ||
| break; | ||
| case SEARCH_UI_STATE.DEFAULT: | ||
| case SEARCH_UI_STATE.QUERY_ID_PENDING: | ||
| textType = "secondary"; | ||
| break; | ||
| case SEARCH_UI_STATE.DONE: | ||
| textType = "success"; | ||
| break; | ||
| default: | ||
| textType = "secondary"; | ||
| } | ||
|
|
||
| return ( | ||
| <Text | ||
| strong={true} | ||
| type={textType} | ||
| > | ||
| {numResults} | ||
| </Text> | ||
| ); | ||
| }; | ||
|
|
||
| export default Results; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .status { | ||
| margin-left: 2px; | ||
| margin-top: 4px; | ||
| } | ||
|
|
||
| .badge { | ||
| padding-bottom: 4px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import {Typography} from "antd"; | ||
|
|
||
| import useSearchStore from "../SearchState/index"; | ||
| import {SEARCH_UI_STATE} from "../SearchState/typings"; | ||
| import styles from "./index.module.css"; | ||
| import Results from "./Results"; | ||
|
|
||
|
|
||
| const {Text} = Typography; | ||
|
|
||
| /** | ||
| * Displays the search job ID and the number of results found. | ||
| * | ||
| * @return | ||
| */ | ||
| const SearchQueryStatus = () => { | ||
| const { | ||
| searchJobId, | ||
| searchUiState, | ||
| } = useSearchStore(); | ||
|
|
||
| return ( | ||
| <div className={styles["status"]}> | ||
| {(searchUiState === SEARCH_UI_STATE.QUERYING || | ||
| searchUiState === SEARCH_UI_STATE.DONE) && ( | ||
| <Text type={"secondary"}> | ||
| Search job # | ||
| {searchJobId} | ||
| {" "} | ||
| found | ||
| {" "} | ||
| </Text> | ||
| )} | ||
| <Results/> | ||
| <Text type={"secondary"}> results</Text> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| export default SearchQueryStatus; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ import {SEARCH_UI_STATE} from "./typings"; | |
| */ | ||
| const SEARCH_STATE_DEFAULT = Object.freeze({ | ||
| aggregationJobId: null, | ||
| numSearchResultsTable: 0, | ||
| numSearchResultsTimeline: 0, | ||
| queryIsCaseSensitive: false, | ||
| queryString: "", | ||
| searchJobId: null, | ||
|
|
@@ -32,6 +34,16 @@ interface SearchState { | |
| */ | ||
| aggregationJobId: string | null; | ||
|
|
||
| /** | ||
| * The number of search table results. | ||
| */ | ||
| numSearchResultsTable: number; | ||
|
|
||
| /** | ||
| * The number of timeline results. | ||
| */ | ||
| numSearchResultsTimeline: number; | ||
|
|
||
| /** | ||
| * Whether the query is case sensitive. | ||
| */ | ||
|
|
@@ -70,6 +82,8 @@ interface SearchState { | |
| timelineConfig: TimelineConfig; | ||
|
|
||
| updateAggregationJobId: (id: string | null) => void; | ||
|
Member
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. following our latest (undocumented yet - sorry!) Zustand practices, Zustand actions that do not perform more actions than state settings should be prefixed with |
||
| updateNumSearchResultsTable: (num: number) => void; | ||
| updateNumSearchResultsTimeline: (num: number) => void; | ||
| updateQueryIsCaseSensitive: (newValue: boolean) => void; | ||
| updateQueryString: (query: string) => void; | ||
| updateSearchJobId: (id: string | null) => void; | ||
|
|
@@ -84,6 +98,12 @@ const useSearchStore = create<SearchState>((set) => ({ | |
| updateAggregationJobId: (id) => { | ||
| set({aggregationJobId: id}); | ||
| }, | ||
| updateNumSearchResultsTable: (num) => { | ||
| set({numSearchResultsTable: num}); | ||
| }, | ||
| updateNumSearchResultsTimeline: (num) => { | ||
| set({numSearchResultsTimeline: num}); | ||
| }, | ||
| updateQueryIsCaseSensitive: (newValue: boolean) => { | ||
| set({queryIsCaseSensitive: newValue}); | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,4 +48,5 @@ const useResultsMetadata = () => { | |
| return resultsMetadata; | ||
| }; | ||
|
|
||
|
|
||
|
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) Remove unnecessary blank line before export The blank line added at line 51 serves no functional purpose and may introduce trailing whitespace. Please remove it to keep formatting consistent. 🤖 Prompt for AI Agents |
||
| export {useResultsMetadata}; | ||
Uh oh!
There was an error while loading. Please reload this page.