bito-code-review[bot] commented on code in PR #43634:
URL: https://github.com/apache/superset/pull/43634#discussion_r3878749781
##########
superset-frontend/src/pages/ChartList/index.tsx:
##########
@@ -260,11 +261,33 @@ function ChartList(props: ChartListProps) {
},
setResourceCollection: setCharts,
hasPerm,
- fetchData,
+ fetchData: fetchChartData,
toggleBulkSelect,
refreshData,
} = useListViewResource<Chart>('chart', t('chart'), addDangerToast);
+ const fetchData = useCallback(
+ (config: ListViewFetchDataConfig) =>
+ fetchChartData({
+ ...config,
+ ...(config.sortBy[0]?.id === 'viz_type'
+ ? {
+ extraQueryParams: {
+ viz_type_names: Object.fromEntries(
+ registry
+ .keys()
+ .map(vizType => [
+ vizType,
+ registry.get(vizType)?.name || vizType,
+ ]),
+ ),
+ },
+ }
+ : {}),
+ }),
+ [fetchChartData],
+ );
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>refreshData bypasses wrapper</b></div>
<div id="fix">
The hook's `refreshData` (from `useListViewResource`) calls its internal
`fetchData` — which is now `fetchChartData` after the rename — bypassing the
new wrapper. When `refreshData` is invoked (e.g., after bulk delete at line
1078, import at line 430, or favorite toggle), the `viz_type_names`
extraQueryParams is lost, so the viz_type sort order falls back to alphabetical
instead of the friendly registry-based ordering defined in
`superset/charts/api.py` (lines 191-203). Either override `refreshData` locally
to call the wrapper, or extend the hook to accept a custom `fetchData` for
refresh.
</div>
</div>
<small><i>Code Review Run #102670</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]