-
Notifications
You must be signed in to change notification settings - Fork 14k
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
feat(explore): Keep or reset chart config after datasource change #18215
Conversation
Would this logic also work case-insensitive? We have use cases where we migrate tables from Postgres to Snowflake, which potentially results in a change in case from lowercase to UPPERCASE. However, the model's general schema is still the same. |
Hey @rumbin, I discussed your suggestion with @villebro and we agree that it makes sense to have that logic case insensitive. However, that change should be made on a higher level, in the whole Superset. I'd suggest that we merge this PR as-is and work on case insensitivity as a separate project. |
f665a24
to
639cbb6
Compare
Codecov Report
@@ Coverage Diff @@
## master #18215 +/- ##
==========================================
- Coverage 66.30% 66.28% -0.03%
==========================================
Files 1592 1594 +2
Lines 62437 62491 +54
Branches 6292 6311 +19
==========================================
+ Hits 41401 41420 +19
- Misses 19383 19421 +38
+ Partials 1653 1650 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
I love this, best of both worlds! One minor bug that causes Explore not to load when entering via the dataset list.
import { styled } from '@superset-ui/core'; | ||
import Button from 'src/components/Button'; | ||
|
||
interface ControlPanelAlertI { |
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.
The I
here gave me a horrible C# flashback 👻 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface (granted, it's trailing, not leading). I did a quick search of the codebase, and it seems like we usually suffix these with Interface
when there would otherwise be overlap with a component name. At the risk of being awarded the nitpicker of the year award, maybe we could change this to ControlPanelAlertInterface
to keep with conventions..? 😄
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.
You're right! And I think that we use a Props
suffix more often, so I'm going to change the name to ControlPanelAlertProps
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.
Sounds good!
renderControl({ name, config }: CustomControlItem) { | ||
const { actions, controls, chart, exploreState } = this.props; | ||
const renderControl = ({ name, config }: CustomControlItem) => { | ||
const { controls, chart } = props; |
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.
It seems we're missing exploreState
here (needed down on line 257):
const { controls, chart } = props; | |
const { controls, chart, exploreState } = props; |
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.
🤦 I moved exploreState
into ControlPanelsContainer
, but then I changed my mind and moved it back to props. For some reason, linter didn't mark this line with "variable not found" error. Thanks for finding that!
@@ -260,7 +260,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => { | |||
// re-render, we only run this when the chart plugin explicitly ask for this. | |||
...(config.mapStateToProps?.length === 3 | |||
? // @ts-ignore /* The typing accuses of having an extra parameter. I didn't remove it because I believe it could be an error in the types and not in the code */ | |||
config.mapStateToProps(exploreState, controls[name], chart) | |||
config.mapStateToProps(props.exploreState, controls[name], chart) |
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.
nit: could we move this to line 249?
b3f78af
to
197ed52
Compare
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.
LGTM!
/testenv up FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true |
@kgabryje Ephemeral environment spinning up at http://54.201.119.118:8080. Credentials are |
Thanks so much for spotting those @jinghua-qa!
|
@jinghua-qa Both issues should be fixed now! Can you retest please? |
/testenv up FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true |
@jinghua-qa Ephemeral environment spinning up at http://34.212.59.37:8080. Credentials are |
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.
LGTM
Ephemeral environment shutdown and build artifacts deleted. |
…ache#18215) * feat(explore): Keep or reset chart config after datasource change * Update copy * Remove useDispatch * fix test * Fix bugs * Remove ts ignore * Scroll top when datasource changes * Fix crashing when switching viz type
…ache#18215) * feat(explore): Keep or reset chart config after datasource change * Update copy * Remove useDispatch * fix test * Fix bugs * Remove ts ignore * Scroll top when datasource changes * Fix crashing when switching viz type
…ache#18215) * feat(explore): Keep or reset chart config after datasource change * Update copy * Remove useDispatch * fix test * Fix bugs * Remove ts ignore * Scroll top when datasource changes * Fix crashing when switching viz type
SUMMARY
Currently, when user switches datasource, controls such as metrics, group by, filters etc. are being reset. This PR changes that behaviour - after switching datasource, controls that use columns or saved metrics that are present in both previous and current datasource are preserved. After that, we display an alert that let's user decide if they want to reset the chart config or keep the changes. If there were no controls using columns nor metrics that matched the new dataset, we display a "warning" alert that informs user that chart config was reset.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2022-01-28.at.13.45.07.mov
Screen.Recording.2022-01-28.at.13.46.17.mov
EDIT: new copy
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CC @kasiazjc
https://app.shortcut.com/preset/story/34087/gh-17010-prod-95-keep-chart-config-when-changing-data-source