You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2020/11/16 23:11:08 UTC
[incubator-superset] branch hugh/SO-1117-modal updated: get data
for owners dropdown
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch hugh/SO-1117-modal
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/hugh/SO-1117-modal by this push:
new 0c7810a get data for owners dropdown
0c7810a is described below
commit 0c7810a24af1a2536cae99a729e86c754dcbec0e
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Nov 16 15:09:53 2020 -0800
get data for owners dropdown
---
superset-frontend/src/SqlLab/components/ResultSet.tsx | 15 ++++++++++++++-
.../src/SqlLab/components/SaveDatasetModal.tsx | 9 +++------
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/ResultSet.tsx b/superset-frontend/src/SqlLab/components/ResultSet.tsx
index 1b8355c..e8d7fac 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet.tsx
@@ -20,7 +20,7 @@ import React, { CSSProperties } from 'react';
import { Alert, ButtonGroup, ProgressBar } from 'react-bootstrap';
import Button from 'src/components/Button';
import shortid from 'shortid';
-import { styled, t } from '@superset-ui/core';
+import { styled, t, SupersetClient} from '@superset-ui/core';
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import Loading from '../../components/Loading';
@@ -91,6 +91,7 @@ export default class ResultSet extends React.PureComponent<
data: [],
showSaveDatasetModal: false,
newSaveDatasetName: '',
+ userDatasetsOwned: []
};
this.changeSearch = this.changeSearch.bind(this);
@@ -108,6 +109,17 @@ export default class ResultSet extends React.PureComponent<
componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
+
+ SupersetClient.get({
+ endpoint:
+ 'api/v1/dataset/?q=(filters:!((col:table_name,opr:ct,value:%27%27)),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:25)',
+ }).then(data => {
+ const userDatasetsOwned = data.json.result.map(r => {
+ return { dataSetName: r.table_name, dataSetId: r.id }
+ })
+ this.setState({userDatasetsOwned})
+ });
+
}
UNSAFE_componentWillReceiveProps(nextProps: ResultSetProps) {
@@ -241,6 +253,7 @@ export default class ResultSet extends React.PureComponent<
onOk={this.handleSaveInDataset}
onCancel={this.handleHideSaveModal}
handleDatasetNameChange={this.handleDatasetNameChange}
+ userDatasetsOwned={this.state.userDatasetsOwned}
/>
<div className="ResultSetButtons">
{this.props.visualize &&
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
index c0dccc6..a74258f 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx
@@ -21,6 +21,7 @@ import React, { useState, FunctionComponent} from 'react';
import { Radio, AutoComplete, Input } from 'src/common/components';
import Modal from 'src/common/components/Modal';
import Button from 'src/components/Button';
+import { SupersetClient } from '@superset-ui/core';
const mockVal = (str, repeat = 1) => {
return {
@@ -32,14 +33,14 @@ interface SaveDatasetModalProps = {
}
// eslint-disable-next-line no-empty-pattern
-export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel, handleDatasetNameChange}) => {
+export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel, handleDatasetNameChange, userDatasetsOwned}) => {
const [value, setValue] = useState('');
const [options, setOptions] = useState([]);
const [radioOption, setRadioOptions] = useState(1);
const onSearch = (searchText) => {
setOptions(
- !searchText ? [] : [mockVal(searchText), mockVal(searchText, 2), mockVal(searchText, 3)],
+ !searchText ? [] : userDatasetsOwned.map(d => ({value: d.dataSetName})),
);
};
@@ -47,10 +48,6 @@ export const SaveDatasetModal: FunctionComponent<> = ({visible, onOk, onCancel,
console.log('onSelect', data);
};
- const onChange = (data) => {
- setValue(data);
- };
-
const onRadioChange = e => {
console.log('radio checked', e.target.value);
setRadioOptions(e.target.value)