-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
chore: Restructure explore redux state #20448
Conversation
CC @eric-briscoe since you were interested in this project 🙂 |
Codecov Report
@@ Coverage Diff @@
## master #20448 +/- ##
==========================================
+ Coverage 66.75% 66.76% +0.01%
==========================================
Files 1740 1744 +4
Lines 65172 65172
Branches 6900 6901 +1
==========================================
+ Hits 43505 43514 +9
+ Misses 19918 19908 -10
- Partials 1749 1750 +1
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.
Thanks for the PR @kgabryje! I left some first-pass comments.
superset-frontend/src/explore/actions/datasourcesActions.test.ts
Outdated
Show resolved
Hide resolved
superset-frontend/src/explore/actions/datasourcesActions.test.ts
Outdated
Show resolved
Hide resolved
superset-frontend/src/explore/actions/datasourcesActions.test.ts
Outdated
Show resolved
Hide resolved
Thanks for comments Michael, they all make sense to me. Will fix |
export function getChartKey(explore) { | ||
const { slice } = explore; | ||
return slice ? slice.slice_id : 0; | ||
const { slice, form_data } = explore; | ||
return slice?.slice_id ?? form_data?.slice_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.
no blocking suggestion, define a constant for the unsaved chart, default value is 0
, and this function might be splited into getChartKeyFromSlice
and getChartKeyFromFromData
.
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.
+1 for creating a constant for default slice id, but is there a use case for splitting this function in 2?
} from '../actions/datasourcesActions'; | ||
|
||
export default function datasourcesReducer( | ||
datasources: { [key: string]: Dataset }, |
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.
This type will probably change in the future to include other datasource types.
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.
Should I change it now? Or just add a todo when those new datasource types are introduced?
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.
Either way would work. Using the intersection type may cause some typescript errors because you'll need to resolve the difference in the schema of the datasources, which is something that we're working on now in a feature branch. It may be easiest to leave it as a todo, honestly.
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.
Added a todo
/testenv up |
@jinghua-qa Ephemeral environment spinning up at http://54.70.20.159:8080. Credentials are |
} | ||
|
||
export function changeDatasource(newDatasource: Dataset) { | ||
return function (dispatch: Dispatch, getState: () => any) { |
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.
Can we confirm the exact type of getState
return here?
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.
Good point... which resulted in finding a bug. I thought that getState
returns the state of reducer, but it actually returns global redux state.
Added a unit test for that
32a2b4b
to
e5a3228
Compare
Explore regression is tested in ephemeral env , did not find major issue related to this PR, LGTM |
b5c5591
to
eade95e
Compare
/testenv up |
@kgabryje Ephemeral environment spinning up at http://34.221.129.165:8080. Credentials are |
datasource_type: explore.datasource.type, | ||
datasourceId: explore.datasource_id, | ||
datasource, | ||
datasource_type: datasource.type, |
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 think this might be a good time to make also the property names consistent, some of them are camel case, some others use hyphens currently
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.
Good call. I'll fix it in a follow up PR
/testenv up |
@kgabryje Ephemeral environment spinning up at http://34.223.225.190: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
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.
Nice Work!
Ephemeral environment shutdown and build artifacts deleted. |
* chore: Restructure explore redux state * fixes * fix tests * add new tests * Fix type * Address comments * Fix bug * Fix import * Add new test * Move unsaved chart id to a constant * Add todo
SUMMARY
This PR restructures Explore redux state, so that it's more consistent with redux state of Dashboard view. This is a prerequisite for upcoming Explore SPA project - we need the redux states to be consistent so that we can smoothly navigate between dashboards and charts.
Now the following structure is used:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION