You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by cc...@apache.org on 2018/09/11 22:51:17 UTC
[incubator-superset] branch chris--ajax-dashboard updated (8cd1b07
-> 1b314b4)
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a change to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git.
omit 8cd1b07 [core] fix SupersetClient dashboard tests
omit 8e7ae60 [core] replace dashboard ajax calls with SupersetClient
omit 23ee2cb [superset-client] initialize SupersetClient in app setup
omit ad73493 [deps] add @superset-ui/core
add 73db918 Upgrade to React==16.4.1 & Enzyme==3.3.0 (#5359)
add 039e7c5 [sql lab] handle large ints, prevent overflow (#5829)
add 73cfccc [bugfix] 'No numeric types to aggregate' in NVD3 chart (#5853)
add ce362f0 [bugfix] fix rows not showing on welcome page (retry) (#5849)
add 9a4bba4 [sqllab]More granular sqllab logging (#5736)
add 965c838 update dashboard sidepane title (#5850)
add 1f6e8b3 [dev] fix redux devtools (#5855)
add 6ae285b Adding line and big number total integration tests (#5846)
add 6df720d [bugfix] mapbox pan on filter (#5858)
new 4bb8820 [deps] add @superset-ui/core
new 617128e [superset-client] initialize SupersetClient in app setup
new 503f5bc [core] replace dashboard ajax calls with SupersetClient
new 1b314b4 [core] fix SupersetClient dashboard tests
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (8cd1b07)
\
N -- N -- N refs/heads/chris--ajax-dashboard (1b314b4)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 4 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.
Summary of changes:
superset/assets/cypress.json | 4 +-
.../cypress/integration/explore/control_tests.js | 6 +-
.../integration/explore/visualization_tests.js | 54 --
.../explore/visualizations/big_number.js | 58 ++
.../integration/explore/visualizations/line.js | 140 +++
.../explore/visualizations/shared.helper.js | 40 +
superset/assets/cypress/support/commands.js | 22 +-
superset/assets/package.json | 25 +-
.../assets/spec/helpers/{browser.js => shim.js} | 5 +
.../assets/spec/javascripts/chart/Chart_spec.jsx | 2 -
.../javascripts/components/AsyncSelect_spec.jsx | 1 -
.../dashboard/components/Dashboard_spec.jsx | 8 -
.../components/gridComponents/Markdown_spec.jsx | 3 +-
.../components/AdhocFilterEditPopover_spec.jsx | 2 +-
.../AdhocMetricEditPopoverTitle_spec.jsx | 2 +-
.../explore/components/DateFilterControl_spec.jsx | 18 +-
.../explore/components/DisplayQueryButton_spec.jsx | 2 -
.../spec/javascripts/sqllab/TableElement_spec.jsx | 4 +-
.../assets/spec/javascripts/sqllab/actions_spec.js | 9 +-
.../spec/javascripts/visualizations/table_spec.jsx | 2 +-
superset/assets/src/SqlLab/actions.js | 10 +-
.../assets/src/SqlLab/components/SqlEditor.jsx | 2 +-
superset/assets/src/chart/chartAction.js | 2 +-
superset/assets/src/common.js | 12 +-
.../dashboard/components/BuilderComponentPane.jsx | 4 +-
.../explore/components/AdhocMetricEditPopover.jsx | 10 +-
.../explore/components/controls/SpatialControl.jsx | 1 -
superset/assets/src/explore/visTypes.jsx | 1 +
superset/assets/src/reduxUtils.js | 2 +-
superset/assets/src/utils/common.js | 9 +-
.../assets/src/visualizations/MapBox/MapBox.jsx | 56 +-
superset/assets/src/welcome/App.jsx | 1 -
superset/assets/src/welcome/DashboardTable.jsx | 6 +-
superset/assets/webpack.config.js | 5 +
superset/assets/yarn.lock | 988 ++++++++++-----------
superset/sql_lab.py | 21 +-
superset/views/core.py | 8 +-
superset/viz.py | 14 +-
yarn.lock | 4 -
39 files changed, 860 insertions(+), 703 deletions(-)
delete mode 100644 superset/assets/cypress/integration/explore/visualization_tests.js
create mode 100644 superset/assets/cypress/integration/explore/visualizations/big_number.js
create mode 100644 superset/assets/cypress/integration/explore/visualizations/line.js
create mode 100644 superset/assets/cypress/integration/explore/visualizations/shared.helper.js
rename superset/assets/spec/helpers/{browser.js => shim.js} (93%)
delete mode 100644 yarn.lock
[incubator-superset] 04/04: [core] fix SupersetClient dashboard
tests
Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 1b314b46c7c2680e7f19e986fd56f3f479e5d759
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Mon Sep 10 22:06:13 2018 -0700
[core] fix SupersetClient dashboard tests
---
.../dashboard/components/DashboardBuilder_spec.jsx | 18 +++++++++++++++++-
.../dashboard/reducers/sliceEntities_spec.js | 6 +++---
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx b/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
index 4c3185f..5033988 100644
--- a/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
+++ b/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
@@ -1,8 +1,9 @@
import { Provider } from 'react-redux';
import React from 'react';
import { shallow, mount } from 'enzyme';
-import { describe, it } from 'mocha';
+import { describe, it, before, after } from 'mocha';
import { expect } from 'chai';
+import sinon from 'sinon';
import ParentSize from '@vx/responsive/build/components/ParentSize';
import { Sticky, StickyContainer } from 'react-sticky';
@@ -13,6 +14,8 @@ import DashboardBuilder from '../../../../src/dashboard/components/DashboardBuil
import DashboardComponent from '../../../../src/dashboard/containers/DashboardComponent';
import DashboardHeader from '../../../../src/dashboard/containers/DashboardHeader';
import DashboardGrid from '../../../../src/dashboard/containers/DashboardGrid';
+import * as dashboardStateActions from '../../../../src/dashboard/actions/dashboardState';
+
import WithDragDropContext from '../helpers/WithDragDropContext';
import {
dashboardLayout as undoableDashboardLayout,
@@ -25,6 +28,19 @@ const dashboardLayout = undoableDashboardLayout.present;
const layoutWithTabs = undoableDashboardLayoutWithTabs.present;
describe('DashboardBuilder', () => {
+ let favStarStub;
+
+ before(() => {
+ // this is invoked on mount, so we stub it instead of making a request
+ favStarStub = sinon
+ .stub(dashboardStateActions, 'fetchFaveStar')
+ .returns({ type: 'mock-action' });
+ });
+
+ after(() => {
+ favStarStub.restore();
+ });
+
const props = {
dashboardLayout,
deleteTopLevelTabs() {},
diff --git a/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js b/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
index 7e3bb76..891df61 100644
--- a/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
+++ b/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
@@ -26,7 +26,7 @@ describe('sliceEntities reducer', () => {
it('should set slices', () => {
const result = sliceEntitiesReducer(
{ slices: { a: {} } },
- { type: SET_ALL_SLICES, slices: { 1: {}, 2: {} } },
+ { type: SET_ALL_SLICES, payload: { slices: { 1: {}, 2: {} } } },
);
expect(result.slices).to.deep.equal({
@@ -42,10 +42,10 @@ describe('sliceEntities reducer', () => {
{},
{
type: FETCH_ALL_SLICES_FAILED,
- error: { responseJSON: { message: 'errorrr' } },
+ payload: { error: 'failed' },
},
);
expect(result.isLoading).to.equal(false);
- expect(result.errorMessage.indexOf('errorrr')).to.be.above(-1);
+ expect(result.errorMessage.indexOf('failed')).to.be.above(-1);
});
});
[incubator-superset] 03/04: [core] replace dashboard ajax calls
with SupersetClient
Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 503f5bc2244852bf0b5533c7e7a3eb257b984bbc
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Mon Sep 10 22:05:22 2018 -0700
[core] replace dashboard ajax calls with SupersetClient
---
.../assets/src/dashboard/actions/dashboardState.js | 73 +++++++++++++---------
.../assets/src/dashboard/actions/datasources.js | 18 +++---
.../assets/src/dashboard/actions/sliceEntities.js | 41 ++++++++----
.../assets/src/dashboard/components/SaveModal.jsx | 11 +++-
.../assets/src/dashboard/components/SliceAdder.jsx | 6 +-
.../dashboard/components/gridComponents/Chart.jsx | 2 +-
.../assets/src/dashboard/reducers/sliceEntities.js | 12 ++--
.../dashboard/stylesheets/builder-sidepane.less | 7 +++
superset/assets/src/dashboard/util/propShapes.jsx | 2 +-
9 files changed, 108 insertions(+), 64 deletions(-)
diff --git a/superset/assets/src/dashboard/actions/dashboardState.js b/superset/assets/src/dashboard/actions/dashboardState.js
index 17f6d46..e2cb0f3 100644
--- a/superset/assets/src/dashboard/actions/dashboardState.js
+++ b/superset/assets/src/dashboard/actions/dashboardState.js
@@ -1,6 +1,6 @@
/* eslint camelcase: 0 */
-import $ from 'jquery';
import { ActionCreators as UndoActionCreators } from 'redux-undo';
+import { SupersetClient } from '@superset-ui/core';
import { addChart, removeChart, refreshChart } from '../../chart/chartAction';
import { chart as initChart } from '../../chart/chartReducer';
@@ -14,7 +14,6 @@ import {
} from '../../logger';
import { SAVE_TYPE_OVERWRITE } from '../util/constants';
import { t } from '../../locales';
-
import {
addSuccessToast,
addWarningToast,
@@ -57,12 +56,21 @@ export function toggleFaveStar(isStarred) {
export const FETCH_FAVE_STAR = 'FETCH_FAVE_STAR';
export function fetchFaveStar(id) {
return function fetchFaveStarThunk(dispatch) {
- const url = `${FAVESTAR_BASE_URL}/${id}/count`;
- return $.get(url).done(data => {
- if (data.count > 0) {
- dispatch(toggleFaveStar(true));
- }
- });
+ return SupersetClient.get({
+ endpoint: `${FAVESTAR_BASE_URL}/${id}/count`,
+ })
+ .then(({ json }) => {
+ if (json.count > 0) dispatch(toggleFaveStar(true));
+ })
+ .catch(() =>
+ dispatch(
+ addDangerToast(
+ t(
+ 'There was an issue fetching the favorite status of this dashboard.',
+ ),
+ ),
+ ),
+ );
};
}
@@ -70,9 +78,17 @@ export const SAVE_FAVE_STAR = 'SAVE_FAVE_STAR';
export function saveFaveStar(id, isStarred) {
return function saveFaveStarThunk(dispatch) {
const urlSuffix = isStarred ? 'unselect' : 'select';
- const url = `${FAVESTAR_BASE_URL}/${id}/${urlSuffix}/`;
- $.get(url);
- dispatch(toggleFaveStar(!isStarred));
+ return SupersetClient.get({
+ endpoint: `${FAVESTAR_BASE_URL}/${id}/${urlSuffix}/`,
+ })
+ .then(() => {
+ dispatch(toggleFaveStar(!isStarred));
+ })
+ .catch(() =>
+ dispatch(
+ addDangerToast(t('There was an issue favoriting this dashboard.')),
+ ),
+ );
};
}
@@ -111,28 +127,29 @@ export function saveDashboardRequestSuccess() {
export function saveDashboardRequest(data, id, saveType) {
const path = saveType === SAVE_TYPE_OVERWRITE ? 'save_dash' : 'copy_dash';
- const url = `/superset/${path}/${id}/`;
+
return dispatch =>
- $.ajax({
- type: 'POST',
- url,
- data: {
- data: JSON.stringify(data),
- },
- success: () => {
- dispatch(saveDashboardRequestSuccess());
- dispatch(addSuccessToast(t('This dashboard was saved successfully.')));
- },
- error: error => {
- const errorMsg = getAjaxErrorMsg(error);
+ SupersetClient.post({
+ endpoint: `/superset/${path}/${id}/`,
+ postPayload: { data },
+ })
+ .then(response =>
+ Promise.all([
+ Promise.resolve(response),
+ dispatch(saveDashboardRequestSuccess()),
+ dispatch(
+ addSuccessToast(t('This dashboard was saved successfully.')),
+ ),
+ ]),
+ )
+ .catch(error =>
dispatch(
addDangerToast(
`${t('Sorry, there was an error saving this dashboard: ')}
- ${errorMsg}`,
+ ${getAjaxErrorMsg(error)}`,
),
- );
- },
- });
+ ),
+ );
}
export function fetchCharts(chartList = [], force = false, interval = 0) {
diff --git a/superset/assets/src/dashboard/actions/datasources.js b/superset/assets/src/dashboard/actions/datasources.js
index d97296e..eab9e99 100644
--- a/superset/assets/src/dashboard/actions/datasources.js
+++ b/superset/assets/src/dashboard/actions/datasources.js
@@ -1,4 +1,5 @@
-import $ from 'jquery';
+import { SupersetClient } from '@superset-ui/core';
+import { getAjaxErrorMsg } from '../../modules/utils';
export const SET_DATASOURCE = 'SET_DATASOURCE';
export function setDatasource(datasource, key) {
@@ -24,13 +25,12 @@ export function fetchDatasourceMetadata(key) {
return dispatch(setDatasource(datasource, key));
}
- const url = `/superset/fetch_datasource_metadata?datasourceKey=${key}`;
- return $.ajax({
- type: 'GET',
- url,
- success: data => dispatch(setDatasource(data, key)),
- error: error =>
- dispatch(fetchDatasourceFailed(error.responseJSON.error, key)),
- });
+ return SupersetClient.get({
+ endpoint: `/superset/fetch_datasource_metadata?datasourceKey=${key}`,
+ })
+ .then(data => dispatch(data, key))
+ .catch(error =>
+ dispatch(fetchDatasourceFailed(getAjaxErrorMsg(error), key)),
+ );
};
}
diff --git a/superset/assets/src/dashboard/actions/sliceEntities.js b/superset/assets/src/dashboard/actions/sliceEntities.js
index b635ea0..33e3507 100644
--- a/superset/assets/src/dashboard/actions/sliceEntities.js
+++ b/superset/assets/src/dashboard/actions/sliceEntities.js
@@ -1,11 +1,13 @@
/* eslint camelcase: 0 */
-import $ from 'jquery';
+import { SupersetClient } from '@superset-ui/core';
+import { addDangerToast } from '../../messageToasts/actions';
+import { t } from '../../locales';
import { getDatasourceParameter } from '../../modules/utils';
export const SET_ALL_SLICES = 'SET_ALL_SLICES';
export function setAllSlices(slices) {
- return { type: SET_ALL_SLICES, slices };
+ return { type: SET_ALL_SLICES, payload: { slices } };
}
export const FETCH_ALL_SLICES_STARTED = 'FETCH_ALL_SLICES_STARTED';
@@ -15,7 +17,7 @@ export function fetchAllSlicesStarted() {
export const FETCH_ALL_SLICES_FAILED = 'FETCH_ALL_SLICES_FAILED';
export function fetchAllSlicesFailed(error) {
- return { type: FETCH_ALL_SLICES_FAILED, error };
+ return { type: FETCH_ALL_SLICES_FAILED, payload: { error } };
}
export function fetchAllSlices(userId) {
@@ -24,13 +26,12 @@ export function fetchAllSlices(userId) {
if (sliceEntities.lastUpdated === 0) {
dispatch(fetchAllSlicesStarted());
- const uri = `/sliceaddview/api/read?_flt_0_created_by=${userId}`;
- return $.ajax({
- url: uri,
- type: 'GET',
- success: response => {
+ return SupersetClient.get({
+ endpoint: `/sliceaddview/api/read?_flt_0_created_by=${userId}`,
+ })
+ .then(({ json }) => {
const slices = {};
- response.result.forEach(slice => {
+ json.result.forEach(slice => {
let form_data = JSON.parse(slice.params);
let datasource = form_data.datasource;
if (!datasource) {
@@ -60,10 +61,26 @@ export function fetchAllSlices(userId) {
};
}
});
+
return dispatch(setAllSlices(slices));
- },
- error: error => dispatch(fetchAllSlicesFailed(error)),
- });
+ })
+ .catch(error =>
+ Promise.all([
+ dispatch(
+ fetchAllSlicesFailed(
+ error.error ||
+ error.statusText ||
+ t('Could not fetch all saved charts'),
+ ),
+ ),
+ dispatch(
+ addDangerToast(
+ t('Sorry there was an error fetching saved charts: ') +
+ error.error || error.statusText,
+ ),
+ ),
+ ]),
+ );
}
return dispatch(setAllSlices(sliceEntities.slices));
diff --git a/superset/assets/src/dashboard/components/SaveModal.jsx b/superset/assets/src/dashboard/components/SaveModal.jsx
index 8194f46..13863a2 100644
--- a/superset/assets/src/dashboard/components/SaveModal.jsx
+++ b/superset/assets/src/dashboard/components/SaveModal.jsx
@@ -93,9 +93,14 @@ class SaveModal extends React.PureComponent {
t('You must pick a name for the new dashboard'),
);
} else {
- this.onSave(data, dashboardId, saveType).done(resp => {
- if (saveType === SAVE_TYPE_NEWDASHBOARD) {
- window.location = `/superset/dashboard/${resp.id}/`;
+ this.onSave(data, dashboardId, saveType).then(([resp]) => {
+ if (
+ saveType === SAVE_TYPE_NEWDASHBOARD &&
+ resp &&
+ resp.json &&
+ resp.json.id
+ ) {
+ window.location = `/superset/dashboard/${resp.json.id}/`;
}
});
this.modal.close();
diff --git a/superset/assets/src/dashboard/components/SliceAdder.jsx b/superset/assets/src/dashboard/components/SliceAdder.jsx
index 31ad797..608cfc1 100644
--- a/superset/assets/src/dashboard/components/SliceAdder.jsx
+++ b/superset/assets/src/dashboard/components/SliceAdder.jsx
@@ -226,8 +226,6 @@ class SliceAdder extends React.Component {
{this.props.isLoading && <Loading />}
- {this.props.errorMessage && <div>{this.props.errorMessage}</div>}
-
{!this.props.isLoading &&
this.state.filteredSlices.length > 0 && (
<List
@@ -243,6 +241,10 @@ class SliceAdder extends React.Component {
/>
)}
+ {this.props.errorMessage && (
+ <div className="error-message">{this.props.errorMessage}</div>
+ )}
+
{/* Drag preview is just a single fixed-position element */}
<AddSliceDragPreview slices={this.state.filteredSlices} />
</div>
diff --git a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
index 7e2e6a6..96c92d9 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
@@ -233,7 +233,7 @@ class Chart extends React.Component {
latestQueryFormData={chart.latestQueryFormData}
lastRendered={chart.lastRendered}
queryResponse={chart.queryResponse}
- queryRequest={chart.queryRequest}
+ queryController={chart.queryController}
triggerQuery={chart.triggerQuery}
/>
</div>
diff --git a/superset/assets/src/dashboard/reducers/sliceEntities.js b/superset/assets/src/dashboard/reducers/sliceEntities.js
index c5e46c2..a96368a 100644
--- a/superset/assets/src/dashboard/reducers/sliceEntities.js
+++ b/superset/assets/src/dashboard/reducers/sliceEntities.js
@@ -3,6 +3,7 @@ import {
FETCH_ALL_SLICES_STARTED,
SET_ALL_SLICES,
} from '../actions/sliceEntities';
+
import { t } from '../../locales';
export const initSliceEntities = {
@@ -27,22 +28,17 @@ export default function sliceEntitiesReducer(
return {
...state,
isLoading: false,
- slices: { ...state.slices, ...action.slices }, // append more slices
+ slices: { ...state.slices, ...action.payload.slices },
lastUpdated: new Date().getTime(),
};
},
[FETCH_ALL_SLICES_FAILED]() {
- const respJSON = action.error.responseJSON;
- const errorMessage =
- t('Sorry, there was an error fetching slices: ') +
- (respJSON && respJSON.message)
- ? respJSON.message
- : action.error.responseText;
return {
...state,
isLoading: false,
- errorMessage,
lastUpdated: new Date().getTime(),
+ errorMessage:
+ action.payload.error || t('Could not fetch all saved charts'),
};
},
};
diff --git a/superset/assets/src/dashboard/stylesheets/builder-sidepane.less b/superset/assets/src/dashboard/stylesheets/builder-sidepane.less
index 17c87a8..08355e3 100644
--- a/superset/assets/src/dashboard/stylesheets/builder-sidepane.less
+++ b/superset/assets/src/dashboard/stylesheets/builder-sidepane.less
@@ -127,6 +127,13 @@
}
.slice-adder-container {
+ position: relative;
+ min-height: 200px; /* for loader positioning */
+
+ .error-message {
+ padding: 16px;
+ }
+
.controls {
display: flex;
padding: 16px;
diff --git a/superset/assets/src/dashboard/util/propShapes.jsx b/superset/assets/src/dashboard/util/propShapes.jsx
index 3c06e14..faedb91 100644
--- a/superset/assets/src/dashboard/util/propShapes.jsx
+++ b/superset/assets/src/dashboard/util/propShapes.jsx
@@ -27,7 +27,7 @@ export const chartPropShape = PropTypes.shape({
chartUpdateEndTime: PropTypes.number,
chartUpdateStartTime: PropTypes.number,
latestQueryFormData: PropTypes.object,
- queryRequest: PropTypes.object,
+ queryController: PropTypes.shape({ abort: PropTypes.func }),
queryResponse: PropTypes.object,
triggerQuery: PropTypes.bool,
lastRendered: PropTypes.number,
[incubator-superset] 01/04: [deps] add @superset-ui/core
Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 4bb8820d31a780caad896b4b7b590108b3138310
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Mon Sep 10 22:02:23 2018 -0700
[deps] add @superset-ui/core
---
superset/assets/package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/superset/assets/package.json b/superset/assets/package.json
index 667b4cb..ab04efa 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -50,6 +50,7 @@
"@data-ui/sparkline": "^0.0.54",
"@data-ui/theme": "^0.0.62",
"@data-ui/xy-chart": "^0.0.61",
+ "@superset-ui/core": "^0.0.2",
"@vx/legend": "^0.0.170",
"@vx/responsive": "0.0.172",
"@vx/scale": "^0.0.165",
[incubator-superset] 02/04: [superset-client] initialize
SupersetClient in app setup
Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 617128e590c71a517264de4e799697eda83f8083
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Mon Sep 10 22:03:48 2018 -0700
[superset-client] initialize SupersetClient in app setup
---
superset/assets/src/common.js | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/superset/assets/src/common.js b/superset/assets/src/common.js
index 67ce498..e23821e 100644
--- a/superset/assets/src/common.js
+++ b/superset/assets/src/common.js
@@ -1,16 +1,17 @@
-/* eslint-disable global-require */
+/* eslint global-require: 0, no-console: 0 */
import $ from 'jquery';
+import { SupersetClient } from '@superset-ui/core';
+
// Everything imported in this file ends up in the common entry file
// be mindful of double-imports
-
-const utils = require('./modules/utils');
+import { toggleCheckbox } from './modules/utils';
$(document).ready(function () {
$(':checkbox[data-checkbox-api-prefix]').change(function () {
const $this = $(this);
const prefix = $this.data('checkbox-api-prefix');
const id = $this.attr('id');
- utils.toggleCheckbox(prefix, '#' + id);
+ toggleCheckbox(prefix, '#' + id);
});
// for language picker dropdown
@@ -18,10 +19,9 @@ $(document).ready(function () {
ev.preventDefault();
const targetUrl = ev.currentTarget.href;
- $.ajax(targetUrl)
- .then(() => {
- location.reload();
- });
+ $.ajax(targetUrl).then(() => {
+ location.reload();
+ });
});
});
@@ -31,4 +31,10 @@ export function appSetup() {
window.$ = $;
window.jQuery = $;
require('bootstrap');
+
+ SupersetClient.configure({ host: (window.location && window.location.host) || '' })
+ .init()
+ .catch((error) => {
+ console.warn(error);
+ });
}