You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2025/10/31 15:18:15 UTC

(superset) 01/01: fix view in sql lab

This is an automated email from the ASF dual-hosted git repository.

enzomartellucci pushed a commit to branch enxdev/fix/view-in-sql-lab
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b59ac4d13ec1fbd81567a608cb316f7581b2fafd
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Fri Oct 31 16:17:47 2025 +0100

    fix view in sql lab
---
 .../explore/components/controls/DatasourceControl/index.jsx   |  5 ++---
 superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts  | 11 +++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
index 6731ade3b2..e2034718f7 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
@@ -68,7 +68,7 @@ const propTypes = {
 };
 
 const defaultProps = {
-  onChange: () => {},
+  onChange: () => { },
   onDatasourceSave: null,
   value: null,
   isEditable: true,
@@ -288,7 +288,7 @@ class DatasourceControl extends PureComponent {
       if (typeof datasource.extra === 'string') {
         try {
           extra = JSON.parse(datasource.extra);
-        } catch {} // eslint-disable-line no-empty
+        } catch { } // eslint-disable-line no-empty
       } else {
         extra = datasource.extra; // eslint-disable-line prefer-destructuring
       }
@@ -316,7 +316,6 @@ class DatasourceControl extends PureComponent {
       datasourceKey: `${datasource.id}__${datasource.type}`,
       sql: datasource.sql,
     };
-
     const defaultDatasourceMenuItems = [];
     if (this.props.isEditable && !isMissingDatasource) {
       defaultDatasourceMenuItems.push({
diff --git a/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts b/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
index b79523b72f..47baccd92b 100644
--- a/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
+++ b/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
@@ -20,6 +20,7 @@ import { getClientErrorObject, t } from '@superset-ui/core';
 import { useEffect, useRef, useCallback, useState } from 'react';
 import { useHistory } from 'react-router-dom';
 import { useBeforeUnload } from 'src/hooks/useBeforeUnload';
+import type { Location, Path } from 'history';
 
 type UseUnsavedChangesPromptProps = {
   hasUnsavedChanges: boolean;
@@ -69,7 +70,13 @@ export const useUnsavedChangesPrompt = ({
   }, [onSave]);
 
   const blockCallback = useCallback(
-    ({ pathname }: { pathname: string }) => {
+    ({
+      pathname,
+      state,
+    }: {
+      pathname: Location['state'];
+      state: Path['pathname'];
+    }) => {
       if (manualSaveRef.current) {
         manualSaveRef.current = false;
         return undefined;
@@ -77,7 +84,7 @@ export const useUnsavedChangesPrompt = ({
 
       confirmNavigationRef.current = () => {
         unblockRef.current?.();
-        history.push(pathname);
+        history.push(pathname, state);
       };
 
       setShowModal(true);