[APP-538] feat: canvas default filter support
This PR adds support for specifying default time, dimension and measure filters to apply when loading a Canvas dashboard for the first time. When using the builder surface in Rill Developer, the workspace provides a quick way to save the currently selected filters as default, which would propagate to the YAML as metrics SQL statements:
type: canvas
defaults:
time_range: 6h as of latest/m+1m
filters:
AdBids_metrics: (publisher IN ('Facebook', 'Google')) AND (publisher IN (SELECT publisher
FROM metrics_view HAVING total_records > 200))
To support the use of multiple metrics views across a single canvas, these metrics SQL filters are keyed with the name of the underlying metrics view.
- Filters are handled on a per-metrics-view basis via instances of the new
FilterStateclass - Filter consolidation and rendering across multiple
FilterStateclasses happens through the newFilterManager - URL filters are keyed with a string that takes the form
f.{{metrics_view_name}} - Each
FilterStateclass has actions on it that allow for filter state manipulation - The
FilterManagerclass has proxies for these functions to call them across multipleFilterStateclasses - Consolidation of the namespace across multiple metrics views currently assumes that all dimensions/measures with equivalent identifiers are the same
- Canvas initialization now happens through the
CanvasProvidercomponent no matter where a Canvas is rendered - When adding a filter for a measure/dimension that exists across multiple metrics views, it is added to each
FilterStateclass (and to the URL) independently, though the actual URL navigation is batched for each user action - Canvas loading, url param syncing and redirecting happens through the
onUrlChangefunction as well as updated getters and setters incanvas/state-managers.ts - Removes use of
RuntimeProviderfor embeds, sets the runtime in the topmost layout load function instead - A new "save defaults" button is added to update the YAML defaults with the current filter state
- Refactors canvas time state management to use
TimeManagerandTimeStateclasses
Outstanding items:
- [x] Update designs (and implementation) to reflect "pin" behavior rather than lock @Di7design
- [x] Remove old Filter class if possible
- [x] Ensure changes did not break Explore
- [x] Ensure prior filter strings (without scoped metrics view) work as intended
- [x] Fix tests
- [x] Abstract UI filter parsing method and apply to defaults
- [x] Fix issue with measure filter pills not updating on first apply
- [x] Update CanvasFilterButton to display labels rather than unique ids
- [x] Match sidebar design to Figma
- [x] Add pinning capability to measures
- [x] Resolve issue where unpinning does not immediately reflect in pill
- [x] Add "saved as default" state to button when viewing defaults
- [x] Resolve issue where filter dropdown reopens after applying selections
- [ ] Bring back measure-specific dimension lists
Checklist:
- [x] Covered by tests
- [x] Ran it and it works as intended
- [x] Reviewed the diff before requesting a review
- [x] Checked for unhandled edge cases
- [x] Linked the issues it closes
- [x] Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
- [ ] Intend to cherry-pick into the release branch
- [x] I'm proud of this work!
[!NOTE] Adds per-metrics-view canvas filtering with pinning and saved defaults, updates URL/schema and parser, refactors initialization/embeds, and introduces new UI to manage and display default/pinned filters.
- Canvas filtering overhaul:
- Introduces per-metrics-view filtering via
FilterManagerandMetricsViewFilterwith consolidated UI/state.- Adds default filters and pinning (save/clear defaults; pinned chips), new inspector tabs, and read-only chips.
- Updates URL schema to scoped filters (
f.{metrics_view}) and batching of navigation.- Protocol & API:
- Extends
CanvasSpecwithpinned_filters;CanvasPresetwithfilter_expr; updates Swagger/TS/Go protobufs.- Parser reads
filters.pinnedanddefaults.filtersfrom YAML.- Runtime/initialization:
- New
handleCanvasStoreInitializationandonUrlChange; removesRuntimeProviderfor embeds; sets runtime in layout.- UI components:
- New
SaveDefaultsButton, default filters display; enhancedChip(pin/gray), filter buttons/chips; time/comparison tweaks.- Embeds/routes:
- Canvas embed and app routes refactored to initialize/store canvas and sync URL.
- Cleanup & tests:
- Removes old
Filtersclass; updates bookmark handling and tests to new comparison/filters.Written by Cursor Bugbot for commit defa8bf68d2e389b012d9127dd20306612789ee5. This will update automatically on new commits. Configure here.
See Figma here.
@briangregoryholmes : Is this ready for review ? Still on track for the release next week?
@briangregoryholmes Some issues with the latest build:
https://www.loom.com/share/47fd9eba4acc4cf9babd3c314e3d1663
@ericokuma Should be fixed as soon as this lands: https://github.com/rilldata/rill/pull/8472
UX looks good to me
@Di7design
This branch is functional, but we might need further iteration.
Looks good @briangregoryholmes
Great job everyone!