zhaoyongjie commented on PR #20010: URL: https://github.com/apache/superset/pull/20010#issuecomment-1129522205
> @zhaoyongjie Is 2 about allowing users to restore field values when they switch between chart types? Yes. The `memorizedFormData`(field in StandardizeFormData) saved the previous chart type as a key, and form_data as a value. In order to find the latest chart, the array was used to store it. > Would it suffice if we just keep the history in a reducer state as well? It could be a simple vizType to formData dict. A plugin's fromStandardizedState function will accept both the standardized state from current formData and the previous formData stored and decide how to merge them. I've tried this, and as you can see, it's hard to read the logic of the current [reducer](https://github.com/apache/superset/blob/63702c48ab77ee73b7e304c92fc74ce02748107e/superset-frontend/src/explore/reducers/exploreReducer.js#L132). In abstract terms. We just need to collect/calculate the current `form_data` and `controlsState` for "arrived viz", and I've written the steps on how to do that in the [comments](https://github.com/apache/superset/pull/20010/files#diff-22f8206e02d866fc191fba5d77a5578c8a1008926e949a983745795e614aa7d4R142-R150). IMO, we should "encapsulate" the transformation logic rather than “leak” information. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
