Repository navigation
Package dashboard components as @bruin-data/dac-ui - #121
Conversation
- Pluggable DataClient for widget data; defaults to the dac server API - Library build (make frontend-lib) and dac-ui.tgz release asset - Component styles split into src/styles/dac.css - Geist fonts bundled instead of loaded from a CDN - Vega-Lite rendered with the expression interpreter (no 'unsafe-eval' needed) - Embedding docs
|
[Medium impact] The change reaches DAC dashboard users and React apps embedding its UI. The client-switch fix needs one more change before merging: stop showing the previous client’s data while the replacement loads. Reviews (2) · Last reviewed commit: "Namespace query caches per data client a..." · Reviewed by Greptile |
| return useQuery<WidgetData>({ | ||
| queryKey: ["widget-data", dashboardName, widgetId, filters], | ||
| queryFn: () => fetchWidgetData(dashboardName, widgetId, filters), | ||
| queryFn: () => client.fetchWidgetData(dashboardName, widgetId, filters), |
There was a problem hiding this comment.
Different clients share cached data
If two DataClientProvider instances share a QueryClient, matching dashboard names, widget IDs, and filters select the same cached result even when the clients fetch different data. Both widgets can show one client's results. Replacing the client prop also leaves the old cache entry selected.
Give each data source a stable cache namespace and include it in widget, dashboard, dashboard-list, and filter-option query keys.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/hooks/useWidgetQuery.ts
Line: 19
Comment:
**Different clients share cached data**
If two `DataClientProvider` instances share a `QueryClient`, matching dashboard names, widget IDs, and filters select the same cached result even when the clients fetch different data. Both widgets can show one client's results. Replacing the `client` prop also leaves the old cache entry selected.
Give each data source a stable cache namespace and include it in widget, dashboard, dashboard-list, and filter-option query keys.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Fixed in 6134dcf: query keys now include a per-client id, so clients sharing a QueryClient keep separate caches.
Packages the dashboard widgets, filter bar and layout as
@bruin-data/dac-ui, so other React apps can render dac dashboards with their own data source.dac serve,dac buildand the embed build behave as before.DataClientcontext for dashboard and widget data; the default is the existing dac server clientmake frontend-libbuilds the package; releases attach it asdac-ui.tgzsrc/styles/dac.css'unsafe-eval'TemplateProvidertakes an optionalclassName