EnxDev commented on code in PR #42241:
URL: https://github.com/apache/superset/pull/42241#discussion_r3629588112


##########
superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx:
##########
@@ -84,26 +84,30 @@ const PopEditorTab: React.FC<{ children?: React.ReactNode 
}> = ({
       setIsLoading(true);
       const targetUrl = `${URI(SQL_LAB_URL).query(pick(requestedQuery, 
Object.keys(restUrlParams)))}`;
       setUpdatedUrl(targetUrl);
-      if (permalink) {
-        dispatch(popPermalink(permalink));
-      } else if (id) {
-        dispatch(popStoredQuery(id));
-      } else if (savedQueryId) {
-        dispatch(popSavedQuery(savedQueryId));
-      } else if (queryId) {
-        dispatch(popQuery(queryId));
-      } else if (datasourceKey) {
-        dispatch(popDatasourceQuery(datasourceKey, sql));
-      } else if (sql) {
-        const newQueryEditor = {
-          name,
-          dbId: Number(dbid),
-          catalog,
-          schema,
-          autorun,
-          sql,
-        };
-        dispatch(addQueryEditor(newQueryEditor));
+      try {
+        if (permalink) {
+          await dispatch(popPermalink(permalink));
+        } else if (id) {
+          await dispatch(popStoredQuery(id));
+        } else if (savedQueryId) {
+          await dispatch(popSavedQuery(savedQueryId));
+        } else if (queryId) {
+          await dispatch(popQuery(queryId));
+        } else if (datasourceKey) {
+          await dispatch(popDatasourceQuery(datasourceKey, sql));
+        } else if (sql) {
+          const newQueryEditor = {
+            name,
+            dbId: Number(dbid),
+            catalog,
+            schema,
+            autorun,
+            sql,
+          };
+          dispatch(addQueryEditor(newQueryEditor));
+        }
+      } finally {
+        setIsLoading(false);

Review Comment:
   Would make it sense to add a regression tests for this? 



##########
superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx:
##########
@@ -84,26 +84,30 @@ const PopEditorTab: React.FC<{ children?: React.ReactNode 
}> = ({
       setIsLoading(true);
       const targetUrl = `${URI(SQL_LAB_URL).query(pick(requestedQuery, 
Object.keys(restUrlParams)))}`;
       setUpdatedUrl(targetUrl);
-      if (permalink) {
-        dispatch(popPermalink(permalink));
-      } else if (id) {
-        dispatch(popStoredQuery(id));
-      } else if (savedQueryId) {
-        dispatch(popSavedQuery(savedQueryId));
-      } else if (queryId) {
-        dispatch(popQuery(queryId));
-      } else if (datasourceKey) {
-        dispatch(popDatasourceQuery(datasourceKey, sql));
-      } else if (sql) {
-        const newQueryEditor = {
-          name,
-          dbId: Number(dbid),
-          catalog,
-          schema,
-          autorun,
-          sql,
-        };
-        dispatch(addQueryEditor(newQueryEditor));
+      try {
+        if (permalink) {
+          await dispatch(popPermalink(permalink));
+        } else if (id) {
+          await dispatch(popStoredQuery(id));
+        } else if (savedQueryId) {
+          await dispatch(popSavedQuery(savedQueryId));
+        } else if (queryId) {
+          await dispatch(popQuery(queryId));
+        } else if (datasourceKey) {
+          await dispatch(popDatasourceQuery(datasourceKey, sql));
+        } else if (sql) {
+          const newQueryEditor = {
+            name,
+            dbId: Number(dbid),
+            catalog,
+            schema,
+            autorun,
+            sql,
+          };
+          dispatch(addQueryEditor(newQueryEditor));
+        }
+      } finally {
+        setIsLoading(false);

Review Comment:
   Also what do you think to add  `.catch(() => {})` ? 



-- 
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]

Reply via email to