-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
fix(explore): Restore missing dataset states #22693
Conversation
Codecov Report
@@ Coverage Diff @@
## master #22693 +/- ##
==========================================
- Coverage 67.10% 67.08% -0.02%
==========================================
Files 1869 1869
Lines 71580 71551 -29
Branches 7806 7822 +16
==========================================
- Hits 48031 48001 -30
- Misses 21521 21523 +2
+ Partials 2028 2027 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -267,11 +267,12 @@ class DatasourceControl extends React.PureComponent { | |||
showSaveDatasetModal, | |||
} = this.state; | |||
const { datasource, onChange, theme } = this.props; | |||
const isMissingDatasource = datasource?.id == null; | |||
const isMissingDatasource = !datasource || datasource.id === 0; |
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.
Would this also work?
const isMissingDatasource = !datasource || datasource.id === 0; | |
const isMissingDatasource = !!datasource?.id |
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.
That's cleaner, thanks! This now also covers the original null
case in case it's still used somewhere I couldn't find, which is probably good.
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.
Actually sorry, !!datasource?.id
doesn't work but !datasource?.id
works. Is that what you meant?
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.
yeah, that's it. 👍
@eschutho thanks, feel free to merge! |
SUMMARY
This PR fixes Explore's dataset control so it correctly displays the intended UI when the chart's dataset doesn't exist or Explore has been opened without a specified chart or dataset.
Prior to moving Explore into the SPA,
DatasourceControl
(the dataset picker in the upper left) would check for a dataset ID ofnull
to determine if the current chart's dataset existed. As part of moving Explore into the SPA, the initial Explore state in Redux was set to this object, which has the dataset ID set to0
. When a user opens Explore for a chart whose dataset does not exist, or when Explore is opened without a specified chart (this happens for new charts) and also without a dataset specified (this should only happen by accident), the initial Explore state's dataset object is not overwritten. BecauseDatasourceControl
is checking for an ID ofnull
, it doesn't correctly identify these cases as empty dataset situations, and shows options that should only be present in situations when there is a dataset and don't work correctly when no dataset is present.This PR:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Chart with missing dataset, before:
Chart with missing dataset, after:
No chart with no dataset specified (e.g. from visiting
/explore
with no query string), before:No chart with no dataset specified, after:
TESTING INSTRUCTIONS
DatasourceControl
and that the only menu option in theDatasourceControl
three-dots menu is "Swap dataset"./explore
and confirm that the correct message (missing URL params) appears underDatasourceControl
and that the only menu option in theDatasourceControl
three-dots menu is "Swap dataset".ADDITIONAL INFORMATION