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

Translate string to array for multi fields in getControlsState #5057

Merged
merged 2 commits into from
May 24, 2018

Conversation

michellethomas
Copy link
Contributor

In the explore store.js, I'm adding logic that will handle a string value being passed to a multi control by making it an array. This would handle errors with existing slices when making a SelectControl multi.

Fixes #5011
@mistercrunch @graceguo-supercat

@codecov-io
Copy link

codecov-io commented May 22, 2018

Codecov Report

Merging #5057 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5057   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files          44       44           
  Lines        8712     8712           
=======================================
  Hits         6755     6755           
  Misses       1957     1957

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 d322e48...d955c13. Read the comment docs.

@@ -56,6 +56,10 @@ export function getControlsState(state, form_data) {
delete control.mapStateToProps;
}

if (control.multi && typeof formData[k] === 'string') {
Copy link
Member

Choose a reason for hiding this comment

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

nit: formData[k] = (control.multi && typeof formData[k] === 'string') ? [formData[k]] : formData[k]

Copy link
Member

Choose a reason for hiding this comment

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

Would !Array.isArray(formData[k]) be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we'd want to stick with typeof formData[k] === 'string' because formData[k] might be undefined or null and we would want to leave it as null.

Copy link
Member

Choose a reason for hiding this comment

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

Though I think it can be a int / float too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, updated it to formData[k] && !Array.isArray(formData[k]).

@hughhhh
Copy link
Member

hughhhh commented May 23, 2018

🚢

@michellethomas
Copy link
Contributor Author

@mistercrunch @graceguo-supercat can one of you merge if formData[k] && !Array.isArray(formData[k]) looks ok to you?

@mistercrunch mistercrunch merged commit 1aaa73b into apache:master May 24, 2018
@mistercrunch
Copy link
Member

Actually after thinking a bit more I'm thinking while this fixes the problem in the explore view, I don't think it fixes the issue in the dashboard view.

@mistercrunch
Copy link
Member

mistercrunch commented May 24, 2018

@michellethomas maybe we need to refactor some sort of formDataInterceptor method that intercepts and modifies formData on the way in and executes for both Explore and Dashboard.

michellethomas added a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
…e#5057)

* Translate string to array for multi fields in getControlsState

* Updating format to fit on one line

(cherry picked from commit 1aaa73b)
john-bodley added a commit that referenced this pull request May 24, 2018
timifasubaa pushed a commit to timifasubaa/incubator-superset that referenced this pull request May 31, 2018
…e#5057)

* Translate string to array for multi fields in getControlsState

* Updating format to fit on one line
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
…e#5057)

* Translate string to array for multi fields in getControlsState

* Updating format to fit on one line
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.26.0 labels Feb 27, 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 🚢 0.26.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Existing histogram slices are broken
4 participants