You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by aa...@apache.org on 2022/07/21 16:08:34 UTC
[superset] branch arash.afghahi/sc-52999/explore-should-have-a-working-table-when created (now 9039880e31)
This is an automated email from the ASF dual-hosted git repository.
aafghahi pushed a change to branch arash.afghahi/sc-52999/explore-should-have-a-working-table-when
in repository https://gitbox.apache.org/repos/asf/superset.git
at 9039880e31 explore results button
This branch includes the following new commits:
new 9039880e31 explore results button
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: explore results button
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aafghahi pushed a commit to branch arash.afghahi/sc-52999/explore-should-have-a-working-table-when
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 9039880e31004568f07abc211127f54c4d0cd425
Author: AAfghahi <ar...@gmail.com>
AuthorDate: Thu Jul 21 12:08:04 2022 -0400
explore results button
---
.../src/SqlLab/components/ResultSet/index.tsx | 40 +++++++++++++++-------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
index 124d2546a6..dcc75ab7ce 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
@@ -29,6 +29,9 @@ import {
SaveDatasetModal,
} from 'src/SqlLab/components/SaveDatasetModal';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
+import { EXPLORE_CHART_DEFAULT } from 'src/SqlLab/types';
+import { mountExploreUrl } from 'src/explore/exploreUtils';
+import { postFormData } from 'src/explore/exploreUtils/formData';
import ProgressBar from 'src/components/ProgressBar';
import Loading from 'src/components/Loading';
import FilterableTable, {
@@ -41,6 +44,7 @@ import ExploreCtasResultsButton from '../ExploreCtasResultsButton';
import ExploreResultsButton from '../ExploreResultsButton';
import HighlightedSql from '../HighlightedSql';
import QueryStateLabel from '../QueryStateLabel';
+import { URL_PARAMS } from 'src/constants';
enum LIMITING_FACTOR {
QUERY = 'QUERY',
@@ -134,6 +138,8 @@ export default class ResultSet extends React.PureComponent<
this.reFetchQueryResults = this.reFetchQueryResults.bind(this);
this.toggleExploreResultsButton =
this.toggleExploreResultsButton.bind(this);
+ this.createExploreResultsOnClick =
+ this.createExploreResultsOnClick.bind(this);
}
async componentDidMount() {
@@ -213,6 +219,25 @@ export default class ResultSet extends React.PureComponent<
}
}
+ async createExploreResultsOnClick() {
+ const { results } = this.props.query;
+ if (results.query_id) {
+ const key = await postFormData(results.query_id, 'table', {
+ ...EXPLORE_CHART_DEFAULT,
+ datasource: `${results.query_id}__table`,
+ ...{
+ all_columns: results.columns.map(column => column.name),
+ },
+ });
+ const url = mountExploreUrl(null, {
+ [URL_PARAMS.formDataKey.name]: key,
+ });
+ window.open(url, '_blank', 'noreferrer');
+ } else {
+ this.setState({ showSaveDatasetModal: true });
+ }
+ }
+
renderControls() {
if (this.props.search || this.props.visualize || this.props.csv) {
let { data } = this.props.query.results;
@@ -223,7 +248,7 @@ export default class ResultSet extends React.PureComponent<
// Added compute logic to stop user from being able to Save & Explore
const { showSaveDatasetModal } = this.state;
const { query } = this.props;
-
+ console.log('this is query', query);
const datasource: ISaveableDatasource = {
columns: query.results.columns as ISimpleColumn[],
name: query?.tab || 'Untitled',
@@ -250,18 +275,7 @@ export default class ResultSet extends React.PureComponent<
this.props.database?.allows_virtual_table_explore && (
<ExploreResultsButton
database={this.props.database}
- onClick={() => {
- // There is currently redux / state issue where sometimes a query will have serverId
- // and other times it will not. We need this attribute consistently for this to work
- // const qid = this.props?.query?.results?.query_id;
- // if (qid) {
- // // This will open explore using the query as datasource
- // window.location.href = `/explore/?dataset_type=query&dataset_id=${qid}`;
- // } else {
- // this.setState({ showSaveDatasetModal: true });
- // }
- this.setState({ showSaveDatasetModal: true });
- }}
+ onClick={this.createExploreResultsOnClick}
/>
)}
{this.props.csv && (