Repository navigation
Commit 2e30c0e
authored
feat: Improve chart editor validations (#1905)
## Summary
This PR improves chart validation. Previously, when the chart configuration was incorrect, the save and run buttons would do nothing, or would run an invalid chart config. Now, we surface some known errors to the user via a notification with helpful messages.
Additionally, this PR
1. Removes the last remaining `any` and `as` casts from the `DBEditTimeChartForm` component and its utils
2. Adds error and loading states to the SQL Preview component
### Validations
The following validations are performed:
1. A metric name is selected when a metric source is selected (pre-existing)
3. A source is selected when using the chart builder format (except for markdown charts)
4. A connection is selected when using the raw sql format
5. Each series with a non-`count` aggregation has a non-empty valueExpression
6. Number and Pie charts have only a single series
7. Raw SQL charts have a non-empty sqlTemplate
When errors are found
1. The run and save button do not run or save
2. A notification is shown with user-friendly error messages
<img width="472" height="89" alt="Screenshot 2026-03-13 at 9 04 43 AM" src="https://github.com/user-attachments/assets/18e57a4f-5f95-4984-b2cb-39fe9d441136" />
### SQL Preview Error and Loading States
<img width="1216" height="115" alt="Screenshot 2026-03-13 at 9 06 03 AM" src="https://github.com/user-attachments/assets/8394bea4-c1b6-4661-bb4e-1ef0e3078815" />
<img width="1203" height="123" alt="Screenshot 2026-03-13 at 9 05 53 AM" src="https://github.com/user-attachments/assets/3e0e103b-36a4-488a-bdf8-00e91353c50a" />
## How to test locally or on Vercel
This can be tested in the preview environment.
## References
- Linear Issue: Closes HDX-3598
- Related PRs:1 parent 60d1bba commit 2e30c0e
8 files changed
Lines changed: 616 additions & 145 deletions
File tree
- .changeset
- packages/app/src
- components
- ChartEditor
- __tests__
- __tests__
- hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments