villebro opened a new pull request, #22565: URL: https://github.com/apache/superset/pull/22565
### SUMMARY When saving a chart without a time grain, the chart reverts to the default time grain after the chart reloads in Explore view. To get around this, the user must choose the "Original value" option from the time grain dropdown. While this works, there should only be one way of clearing the time grain. A summary of changes introduced by this PR: - When saving the chart with the time grain control in cleared state, the `time_grain_sqla` entry is removed from the form data. To get around this, we check if the chart has been saved by looking at the `metadata` property of the chart state - if it's defined, we know the chart has been saved, in which case we know that the time grain has been explicitly set to `undefined`. - Remove the "Original value" option from the time grain dropdown. After this the time grain should be cleared to be removed. - Add a "None" placeholder when the time grain is cleared. Use the same placeholder for "Series limit", as that seems more appropriate for that one, too (currently it shows ") The change has been tested to work in the following scenarios: - Chart saved with "Original value" prior to the change - it renders the chart without the time grain as expected, but with the time grain control in cleared state (as opposed to with "Original value") - Chart saved with time grain - Chart saved without time grain - All of the above on a dashboard (verified by looking at the rendered query to confirm that the time grain was applied correctly) ### AFTER With these changes, the time grain remains cleared even after saving: https://user-images.githubusercontent.com/33317356/210207589-6d6a3fb2-2b3a-4443-aa61-b5e3d99db666.mp4 ### BEFORE Previously, the chart would revert back to the default time grain `P1D` when the chart reloaded in Explore view: https://user-images.githubusercontent.com/33317356/210207787-51cd2089-213d-4762-baf8-213a3ec425bc.mp4 ### TESTING INSTRUCTIONS 1. Create a line chart and remove the time grain 2. Save the chart and notice that the default time grain is reapplied. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
