From 007ad351cf8d27e1218ecc5f1619701a18787241 Mon Sep 17 00:00:00 2001 From: Riku Pelkonen Date: Mon, 5 Mar 2018 21:43:59 +0200 Subject: [PATCH] Pass datasource as form_data param (#4538) * Pass datasource as form_data param * add comma after datasource * change test to match new addSlice --- superset/assets/javascripts/addSlice/AddSliceContainer.jsx | 6 +++++- .../spec/javascripts/addSlice/AddSliceContainer_spec.jsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/superset/assets/javascripts/addSlice/AddSliceContainer.jsx b/superset/assets/javascripts/addSlice/AddSliceContainer.jsx index 48b31eb4797b8..05169346885c4 100644 --- a/superset/assets/javascripts/addSlice/AddSliceContainer.jsx +++ b/superset/assets/javascripts/addSlice/AddSliceContainer.jsx @@ -23,7 +23,11 @@ export default class AddSliceContainer extends React.PureComponent { } exploreUrl() { - const formData = encodeURIComponent(JSON.stringify({ viz_type: this.state.visType })); + const formData = encodeURIComponent( + JSON.stringify({ + viz_type: this.state.visType, + datasource: this.state.datasourceValue, + })); return `/superset/explore/?form_data=${formData}`; } diff --git a/superset/assets/spec/javascripts/addSlice/AddSliceContainer_spec.jsx b/superset/assets/spec/javascripts/addSlice/AddSliceContainer_spec.jsx index 2a1f09b79c11c..f91b301cdf491 100644 --- a/superset/assets/spec/javascripts/addSlice/AddSliceContainer_spec.jsx +++ b/superset/assets/spec/javascripts/addSlice/AddSliceContainer_spec.jsx @@ -53,7 +53,7 @@ describe('AddSliceContainer', () => { datasourceId: datasourceValue.split('__')[0], datasourceType: datasourceValue.split('__')[1], }); - const formattedUrl = '/superset/explore/?form_data=%7B%22viz_type%22%3A%22table%22%7D'; + const formattedUrl = '/superset/explore/?form_data=%7B%22viz_type%22%3A%22table%22%2C%22datasource%22%3A%221__table%22%7D'; expect(wrapper.instance().exploreUrl()).to.equal(formattedUrl); }); });