This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/so-1121 in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit f24c8796fb9cf56fc7352cd77a48d4aa8c6e306f Author: hughhhh <[email protected]> AuthorDate: Wed Oct 28 19:27:58 2020 -0700 poc --- .../src/explore/actions/exploreActions.ts | 15 +++++++++++++++ .../components/controls/DatasourceControl.jsx | 20 +++++++++++--------- .../src/explore/reducers/exploreReducer.js | 6 ++++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/superset-frontend/src/explore/actions/exploreActions.ts b/superset-frontend/src/explore/actions/exploreActions.ts index af71199..35c6d57 100644 --- a/superset-frontend/src/explore/actions/exploreActions.ts +++ b/superset-frontend/src/explore/actions/exploreActions.ts @@ -27,6 +27,7 @@ import { import { Dispatch } from 'redux'; import { addDangerToast } from 'src/messageToasts/actions'; import { Slice } from 'src/types/Chart'; +import { postForm } from '../exploreUtils'; const FAVESTAR_BASE_URL = '/superset/favstar/slice'; @@ -147,6 +148,19 @@ export function sliceUpdated(slice: Slice) { return { type: SLICE_UPDATED, slice }; } +export const VIEW_IN_SQLLAB = 'VIEW_IN_SQLLAB'; +export function redirectSQLLab(formData) { + return dispatch => { + console.log("inside redirectSQLLab", formData); + const payload = { + datasourceKey: `${formData.datasource.id}__${formData.datasource.type}`, + sql: formData.datasource.sql, + }; + console.log("posting form", payload); + postForm('/superset/sqllab', payload); + }; +} + export const exploreActions = { setDatasourceType, setDatasource, @@ -163,6 +177,7 @@ export const exploreActions = { updateChartTitle, createNewSlice, sliceUpdated, + redirectSQLLab, }; export type ExploreActions = typeof exploreActions; diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl.jsx b/superset-frontend/src/explore/components/controls/DatasourceControl.jsx index 1d70249..264c39f 100644 --- a/superset-frontend/src/explore/components/controls/DatasourceControl.jsx +++ b/superset-frontend/src/explore/components/controls/DatasourceControl.jsx @@ -29,6 +29,7 @@ import ChangeDatasourceModal from 'src/datasource/ChangeDatasourceModal'; import DatasourceModal from 'src/datasource/DatasourceModal'; import Label from 'src/components/Label'; +import redirectToSqlLab from 'src/chart/chartAction'; import ControlHeader from '../ControlHeader'; const propTypes = { @@ -138,6 +139,15 @@ class DatasourceControl extends React.PureComponent { if (key === EDIT_DATASET) { this.toggleEditDatasourceModal(); } + if (key === EXPLORE_IN_SQL_LAB) { + console.log("pressed btn view in sql lab"); + console.log("this.props", this.props); + const { datasource } = this.props; + // console.log("this.props.datasource.sql", this.props.datasource.sql); + + console.log('calling redirect to sqllab'); + this.props.actions.redirectSQLLab({ datasource }); + } } renderDatasource() { @@ -200,15 +210,7 @@ class DatasourceControl extends React.PureComponent { </Menu.Item> )} <Menu.Item key={CHANGE_DATASET}>{t('Change Dataset')}</Menu.Item> - <Menu.Item key={EXPLORE_IN_SQL_LAB}> - <a - href={`/superset/sqllab?datasourceKey=${value}`} - target="_blank" - rel="noopener noreferrer" - > - {t('View in SQL Lab')} - </a> - </Menu.Item> + <Menu.Item key={EXPLORE_IN_SQL_LAB}>{t('View in SQL Lab')}</Menu.Item> </Menu> ); diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js b/superset-frontend/src/explore/reducers/exploreReducer.js index 36d7908..1a3f6a9 100644 --- a/superset-frontend/src/explore/reducers/exploreReducer.js +++ b/superset-frontend/src/explore/reducers/exploreReducer.js @@ -27,6 +27,12 @@ import * as actions from '../actions/exploreActions'; export default function exploreReducer(state = {}, action) { const actionHandlers = { + [actions.VIEW_IN_SQLLAB]() { + console.log('changed the state to sqllab'); + return { + ...state, + }; + }, [actions.TOGGLE_FAVE_STAR]() { return { ...state,
