You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/11 13:52:36 UTC

[GitHub] [superset] geido commented on a diff in pull request #20934: feat(explore): Don't discard controls with custom sql when changing datasource

geido commented on code in PR #20934:
URL: https://github.com/apache/superset/pull/20934#discussion_r943509078


##########
superset-frontend/src/explore/components/ControlPanelsContainer.tsx:
##########
@@ -269,6 +270,29 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
 
   const containerRef = useRef<HTMLDivElement>(null);
 
+  const controlsTransferred = useSelector<ExplorePageState, string[]>(
+    state => state.explore.controlsTransferred,
+  );
+
+  useEffect(() => {
+    if (props.chart.chartStatus === 'success') {
+      controlsTransferred.forEach(controlName => {
+        const alteredControls = ensureIsArray(
+          props.controls[controlName].value,
+        ).map(value => {
+          if (
+            typeof value === 'object' &&
+            isDefined(value) &&
+            'datasourceWarning' in value

Review Comment:
   Minor. Do you think we can have Typescript helping here or maybe setting it in a constant? I am not very fond of using a plain string for `datasourceWarning`



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org