diff --git a/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanel.test.tsx b/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanel.test.tsx
index eedc2fb101..95258f443e 100644
--- a/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanel.test.tsx
+++ b/superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanel.test.tsx
@@ -186,27 +186,6 @@ test('should render a create dataset infobox', async () => {
expect(infoboxText).toBeVisible();
});
-test('should render a save dataset modal when "Create a dataset" is clicked', async () => {
- const newProps = {
- ...props,
- datasource: {
- ...datasource,
- type: DatasourceType.Query,
- },
- };
- render(, { useRedux: true, useDnd: true });
-
- const createButton = await screen.findByRole('button', {
- name: /create a dataset/i,
- });
-
- userEvent.click(createButton);
-
- const saveDatasetModalTitle = screen.getByText(/save or overwrite dataset/i);
-
- expect(saveDatasetModalTitle).toBeVisible();
-});
-
test('should not render a save dataset modal when datasource is not query or dataset', async () => {
const newProps = {
...props,
diff --git a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
index fee2eb941f..dbbc8fe948 100644
--- a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
+++ b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.tsx
@@ -231,7 +231,9 @@ const ColumnSelectPopover = ({
}, []);
const setDatasetAndClose = () => {
- if (setDatasetModal) setDatasetModal(true);
+ if (setDatasetModal) {
+ setDatasetModal(true);
+ }
onClose();
};
diff --git a/superset-frontend/src/pages/ChartCreation/index.tsx b/superset-frontend/src/pages/ChartCreation/index.tsx
index 4aeb7aeed4..bea530fd3a 100644
--- a/superset-frontend/src/pages/ChartCreation/index.tsx
+++ b/superset-frontend/src/pages/ChartCreation/index.tsx
@@ -337,10 +337,7 @@ export class ChartCreation extends React.PureComponent<
const isButtonDisabled = this.isBtnDisabled();
const datasetHelpText = this.state.canCreateDataset ? (
-
+
{t('Add a dataset')}
{` ${t('or')} `}
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
index 744edb51b1..0e3642493a 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
@@ -21,6 +21,7 @@ import React, { useState, useMemo, useEffect } from 'react';
import rison from 'rison';
import { useSelector } from 'react-redux';
import { useQueryParams, BooleanParam } from 'use-query-params';
+import { LocalStorageKeys, setItem } from 'src/utils/localStorageHelpers';
import Loading from 'src/components/Loading';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
@@ -157,6 +158,9 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
refreshData();
addSuccessToast(t('Deleted: %s', dbName));
+ // Delete user-selected db from local storage
+ setItem(LocalStorageKeys.db, null);
+
// Close delete modal
setDatabaseCurrentlyDeleting(null);
},
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
index 5d58060155..8f2e4cda37 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx
@@ -62,6 +62,14 @@ jest.mock('src/components/Icons/Icon', () => ({
StyledIcon: () => ,
}));
+const mockHistoryPush = jest.fn();
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useHistory: () => ({
+ push: mockHistoryPush,
+ }),
+}));
+
const dbProps = {
show: true,
database_name: 'my database',
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index 6e374f85c8..72d3ddfd90 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -137,6 +137,7 @@ interface DatabaseModalProps {
show: boolean;
databaseId: number | undefined; // If included, will go into edit mode
dbEngine: string | undefined; // if included goto step 2 with engine already set
+ history?: any;
}
export enum ActionType {
@@ -521,6 +522,7 @@ const DatabaseModal: FunctionComponent = ({
show,
databaseId,
dbEngine,
+ history,
}) => {
const [db, setDB] = useReducer<
Reducer | null, DBReducerActionType>
@@ -653,6 +655,16 @@ const DatabaseModal: FunctionComponent = ({
onHide();
};
+ const redirectURL = (url: string) => {
+ /* TODO (lyndsiWilliams): This check and passing history
+ as a prop can be removed once SQL Lab is in the SPA */
+ if (!isEmpty(history)) {
+ history?.push(url);
+ } else {
+ window.location.href = url;
+ }
+ };
+
// Database import logic
const {
state: {
@@ -1345,23 +1357,21 @@ const DatabaseModal: FunctionComponent = ({
const renderCTABtns = () => (
{loadTables && !refresh && Loader(TABLE_LOADING_TEXT)}
- {schema && !loadTables && !tableOptions.length && !searchVal && (
+ {dataset?.schema && !loadTables && !tableOptions.length && !searchVal && (
)}
- {schema && (tableOptions.length > 0 || searchVal.length > 0) && (
+ {dataset?.schema && (tableOptions.length > 0 || searchVal.length > 0) && (
<>