superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [dashboard] Fix save issue at Force_V2_Edit mode (#5360)
Date Sat, 07 Jul 2018 03:53:00 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo 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 a17f714  [dashboard] Fix save issue at Force_V2_Edit mode (#5360)
a17f714 is described below

commit a17f7141b75f4aca2458d3190ad92f96840ccbcd
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Fri Jul 6 20:52:56 2018 -0700

    [dashboard] Fix save issue at Force_V2_Edit mode (#5360)
---
 .../dashboard/deprecated/v1/components/Controls.jsx   |  1 +
 .../dashboard/deprecated/v1/components/Dashboard.jsx  | 18 ++++++++++++++++++
 .../src/dashboard/deprecated/v1/components/Header.jsx | 19 ++-----------------
 superset/views/core.py                                |  2 ++
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/superset/assets/src/dashboard/deprecated/v1/components/Controls.jsx b/superset/assets/src/dashboard/deprecated/v1/components/Controls.jsx
index 6a6fa47..3fbd1b7 100644
--- a/superset/assets/src/dashboard/deprecated/v1/components/Controls.jsx
+++ b/superset/assets/src/dashboard/deprecated/v1/components/Controls.jsx
@@ -144,6 +144,7 @@ class Controls extends React.PureComponent {
             }
           />
           {dashboard.dash_save_perm &&
+            dashboard.force_v2_edit &&
             <SaveModal
               dashboard={dashboard}
               filters={filters}
diff --git a/superset/assets/src/dashboard/deprecated/v1/components/Dashboard.jsx b/superset/assets/src/dashboard/deprecated/v1/components/Dashboard.jsx
index 6ba4159..ec831fa 100644
--- a/superset/assets/src/dashboard/deprecated/v1/components/Dashboard.jsx
+++ b/superset/assets/src/dashboard/deprecated/v1/components/Dashboard.jsx
@@ -10,6 +10,7 @@ import {
   Logger,
   ActionLog,
   DASHBOARD_EVENT_NAMES,
+  LOG_ACTIONS_PREVIEW_V2,
   LOG_ACTIONS_MOUNT_DASHBOARD,
   LOG_ACTIONS_EXPLORE_DASHBOARD_CHART,
   LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART,
@@ -68,6 +69,7 @@ class Dashboard extends React.PureComponent {
       unsavedChanges: false,
     };
     this.handleSetEditMode = this.handleSetEditMode.bind(this);
+    this.handleConvertToV2 = this.handleConvertToV2.bind(this);
 
     this.rerenderCharts = this.rerenderCharts.bind(this);
     this.updateDashboardTitle = this.updateDashboardTitle.bind(this);
@@ -346,6 +348,21 @@ class Dashboard extends React.PureComponent {
     exportChart(formData, 'csv');
   }
 
+  handleConvertToV2(editMode) {
+    Logger.append(
+      LOG_ACTIONS_PREVIEW_V2,
+      {
+        force_v2_edit: this.props.dashboard.forceV2Edit,
+        edit_mode: editMode === true,
+      },
+      true,
+    );
+    const url = new URL(window.location); // eslint-disable-line
+    url.searchParams.set('version', 'v2');
+    if (editMode === true) url.searchParams.set('edit', true);
+    window.location = url; // eslint-disable-line
+  }
+
   handleSetEditMode(nextEditMode) {
     if (this.props.dashboard.forceV2Edit) {
       this.handleConvertToV2(true);
@@ -386,6 +403,7 @@ class Dashboard extends React.PureComponent {
             addSlicesToDashboard={this.addSlicesToDashboard}
             editMode={this.props.editMode}
             setEditMode={this.handleSetEditMode}
+            handleConvertToV2={this.handleConvertToV2}
           />
         </div>
         <div id="grid-container" className="slice-grid gridster">
diff --git a/superset/assets/src/dashboard/deprecated/v1/components/Header.jsx b/superset/assets/src/dashboard/deprecated/v1/components/Header.jsx
index a84ee89..c801c0a 100644
--- a/superset/assets/src/dashboard/deprecated/v1/components/Header.jsx
+++ b/superset/assets/src/dashboard/deprecated/v1/components/Header.jsx
@@ -9,7 +9,6 @@ import InfoTooltipWithTrigger from '../../../../components/InfoTooltipWithTrigge
 import PromptV2ConversionModal from '../../PromptV2ConversionModal';
 import {
   Logger,
-  LOG_ACTIONS_PREVIEW_V2,
   LOG_ACTIONS_DISMISS_V2_PROMPT,
   LOG_ACTIONS_SHOW_V2_INFO_PROMPT,
 } from '../../../../logger';
@@ -31,6 +30,7 @@ const propTypes = {
   updateDashboardTitle: PropTypes.func,
   editMode: PropTypes.bool.isRequired,
   setEditMode: PropTypes.func.isRequired,
+  handleConvertToV2: PropTypes.func.isRequired,
   unsavedChanges: PropTypes.bool.isRequired,
 };
 
@@ -43,25 +43,10 @@ class Header extends React.PureComponent {
       showV2PromptModal: props.dashboard.promptV2Conversion,
     };
     this.toggleShowV2PromptModal = this.toggleShowV2PromptModal.bind(this);
-    this.handleConvertToV2 = this.handleConvertToV2.bind(this);
   }
   handleSaveTitle(title) {
     this.props.updateDashboardTitle(title);
   }
-  handleConvertToV2(editMode) {
-    Logger.append(
-      LOG_ACTIONS_PREVIEW_V2,
-      {
-        force_v2_edit: this.props.dashboard.forceV2Edit,
-        edit_mode: editMode === true,
-      },
-      true,
-    );
-    const url = new URL(window.location); // eslint-disable-line
-    url.searchParams.set('version', 'v2');
-    if (editMode === true) url.searchParams.set('edit', true);
-    window.location = url; // eslint-disable-line
-  }
   toggleEditMode() {
     this.props.setEditMode(!this.props.editMode);
   }
@@ -169,7 +154,7 @@ class Header extends React.PureComponent {
           !this.props.editMode && (
             <PromptV2ConversionModal
               onClose={this.toggleShowV2PromptModal}
-              handleConvertToV2={this.handleConvertToV2}
+              handleConvertToV2={this.props.handleConvertToV2}
               forceV2Edit={dashboard.forceV2Edit}
               v2AutoConvertDate={dashboard.v2AutoConvertDate}
               v2FeedbackUrl={dashboard.v2FeedbackUrl}
diff --git a/superset/views/core.py b/superset/views/core.py
index 6d7d7bc..0e51eac 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2169,6 +2169,8 @@ class Superset(BaseSupersetView):
             else:
                 dashboard_view = 'v1'
                 prompt_v2_conversion = not force_v1
+                if force_v2_edit:
+                    dash_edit_perm = False
 
         # Hack to log the dashboard_id properly, even when getting a slug
         @log_this


Mime
View raw message