Repository navigation
feat: Optionally apply dashboard filters to tile editor preview #3093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@hyperdx/common-utils': patch | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat: Optionally apply the dashboard's filter selections to the tile editor preview |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ import { | |
| buildRenderedPromqlExpression, | ||
| buildSampleEventsConfig, | ||
| isQueryReady, | ||
| tabQueriesData, | ||
| } from './utils'; | ||
|
|
||
| /** Why a preview accordion is empty before its tile has been run. */ | ||
|
|
@@ -142,6 +143,8 @@ type ChartPreviewPanelProps = { | |
| showSampleEvents: boolean; | ||
| showGeneratedPromql: boolean; | ||
| dbTimeChartConfig?: ChartConfigWithDateRange; | ||
| /** Required dashboard filters with nothing selected that block this tile. */ | ||
| missingRequiredFilterNames?: string[]; | ||
| setValue: (name: 'orderBy', value: string) => void; | ||
| onSubmit: () => void; | ||
| }; | ||
|
|
@@ -159,6 +162,7 @@ export function ChartPreviewPanel({ | |
| showSampleEvents, | ||
| showGeneratedPromql, | ||
| dbTimeChartConfig, | ||
| missingRequiredFilterNames, | ||
| setValue, | ||
| onSubmit, | ||
| }: ChartPreviewPanelProps) { | ||
|
|
@@ -169,7 +173,11 @@ export function ChartPreviewPanel({ | |
| [queriedConfig], | ||
| ); | ||
|
|
||
| const queryReady = !!isQueryReady(queriedConfig); | ||
| const blockingFilterNames = missingRequiredFilterNames ?? []; | ||
| const isBlockedByRequiredFilters = | ||
| blockingFilterNames.length > 0 && tabQueriesData(activeTab); | ||
| const queryReady = | ||
| !isBlockedByRequiredFilters && !!isQueryReady(queriedConfig); | ||
|
|
||
| const onTableSortingChange = useCallback( | ||
| (sortState: SortingState | null) => { | ||
|
|
@@ -203,7 +211,16 @@ export function ChartPreviewPanel({ | |
|
|
||
| return ( | ||
| <> | ||
| {!queryReady && activeTab !== 'markdown' ? ( | ||
| {isBlockedByRequiredFilters ? ( | ||
|
pulpdrew marked this conversation as resolved.
Resolved
|
||
| <EmptyState | ||
| description={`Missing required filters: ${blockingFilterNames.join( | ||
|
pulpdrew marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this point at the switch? The message asks for a value, but the filter bar is behind the modal, so the user has to close the editor to give it one. Turning "Apply filters" off is the only thing available from here. It also moves the wording off the tile's copy of this string, which says "load this tile": description={`Missing required filters: ${blockingFilterNames.join(', ')}. Select a value for each on the dashboard, or turn off "Apply filters" to preview without them.`} |
||
| ', ', | ||
| )}. Select a value for each to preview this tile.`} | ||
| variant="card" | ||
| fullWidth | ||
| data-testid="preview-missing-required-filters" | ||
| /> | ||
| ) : !queryReady && tabQueriesData(activeTab) ? ( | ||
| <EmptyState | ||
| description="Please start by defining your chart above and then click the play button to query data." | ||
| variant="card" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — Tile and tile-editor now resolve "what the dashboard contributes to this tile" in two places
Tilestill computesconsumesBroadcastFilters+getBlockingRequiredFilters(...)+ the filter array inline (DBDashboardPage.tsx:602-634), while the editor routes the identical decision through the newresolveTilePreviewFilters(packages/app/src/components/DBEditTimeChartForm/utils.ts:203). The premise of this feature is that the preview queries what the tile does, so these must not drift; haveTilecallresolveTilePreviewFilters({ ..., applySelections: true })and derive its serialized memo inputs from the result instead of keeping a parallel copy.