+
{this.props.visualize &&
this.props.database &&
@@ -184,6 +432,7 @@ export default class ResultSet extends React.PureComponent<
query={this.props.query}
database={this.props.database}
actions={this.props.actions}
+ onClick={this.handleExploreBtnClick}
/>
)}
{this.props.csv && (
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
index 01906b70fb..7e3cd87059 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
@@ -17,11 +17,12 @@
* under the License.
*/
-import React, { useState, FunctionComponent } from 'react';
+import React, { FunctionComponent } from 'react';
+import { AutoCompleteProps } from 'antd/lib/auto-complete';
import { Radio, AutoComplete, Input } from 'src/common/components';
import StyledModal from 'src/common/components/Modal';
import Button from 'src/components/Button';
-import { styled } from '@superset-ui/core';
+import { styled, t } from '@superset-ui/core';
import { RadioChangeEvent } from 'antd/lib/radio';
interface SaveDatasetModalProps {
@@ -29,27 +30,37 @@ interface SaveDatasetModalProps {
onOk: () => void;
onHide: () => void;
handleDatasetNameChange: (e: React.FormEvent
) => void;
- userDatasetsOwned: Array>;
+ handleSaveDatasetModalSearch: (searchText: string) => void;
+ filterAutocompleteOption: (
+ inputValue: string,
+ option: { value: string; datasetId: number },
+ ) => boolean;
handleSaveDatasetRadioBtnState: (e: RadioChangeEvent) => void;
- saveDatasetRadioBtnState: number;
- shouldOverwriteDataset: boolean;
handleOverwriteCancel: () => void;
handleOverwriteDataset: () => void;
handleOverwriteDatasetOption: (
data: string,
option: Record,
) => void;
+ onChangeAutoComplete: () => void;
defaultCreateDatasetValue: string;
+ disableSaveAndExploreBtn: boolean;
+ saveDatasetRadioBtnState: number;
+ shouldOverwriteDataset: boolean;
+ userDatasetOptions: AutoCompleteProps['options'];
}
const Styles = styled.div`
+ .smd-body {
+ margin: 0 8px;
+ }
.smd-input {
margin-left: 45px;
- width: 290px;
+ width: 401px;
}
.smd-autocomplete {
margin-left: 8px;
- width: 290px;
+ width: 401px;
}
.smd-radio {
display: block;
@@ -57,6 +68,9 @@ const Styles = styled.div`
margin: 10px 0px;
line-height: 30px;
}
+ .smd-overwrite-msg {
+ margin: 7px;
+ }
`;
// eslint-disable-next-line no-empty-pattern
@@ -65,7 +79,6 @@ export const SaveDatasetModal: FunctionComponent = ({
onOk,
onHide,
handleDatasetNameChange,
- userDatasetsOwned,
handleSaveDatasetRadioBtnState,
saveDatasetRadioBtnState,
shouldOverwriteDataset,
@@ -73,32 +86,12 @@ export const SaveDatasetModal: FunctionComponent = ({
handleOverwriteDataset,
handleOverwriteDatasetOption,
defaultCreateDatasetValue,
+ disableSaveAndExploreBtn,
+ handleSaveDatasetModalSearch,
+ filterAutocompleteOption,
+ userDatasetOptions,
+ onChangeAutoComplete,
}) => {
- const [options, setOptions] = useState<
- {
- value: string;
- datasetId: number;
- }[]
- >([]);
-
- const onSearch = (searchText: string) => {
- setOptions(
- !searchText
- ? []
- : userDatasetsOwned.map(d => ({
- value: d.datasetName,
- datasetId: d.datasetId,
- })),
- );
- };
-
- const filterAutocompleteOption = (
- inputValue: string,
- option: { value: string; datasetId: number },
- ) => {
- return option.value.includes(inputValue);
- };
-
return (
= ({
<>
{!shouldOverwriteDataset && (
)}
{shouldOverwriteDataset && (
<>
-
)}
{shouldOverwriteDataset && (
-
Are you sure you want to overwrite this dataset?
+
+ Are you sure you want to overwrite this dataset?
+
)}
diff --git a/superset-frontend/src/api/dataset.ts b/superset-frontend/src/api/dataset.ts
index 048487c50e..d426daffdd 100644
--- a/superset-frontend/src/api/dataset.ts
+++ b/superset-frontend/src/api/dataset.ts
@@ -41,6 +41,7 @@ export const getByUser = async (userId: number) => {
export const put = async (
datasetId: number,
+ dbId: number,
sql: string,
columns: Array
>,
overrideColumns: boolean,
@@ -50,6 +51,7 @@ export const put = async (
const body = JSON.stringify({
sql,
columns,
+ database_id: dbId,
});
const data: JsonResponse = await SupersetClient.put({
diff --git a/superset/datasets/schemas.py b/superset/datasets/schemas.py
index b8406eb2cf..2703228739 100644
--- a/superset/datasets/schemas.py
+++ b/superset/datasets/schemas.py
@@ -75,6 +75,7 @@ class DatasetPostSchema(Schema):
class DatasetPutSchema(Schema):
table_name = fields.String(allow_none=True, validate=Length(1, 250))
+ database_id = fields.Integer()
sql = fields.String(allow_none=True)
filter_select_enabled = fields.Boolean(allow_none=True)
fetch_values_predicate = fields.String(allow_none=True, validate=Length(0, 1000))