You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by su...@apache.org on 2020/08/05 22:44:29 UTC

[incubator-superset] branch fix/dash-change-chart-title created (now 313bddb)

This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a change to branch fix/dash-change-chart-title
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git.


      at 313bddb  comprehensions > loops

This branch includes the following new commits:

     new 24b2b2d  changing slice names in dashboard should not change chart title
     new 313bddb  comprehensions > loops

The 2 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.



[incubator-superset] 01/02: changing slice names in dashboard should not change chart title

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch fix/dash-change-chart-title
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 24b2b2dbb7d5d780e609a22708c6133cef3bcc63
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Aug 5 15:40:13 2020 -0700

    changing slice names in dashboard should not change chart title
---
 .../dashboard/components/gridComponents/ChartHolder.jsx    |  8 ++++++--
 superset/dashboards/dao.py                                 | 14 --------------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
index 57a00b5..09a1ae5 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
@@ -156,7 +156,7 @@ class ChartHolder extends React.Component {
         ...component,
         meta: {
           ...component.meta,
-          sliceName: nextName,
+          sliceNameOverride: nextName,
         },
       },
     });
@@ -255,7 +255,11 @@ class ChartHolder extends React.Component {
                 dashboardId={dashboardId}
                 width={chartWidth}
                 height={chartHeight}
-                sliceName={component.meta.sliceName || ''}
+                sliceName={
+                  component.meta.sliceNameOverride ||
+                  component.meta.sliceName ||
+                  ''
+                }
                 updateSliceName={this.handleUpdateSliceName}
                 isComponentVisible={isComponentVisible}
                 handleToggleFullSize={this.handleToggleFullSize}
diff --git a/superset/dashboards/dao.py b/superset/dashboards/dao.py
index 5859640..7a4ee14 100644
--- a/superset/dashboards/dao.py
+++ b/superset/dashboards/dao.py
@@ -89,31 +89,17 @@ class DashboardDAO(BaseDAO):
         positions = data["positions"]
         # find slices in the position data
         slice_ids = []
-        slice_id_to_name = {}
         for value in positions.values():
             if isinstance(value, dict):
                 try:
                     slice_id = value["meta"]["chartId"]
                     slice_ids.append(slice_id)
-                    slice_id_to_name[slice_id] = value["meta"]["sliceName"]
                 except KeyError:
                     pass
 
         current_slices = db.session.query(Slice).filter(Slice.id.in_(slice_ids)).all()
         dashboard.slices = current_slices
 
-        # update slice names. this assumes user has permissions to update the slice
-        # we allow user set slice name be empty string
-        for slc in dashboard.slices:
-            try:
-                new_name = slice_id_to_name[slc.id]
-                if slc.slice_name != new_name:
-                    slc.slice_name = new_name
-                    db.session.merge(slc)
-                    db.session.flush()
-            except KeyError:
-                pass
-
         # remove leading and trailing white spaces in the dumped json
         dashboard.position_json = json.dumps(
             positions, indent=None, separators=(",", ":"), sort_keys=True


[incubator-superset] 02/02: comprehensions > loops

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch fix/dash-change-chart-title
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 313bddb0fdd37ec16eae6dd9fa6af21354942426
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Aug 5 15:43:38 2020 -0700

    comprehensions > loops
---
 superset/dashboards/dao.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/superset/dashboards/dao.py b/superset/dashboards/dao.py
index 7a4ee14..d56dea4 100644
--- a/superset/dashboards/dao.py
+++ b/superset/dashboards/dao.py
@@ -88,14 +88,11 @@ class DashboardDAO(BaseDAO):
     ) -> None:
         positions = data["positions"]
         # find slices in the position data
-        slice_ids = []
-        for value in positions.values():
-            if isinstance(value, dict):
-                try:
-                    slice_id = value["meta"]["chartId"]
-                    slice_ids.append(slice_id)
-                except KeyError:
-                    pass
+        slice_ids = [
+            value.get("meta", {}).get("chartId")
+            for value in positions.values()
+            if isinstance(value, dict)
+        ]
 
         current_slices = db.session.query(Slice).filter(Slice.id.in_(slice_ids)).all()
         dashboard.slices = current_slices