You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2020/12/18 21:17:54 UTC
[incubator-superset] branch master updated: Improves chart save and
go button (#12125)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new a6ac2c1 Improves chart save and go button (#12125)
a6ac2c1 is described below
commit a6ac2c1245b292239e179a063426c541e4b34ca2
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Dec 18 18:17:31 2020 -0300
Improves chart save and go button (#12125)
Resolves #11748
---
.../src/dashboard/containers/Chart.jsx | 26 +++++++++++++---------
.../explore/components/ExploreViewContainer.jsx | 3 +++
.../src/explore/components/SaveModal.jsx | 9 +++++++-
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/src/dashboard/containers/Chart.jsx b/superset-frontend/src/dashboard/containers/Chart.jsx
index 634a201..f8ad642 100644
--- a/superset-frontend/src/dashboard/containers/Chart.jsx
+++ b/superset-frontend/src/dashboard/containers/Chart.jsx
@@ -50,24 +50,28 @@ function mapStateToProps(
) {
const { id } = ownProps;
const chart = chartQueries[id] || {};
+ const datasource =
+ (chart && chart.form_data && datasources[chart.form_data.datasource]) || {};
const { colorScheme, colorNamespace } = dashboardState;
+ // note: this method caches filters if possible to prevent render cascades
+ const formData = getFormDataWithExtraFilters({
+ chart,
+ filters: getAppliedFilterValues(id),
+ colorScheme,
+ colorNamespace,
+ sliceId: id,
+ });
+
+ formData.dashboardId = dashboardInfo.id;
+
return {
chart,
- datasource:
- (chart && chart.form_data && datasources[chart.form_data.datasource]) ||
- {},
+ datasource,
slice: sliceEntities.slices[id],
timeout: dashboardInfo.common.conf.SUPERSET_WEBSERVER_TIMEOUT,
filters: getActiveFilters() || EMPTY_FILTERS,
- // note: this method caches filters if possible to prevent render cascades
- formData: getFormDataWithExtraFilters({
- chart,
- filters: getAppliedFilterValues(id),
- colorScheme,
- colorNamespace,
- sliceId: id,
- }),
+ formData,
editMode: dashboardState.editMode,
isExpanded: !!dashboardState.expandedSlices[id],
supersetCanExplore: !!dashboardInfo.superset_can_explore,
diff --git a/superset-frontend/src/explore/components/ExploreViewContainer.jsx b/superset-frontend/src/explore/components/ExploreViewContainer.jsx
index 69cffd4..5970c6f 100644
--- a/superset-frontend/src/explore/components/ExploreViewContainer.jsx
+++ b/superset-frontend/src/explore/components/ExploreViewContainer.jsx
@@ -47,6 +47,7 @@ import {
const propTypes = {
actions: PropTypes.object.isRequired,
datasource_type: PropTypes.string.isRequired,
+ dashboardId: PropTypes.number,
isDatasourceMetaLoading: PropTypes.bool.isRequired,
chart: chartPropShape.isRequired,
slice: PropTypes.object,
@@ -413,6 +414,7 @@ class ExploreViewContainer extends React.Component {
actions={this.props.actions}
form_data={this.props.form_data}
sliceName={this.props.sliceName}
+ dashboardId={this.props.dashboardId}
/>
)}
<div
@@ -508,6 +510,7 @@ function mapStateToProps(state) {
datasource: explore.datasource,
datasource_type: explore.datasource.type,
datasourceId: explore.datasource_id,
+ dashboardId: explore.form_data ? explore.form_data.dashboardId : undefined,
controls: explore.controls,
can_overwrite: !!explore.can_overwrite,
can_add: !!explore.can_add,
diff --git a/superset-frontend/src/explore/components/SaveModal.jsx b/superset-frontend/src/explore/components/SaveModal.jsx
index 67d1c5b..ddf8c3e 100644
--- a/superset-frontend/src/explore/components/SaveModal.jsx
+++ b/superset-frontend/src/explore/components/SaveModal.jsx
@@ -38,6 +38,7 @@ const propTypes = {
alert: PropTypes.string,
slice: PropTypes.object,
datasource: PropTypes.object,
+ dashboardId: PropTypes.number,
};
// Session storage key for recent dashboard
@@ -64,6 +65,11 @@ class SaveModal extends React.Component {
);
let recentDashboard = sessionStorage.getItem(SK_DASHBOARD_ID);
recentDashboard = recentDashboard && parseInt(recentDashboard, 10);
+
+ if (!recentDashboard && this.props.dashboardId) {
+ recentDashboard = this.props.dashboardId;
+ }
+
if (
recentDashboard !== null &&
dashboardIds.indexOf(recentDashboard) !== -1
@@ -146,7 +152,8 @@ class SaveModal extends React.Component {
id="btn_modal_save_goto_dash"
buttonSize="sm"
disabled={
- !this.state.newSliceName || !this.state.newDashboardName
+ !this.state.newSliceName ||
+ (!this.state.saveToDashboardId && !this.state.newDashboardName)
}
onClick={this.saveOrOverwrite.bind(this, true)}
>