From 5d92e9e072cfd6adebad935f81198a42d5858252 Mon Sep 17 00:00:00 2001 From: Jules Vautier Date: Thu, 20 Jun 2024 20:03:43 +0200 Subject: [PATCH] Jules/fix ci (#5145) * Update caniuse-lite and fix eslint issue * Fix Eslint errors * Avoid warning by suing useEffect on aggragation update * Remove console log --- .../QueryEditor/AggregationEditor.tsx | 15 ++++------ .../SearchResult/AggregationResult.tsx | 1 - .../components/SearchResult/SearchResult.tsx | 30 +++++++++---------- quickwit/quickwit-ui/yarn.lock | 6 ++-- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/quickwit/quickwit-ui/src/components/QueryEditor/AggregationEditor.tsx b/quickwit/quickwit-ui/src/components/QueryEditor/AggregationEditor.tsx index 98d97a19ac2..77e9805fd97 100644 --- a/quickwit/quickwit-ui/src/components/QueryEditor/AggregationEditor.tsx +++ b/quickwit/quickwit-ui/src/components/QueryEditor/AggregationEditor.tsx @@ -98,7 +98,6 @@ export function MetricKind(props: SearchComponentProps) { } export function AggregationKind(props: SearchComponentProps) { - props; const defaultAgg = { histogram: { interval: "1d", @@ -117,12 +116,14 @@ export function AggregationKind(props: SearchComponentProps) { } }, []); // Empty dependency array means this runs once after mount - const updateAggregationProp = (newAggregations: ({term: TermAgg} | {histogram: HistogramAgg})[]) => { + useEffect(() => { + // Update search request whenever aggregations change const metric = props.searchRequest.aggregationConfig.metric; - const updatedAggregation = Object.assign({}, {metric: metric}, ...newAggregations); - const updatedSearchRequest = {...props.searchRequest, aggregationConfig: updatedAggregation}; + const updatedAggregation = Object.assign({}, { metric: metric }, ...aggregations); + const updatedSearchRequest = { ...props.searchRequest, aggregationConfig: updatedAggregation }; props.onSearchRequestUpdate(updatedSearchRequest); - }; + }, [aggregations]); + const handleAggregationChange = (pos: number, event: SelectChangeEvent) => { const value = event.target.value; @@ -150,7 +151,6 @@ export function AggregationKind(props: SearchComponentProps) { newAggregations.splice(pos, 1); } } - updateAggregationProp(newAggregations); return newAggregations; }); }; @@ -160,7 +160,6 @@ export function AggregationKind(props: SearchComponentProps) { setAggregations((agg) => { const newAggregations = [...agg]; newAggregations[pos] = {histogram: {interval:value}}; - updateAggregationProp(newAggregations); return newAggregations; }); } @@ -173,7 +172,6 @@ export function AggregationKind(props: SearchComponentProps) { if (isTerm(term)) { term.term.field = value; } - updateAggregationProp(newAggregations); return newAggregations; }); }; @@ -186,7 +184,6 @@ export function AggregationKind(props: SearchComponentProps) { if (isTerm(term)) { term.term.size = Number(value); } - updateAggregationProp(newAggregations); return newAggregations; }); }; diff --git a/quickwit/quickwit-ui/src/components/SearchResult/AggregationResult.tsx b/quickwit/quickwit-ui/src/components/SearchResult/AggregationResult.tsx index 8649eeae750..e5d137c1f61 100644 --- a/quickwit/quickwit-ui/src/components/SearchResult/AggregationResult.tsx +++ b/quickwit/quickwit-ui/src/components/SearchResult/AggregationResult.tsx @@ -47,7 +47,6 @@ export function AggregationResult({searchResponse}: {searchResponse: SearchRespo data: line.value, }; }); - series; // we don't customize colors because we would need a full palette. return ( { + if (props.searchResponse == null || props.index == null) { + return null; + } else if (props.searchResponse.aggregations === undefined) { + return ; + } else { + return ; + } + }, [props.searchResponse, props.index]); + if (props.queryRunning) { - return + return ; } + if (props.searchError !== null) { return ErrorResponseDisplay(props.searchError); } + if (props.searchResponse == null || props.index == null) { - return <> + return <>; } - // try to improve typing experience by caching the costly-to-render components - // in practice this doesn't seem to have much impact - const result = useMemo( - () => { - if (props.searchResponse == null || props.index == null) { - return null; - } else if (props.searchResponse.aggregations === undefined) { - return (); - } else { - return (); - } - }, - [props.searchResponse, props.index] - ); return ( diff --git a/quickwit/quickwit-ui/yarn.lock b/quickwit/quickwit-ui/yarn.lock index 7e0a066f6e2..a6728df0eae 100644 --- a/quickwit/quickwit-ui/yarn.lock +++ b/quickwit/quickwit-ui/yarn.lock @@ -4910,9 +4910,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426, caniuse-lite@^1.0.30001541: - version "1.0.30001551" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001551.tgz" - integrity sha512-vtBAez47BoGMMzlbYhfXrMV1kvRF2WP/lqiMuDu1Sb4EE4LKEgjopFDSRtZfdVnslNRpOqV/woE+Xgrwj6VQlg== + version "1.0.30001636" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz" + integrity sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg== case-sensitive-paths-webpack-plugin@^2.4.0: version "2.4.0"