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/03/20 08:12:48 UTC

[incubator-superset] branch chris--top-level-tabs updated: [dashboard-builder] make sure getChildWidth returns a number

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

ccwilliams pushed a commit to branch chris--top-level-tabs
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/chris--top-level-tabs by this push:
     new b5dca0e  [dashboard-builder] make sure getChildWidth returns a number
b5dca0e is described below

commit b5dca0ea35adfce8f093eaa1d37823065b9519a1
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Tue Mar 20 01:12:31 2018 -0700

    [dashboard-builder] make sure getChildWidth returns a number
---
 .../javascripts/dashboard/v2/components/gridComponents/Spacer.jsx   | 4 +++-
 superset/assets/javascripts/dashboard/v2/reducers/dashboard.js      | 2 +-
 superset/assets/javascripts/dashboard/v2/stylesheets/grid.less      | 2 +-
 superset/assets/javascripts/dashboard/v2/util/getChildWidth.js      | 4 ++--
 .../assets/javascripts/dashboard/v2/util/newEntitiesFromDrop.js     | 6 ------
 5 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/superset/assets/javascripts/dashboard/v2/components/gridComponents/Spacer.jsx b/superset/assets/javascripts/dashboard/v2/components/gridComponents/Spacer.jsx
index 95a709a..7a287d8 100644
--- a/superset/assets/javascripts/dashboard/v2/components/gridComponents/Spacer.jsx
+++ b/superset/assets/javascripts/dashboard/v2/components/gridComponents/Spacer.jsx
@@ -60,6 +60,8 @@ class Spacer extends React.PureComponent {
     const adjustableWidth = orientation === 'column';
     const adjustableHeight = orientation === 'row';
 
+    console.log('spacer', availableColumnCount)
+
     return (
       <DragDroppable
         component={component}
@@ -75,7 +77,7 @@ class Spacer extends React.PureComponent {
             adjustableWidth={adjustableWidth}
             adjustableHeight={adjustableHeight}
             widthStep={columnWidth}
-            widthMultiple={component.meta.width}
+            widthMultiple={component.meta.width || 1}
             heightMultiple={adjustableHeight ? component.meta.height || 1 : undefined}
             minWidthMultiple={1}
             minHeightMultiple={1}
diff --git a/superset/assets/javascripts/dashboard/v2/reducers/dashboard.js b/superset/assets/javascripts/dashboard/v2/reducers/dashboard.js
index f2ef3d2..9b03861 100644
--- a/superset/assets/javascripts/dashboard/v2/reducers/dashboard.js
+++ b/superset/assets/javascripts/dashboard/v2/reducers/dashboard.js
@@ -104,7 +104,7 @@ const actionHandlers = {
       destination,
     });
 
-    // wrap the dragged component in a row depening on destination type
+    // wrap the dragged component in a row depending on destination type
     const wrapInRow = shouldWrapChildInRow({
       parentType: destination.type,
       childType: dragging.type,
diff --git a/superset/assets/javascripts/dashboard/v2/stylesheets/grid.less b/superset/assets/javascripts/dashboard/v2/stylesheets/grid.less
index e2b0b72..7c55dee 100644
--- a/superset/assets/javascripts/dashboard/v2/stylesheets/grid.less
+++ b/superset/assets/javascripts/dashboard/v2/stylesheets/grid.less
@@ -27,7 +27,7 @@
 .grid-row-guide {
   position: absolute;
   left: 0;
-  bottom: 1;
+  bottom: 2;
   height: 2;
   background-color: @indicator-color;
   pointer-events: none;
diff --git a/superset/assets/javascripts/dashboard/v2/util/getChildWidth.js b/superset/assets/javascripts/dashboard/v2/util/getChildWidth.js
index 630f72d..516624d 100644
--- a/superset/assets/javascripts/dashboard/v2/util/getChildWidth.js
+++ b/superset/assets/javascripts/dashboard/v2/util/getChildWidth.js
@@ -6,9 +6,9 @@ export default function getTotalChildWidth({ id, components, recurse = false })
 
   (component.children || []).forEach((childId) => {
     const child = components[childId];
-    width = Math.max(width, child.meta.width);
+    width += child.meta.width || 0;
     if (recurse) {
-      width = Math.max(width, getTotalChildWidth(child, components));
+      width += getTotalChildWidth({ id: childId, components, recurse }) || 0;
     }
   });
 
diff --git a/superset/assets/javascripts/dashboard/v2/util/newEntitiesFromDrop.js b/superset/assets/javascripts/dashboard/v2/util/newEntitiesFromDrop.js
index 881ab45..9e49643 100644
--- a/superset/assets/javascripts/dashboard/v2/util/newEntitiesFromDrop.js
+++ b/superset/assets/javascripts/dashboard/v2/util/newEntitiesFromDrop.js
@@ -12,12 +12,6 @@ export default function newEntitiesFromDrop({ dropResult, components }) {
 
   const dragType = dragging.type;
   const dropEntity = components[destination.id];
-
-  if (!dropEntity) {
-    console.warn('Drop target entity', destination.id, 'not found');
-    return null;
-  }
-
   const dropType = dropEntity.type;
   let newDropChild = newComponentFactory(dragType);
   const wrapChildInRow = shouldWrapChildInRow({ parentType: dropType, childType: dragType });

-- 
To stop receiving notification emails like this one, please contact
ccwilliams@apache.org.