Skip to content

Commit

Permalink
Jules/fix ci (#5145)
Browse files Browse the repository at this point in the history
* Update caniuse-lite and fix eslint issue

* Fix Eslint errors

* Avoid warning by suing useEffect on aggragation update

* Remove console log
  • Loading branch information
JulesVautier-io authored Jun 20, 2024
1 parent 22dea2d commit 5d92e9e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export function MetricKind(props: SearchComponentProps) {
}

export function AggregationKind(props: SearchComponentProps) {
props;
const defaultAgg = {
histogram: {
interval: "1d",
Expand All @@ -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;
Expand Down Expand Up @@ -150,7 +151,6 @@ export function AggregationKind(props: SearchComponentProps) {
newAggregations.splice(pos, 1);
}
}
updateAggregationProp(newAggregations);
return newAggregations;
});
};
Expand All @@ -160,7 +160,6 @@ export function AggregationKind(props: SearchComponentProps) {
setAggregations((agg) => {
const newAggregations = [...agg];
newAggregations[pos] = {histogram: {interval:value}};
updateAggregationProp(newAggregations);
return newAggregations;
});
}
Expand All @@ -173,7 +172,6 @@ export function AggregationKind(props: SearchComponentProps) {
if (isTerm(term)) {
term.term.field = value;
}
updateAggregationProp(newAggregations);
return newAggregations;
});
};
Expand All @@ -186,7 +184,6 @@ export function AggregationKind(props: SearchComponentProps) {
if (isTerm(term)) {
term.term.size = Number(value);
}
updateAggregationProp(newAggregations);
return newAggregations;
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<LineChart
Expand Down
30 changes: 14 additions & 16 deletions quickwit/quickwit-ui/src/components/SearchResult/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,27 @@ interface SearchResultProps {
}

export default function SearchResult(props: SearchResultProps) {
const result = useMemo(() => {
if (props.searchResponse == null || props.index == null) {
return null;
} else if (props.searchResponse.aggregations === undefined) {
return <ResultTable searchResponse={props.searchResponse} index={props.index} />;
} else {
return <AggregationResult searchResponse={props.searchResponse} />;
}
}, [props.searchResponse, props.index]);

if (props.queryRunning) {
return <Loader />
return <Loader />;
}

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 (<ResultTable searchResponse={props.searchResponse} index={props.index} />);
} else {
return (<AggregationResult searchResponse={props.searchResponse} />);
}
},
[props.searchResponse, props.index]
);

return (
<Box sx={{ pt: 1, flexGrow: '1', flexBasis: '0%', overflow: 'hidden'}}>
Expand Down
6 changes: 3 additions & 3 deletions quickwit/quickwit-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5d92e9e

Please sign in to comment.