Skip to content

chore: Restructure explore redux state - #20448

Merged
kgabryje merged 11 commits into
apache:masterfrom
kgabryje:chore/explore-redux
Jun 24, 2022
Merged

chore: Restructure explore redux state#20448
kgabryje merged 11 commits into
apache:masterfrom
kgabryje:chore/explore-redux

Conversation

@kgabryje

@kgabryje kgabryje commented Jun 21, 2022

Copy link
Copy Markdown
Member

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:

{
  user: User;
  common: {
    flash_messages: string[];
    conf: JsonObject;
  };
  charts: { [key: number]: ChartState };
  datasources: { [key: string]: Dataset };
  explore: {
    can_add: boolean;
    can_download: boolean;
    can_overwrite: boolean;
    isDatasourceMetaLoading: boolean;
    isStarred: boolean;
    triggerRender: boolean;
    // duplicate datasource in exploreState - it's needed by getControlsState
    datasource: Dataset,
    controls: ControlStateMapping;
    form_data: JsonObject;
    slice: Slice;
    controlsTransferred: string[],
    standalone: boolean;
    force: boolean;
  }
}

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@kgabryje

Copy link
Copy Markdown
Member Author

CC @eric-briscoe since you were interested in this project 🙂

@codecov

codecov Bot commented Jun 21, 2022

Copy link
Copy Markdown

Codecov Report

Merging #20448 (76e0b46) into master (44f0b51) will increase coverage by 0.01%.
The diff coverage is 64.44%.

@@            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     
Flag Coverage Δ
javascript 51.83% <64.44%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
...perset-frontend/src/addSlice/AddSliceContainer.tsx 65.85% <ø> (ø)
superset-frontend/src/dashboard/actions/hydrate.js 2.04% <ø> (ø)
...frontend/src/dashboard/components/Header/index.jsx 59.39% <ø> (ø)
...rontend/src/dashboard/containers/DashboardPage.tsx 5.31% <ø> (ø)
...set-frontend/src/dashboard/util/permissionUtils.ts 90.00% <ø> (ø)
...rset-frontend/src/explore/components/SaveModal.tsx 66.19% <ø> (ø)
...re/components/controls/DatasourceControl/index.jsx 74.73% <0.00%> (ø)
...et-frontend/src/explore/reducers/exploreReducer.js 40.67% <0.00%> (+5.89%) ⬆️
...t-frontend/src/explore/reducers/getInitialState.ts 0.00% <0.00%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44f0b51...76e0b46. Read the comment docs.

@michael-s-molina michael-s-molina left a comment

Copy link
Copy Markdown
Member

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.

Comment thread superset-frontend/src/dashboard/components/Header/index.jsx Outdated
Comment thread superset-frontend/src/dashboard/util/getDashboardPermission.ts Outdated
Comment thread superset-frontend/src/explore/actions/datasourcesActions.test.ts Outdated
Comment thread superset-frontend/src/explore/actions/datasourcesActions.test.ts Outdated
Comment thread superset-frontend/src/explore/actions/datasourcesActions.test.ts Outdated
Comment thread superset-frontend/src/explore/reducers/getInitialState.ts Outdated
Comment thread superset-frontend/src/explore/reducers/index.js Outdated
Comment thread superset-frontend/src/utils/findPermission.test.ts Outdated
Comment thread superset-frontend/src/utils/getDatasourceUid.test.ts Outdated
Comment thread superset-frontend/src/utils/getDatasourceUid.test.ts Outdated
@kgabryje

Copy link
Copy Markdown
Member Author

Thanks for comments Michael, they all make sense to me. Will fix

Comment on lines 40 to 44

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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?

Comment thread superset-frontend/src/explore/reducers/getInitialState.ts Outdated
Comment thread superset-frontend/src/utils/getDatasourceUid.ts Outdated
Comment thread superset-frontend/src/explore/reducers/datasourcesReducer.ts Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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?

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a todo

@jinghua-qa

Copy link
Copy Markdown
Member

/testenv up

@github-actions

Copy link
Copy Markdown
Contributor

@jinghua-qa Ephemeral environment spinning up at http://54.70.20.159:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Copy Markdown
Member

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?

@kgabryje kgabryje Jun 23, 2022

Copy link
Copy Markdown
Member Author

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

@kgabryje
kgabryje force-pushed the chore/explore-redux branch from 32a2b4b to e5a3228 Compare June 23, 2022 12:10
@jinghua-qa

Copy link
Copy Markdown
Member

Explore regression is tested in ephemeral env , did not find major issue related to this PR, LGTM

@kgabryje
kgabryje force-pushed the chore/explore-redux branch from b5c5591 to eade95e Compare June 24, 2022 10:34
@kgabryje

Copy link
Copy Markdown
Member Author

/testenv up

@github-actions

Copy link
Copy Markdown
Contributor

@kgabryje Ephemeral environment spinning up at http://34.221.129.165:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

datasource_type: explore.datasource.type,
datasourceId: explore.datasource_id,
datasource,
datasource_type: datasource.type,

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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

@kgabryje

Copy link
Copy Markdown
Member Author

/testenv up

@github-actions

Copy link
Copy Markdown
Contributor

@kgabryje Ephemeral environment spinning up at http://34.223.225.190:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@michael-s-molina michael-s-molina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stephenLYZ stephenLYZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Work!

@kgabryje
kgabryje merged commit c7f1c7d into apache:master Jun 24, 2022
@github-actions

Copy link
Copy Markdown
Contributor

Ephemeral environment shutdown and build artifacts deleted.

akshatsri pushed a commit to charan1314/superset that referenced this pull request Jul 19, 2022
* 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
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 First shipped in 2.1.0 labels Mar 13, 2024
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io size/XL 🚢 2.1.0 First shipped in 2.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants