Skip to content
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): each control can define its own canDrop for dnd #16090

Merged
merged 3 commits into from
Aug 10, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Aug 5, 2021

SUMMARY

Allows defining canDropValue function in mapStateToProps of controls in control panel (in superset-ui).
That will allow us not only to use generic canDrop functions for columns or adhoc metrics, but also more advanced ones - like can drop column "gender" in "Series" control only if "Breakdown" control doesn't already have this column added.

It's a prerequisite for fixing issue #16071

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No changes

TESTING INSTRUCTIONS

  1. Enable dnd
  2. Verify that everything works as before

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

CC: @junlincc

@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #16090 (d994940) into master (a59d458) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16090      +/-   ##
==========================================
- Coverage   76.86%   76.83%   -0.04%     
==========================================
  Files         995      995              
  Lines       52876    52922      +46     
  Branches     6720     6738      +18     
==========================================
+ Hits        40645    40660      +15     
- Misses      12005    12037      +32     
+ Partials      226      225       -1     
Flag Coverage Δ
javascript 71.20% <0.00%> (-0.07%) ⬇️

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

Impacted Files Coverage Δ
...controls/DndColumnSelectControl/DndSelectLabel.tsx 77.27% <0.00%> (-7.73%) ⬇️
...ontrols/DndColumnSelectControl/DndColumnSelect.tsx 47.36% <0.00%> (-13.75%) ⬇️
...src/dashboard/components/PropertiesModal/index.jsx 83.09% <0.00%> (-2.52%) ⬇️
...plore/components/controls/OptionControls/index.tsx 88.88% <0.00%> (-1.54%) ⬇️
superset-frontend/src/reports/actions/reports.js 9.80% <0.00%> (-1.07%) ⬇️
...rontend/src/components/Select/DeprecatedSelect.tsx 85.71% <0.00%> (-1.03%) ⬇️
...tend/src/explore/components/ExploreChartHeader.jsx 55.55% <0.00%> (-0.79%) ⬇️
...c/views/CRUD/data/database/DatabaseModal/index.tsx 44.15% <0.00%> (-0.38%) ⬇️
...ontrols/DndColumnSelectControl/DndMetricSelect.tsx 41.78% <0.00%> (-0.29%) ⬇️
superset-frontend/src/dashboard/actions/hydrate.js 1.69% <0.00%> (-0.02%) ⬇️
... and 15 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 a59d458...d994940. Read the comment docs.

@junlincc junlincc requested a review from zhaoyongjie August 5, 2021 20:54
@junlincc junlincc added the explore:drag&drop Related to drag&drop in Explore label Aug 5, 2021
@kgabryje
Copy link
Member Author

kgabryje commented Aug 6, 2021

/testenv up FEATURE_ENABLE_DRAG_AND_DROP=true

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2021

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

@michael-s-molina
Copy link
Member

@kgabryje I didn't understand why we need to create an additional function for this. canDrop receives a DatasourcePanelDndItem and this object contains a value prop of type DndItemValue. Can't we just check the value inside canDrop?

@kgabryje
Copy link
Member Author

kgabryje commented Aug 9, 2021

@michael-s-molina We can only check control's own value in canDrop. The point was to 1) allow checking values of other controls, so that for example user can add a value to control1 only if that value hasn't been added to control2. That can be done in mapStateToProps function in chart's control panel in superset-ui, and that's were canDropValue is supposed to be defined if needed. And 2) this allows us to define canDrop rules specific to a given control, which doesn't apply to all DndColumnControl type controls

@michael-s-molina
Copy link
Member

@villebro What do you think? I'm still not sure if we need this extra prop.

@villebro
Copy link
Member

I agree with Kamil's assessment and see this as improving decoupling. By adding this we can let both components decide about the things they have the best context on. Without it we face a situation where we would need to make control1 aware of logic that should be inside control2 and vice versa.

@michael-s-molina
Copy link
Member

@villebro @kgabryje Understood. Can we add an onDropValue for consistency?

Copy link
Member

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

Choose a reason for hiding this comment

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

Thanks for the clarifications!

@kgabryje kgabryje merged commit 6e1d16d into apache:master Aug 10, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
…e#16090)

* feat(explore): each control can define its own canDrop for dnd

* Make canDropValue optional

* Add onDropValue
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
…e#16090)

* feat(explore): each control can define its own canDrop for dnd

* Make canDropValue optional

* Add onDropValue
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
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 explore:drag&drop Related to drag&drop in Explore size/S 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants