You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2019/06/14 20:39:57 UTC

[incubator-superset] branch master updated: [dashboard] fix nested tab component visible logic (#7700)

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 925b8db  [dashboard] fix nested tab component visible logic (#7700)
925b8db is described below

commit 925b8dbb90552aa1a66c2f0bcdcf7d1252ab925f
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Fri Jun 14 13:39:48 2019 -0700

    [dashboard] fix nested tab component visible logic (#7700)
---
 .../assets/cypress/integration/dashboard/tabs.js   | 33 +++++++++++---
 .../dashboard/components/gridComponents/Tabs.jsx   |  5 +-
 superset/data/tabbed_dashboard.py                  | 53 ++++++++++++++++++----
 3 files changed, 74 insertions(+), 17 deletions(-)

diff --git a/superset/assets/cypress/integration/dashboard/tabs.js b/superset/assets/cypress/integration/dashboard/tabs.js
index 5029a00..273d2ec 100644
--- a/superset/assets/cypress/integration/dashboard/tabs.js
+++ b/superset/assets/cypress/integration/dashboard/tabs.js
@@ -107,9 +107,6 @@ export default () => describe('tabs', () => {
     cy.wait('@filterRequest');
     cy.wait('@treemapRequest');
 
-    // creating route and stubbing filtered route
-    cy.route('POST', '/superset/explore_json/*').as('updatedChartRequest');
-
     // apply filter
     cy.get('.Select-control')
       .first()
@@ -118,7 +115,7 @@ export default () => describe('tabs', () => {
       .type('South Asia{enter}', { force: true });
 
     // send new query from same tab
-    cy.wait('@updatedChartRequest')
+    cy.wait('@treemapRequest')
       .then((xhr) => {
         const requestFormData = xhr.request.body;
         const requestParams = JSON.parse(requestFormData.get('form_data'));
@@ -130,7 +127,7 @@ export default () => describe('tabs', () => {
     cy.get('.tab-content ul.nav.nav-tabs li')
       .last()
       .click();
-    cy.wait('@updatedChartRequest')
+    cy.wait('@linechartRequest')
       .then((xhr) => {
         const requestFormData = xhr.request.body;
         const requestParams = JSON.parse(requestFormData.get('form_data'));
@@ -146,12 +143,36 @@ export default () => describe('tabs', () => {
       .last()
       .find('.editable-title input')
       .click();
-    cy.wait('@updatedChartRequest')
+    cy.wait('@boxplotRequest')
       .then((xhr) => {
         const requestFormData = xhr.request.body;
         const requestParams = JSON.parse(requestFormData.get('form_data'));
         expect(requestParams.extra_filters[0])
           .deep.eq({ col: 'region', op: 'in', val: ['South Asia'] });
       });
+
+    // navigate to filter and clear filter
+    cy.get('.dashboard-component-tabs')
+      .first()
+      .find('ul.nav.nav-tabs li')
+      .first()
+      .click();
+    cy.get('.tab-content ul.nav.nav-tabs li')
+      .first()
+      .click();
+    cy.get('span.Select-clear')
+      .click();
+
+    // trigger 1 new query
+    cy.wait('@treemapRequest');
+
+    // no other requests occurred
+    cy.on('fail', (err) => {
+      expect(err.message).to.include('Timed out retrying');
+      return false;
+    });
+    cy.wait('@boxplotRequest', { timeout: 1000 }).then(() => {
+      throw new Error('Unexpected API call.');
+    });
   });
 });
diff --git a/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx b/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
index dfa0cae..d00df3a 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
@@ -168,6 +168,7 @@ class Tabs extends React.PureComponent {
       handleComponentDrop,
       renderTabContent,
       renderHoverMenu,
+      isComponentVisible: isCurrentTabVisible,
       editMode,
     } = this.props;
 
@@ -238,7 +239,9 @@ class Tabs extends React.PureComponent {
                       onResize={onResize}
                       onResizeStop={onResizeStop}
                       onDropOnTab={this.handleDropOnTab}
-                      isComponentVisible={selectedTabIndex === tabIndex}
+                      isComponentVisible={
+                        selectedTabIndex === tabIndex && isCurrentTabVisible
+                      }
                     />
                   )}
                 </BootstrapTab>
diff --git a/superset/data/tabbed_dashboard.py b/superset/data/tabbed_dashboard.py
index 4c81f85..95b2805 100644
--- a/superset/data/tabbed_dashboard.py
+++ b/superset/data/tabbed_dashboard.py
@@ -90,7 +90,9 @@ def load_tabbed_dashboard():
           "ROOT_ID",
           "TABS-lV0r00f4H1",
           "TAB-gcQJxApOZS",
-          "ROW-3PphCz4GD"
+          "TABS-afnrUvdxYF",
+          "TAB-jNNd4WWar1",
+          "ROW-7ygtDczaQ"
         ],
         "type": "CHART"
       },
@@ -152,33 +154,35 @@ def load_tabbed_dashboard():
         "id": "ROOT_ID",
         "type": "ROOT"
       },
-      "ROW-3PphCz4GD": {
+      "ROW-7G2o5uDvfo": {
         "children": [
-          "CHART-dxV7Il74hH"
+          "CHART-c0EjR-OZ0n"
         ],
-        "id": "ROW-3PphCz4GD",
+        "id": "ROW-7G2o5uDvfo",
         "meta": {
           "background": "BACKGROUND_TRANSPARENT"
         },
         "parents": [
           "ROOT_ID",
           "TABS-lV0r00f4H1",
-          "TAB-gcQJxApOZS"
+          "TAB-NF3dlrWGS"
         ],
         "type": "ROW"
       },
-      "ROW-7G2o5uDvfo": {
+      "ROW-7ygtDczaQ": {
         "children": [
-          "CHART-c0EjR-OZ0n"
+          "CHART-dxV7Il74hH"
         ],
-        "id": "ROW-7G2o5uDvfo",
+        "id": "ROW-7ygtDczaQ",
         "meta": {
           "background": "BACKGROUND_TRANSPARENT"
         },
         "parents": [
           "ROOT_ID",
           "TABS-lV0r00f4H1",
-          "TAB-NF3dlrWGS"
+          "TAB-gcQJxApOZS",
+          "TABS-afnrUvdxYF",
+          "TAB-jNNd4WWar1"
         ],
         "type": "ROW"
       },
@@ -249,7 +253,7 @@ def load_tabbed_dashboard():
       },
       "TAB-gcQJxApOZS": {
         "children": [
-          "ROW-3PphCz4GD"
+          "TABS-afnrUvdxYF"
         ],
         "id": "TAB-gcQJxApOZS",
         "meta": {
@@ -261,6 +265,22 @@ def load_tabbed_dashboard():
         ],
         "type": "TAB"
       },
+      "TAB-jNNd4WWar1": {
+        "children": [
+          "ROW-7ygtDczaQ"
+        ],
+        "id": "TAB-jNNd4WWar1",
+        "meta": {
+          "text": "New Tab"
+        },
+        "parents": [
+          "ROOT_ID",
+          "TABS-lV0r00f4H1",
+          "TAB-gcQJxApOZS",
+          "TABS-afnrUvdxYF"
+        ],
+        "type": "TAB"
+      },
       "TAB-z81Q87PD7": {
         "children": [
           "ROW-G73z9PIHn"
@@ -291,6 +311,19 @@ def load_tabbed_dashboard():
         ],
         "type": "TABS"
       },
+      "TABS-afnrUvdxYF": {
+        "children": [
+          "TAB-jNNd4WWar1"
+        ],
+        "id": "TABS-afnrUvdxYF",
+        "meta": {},
+        "parents": [
+          "ROOT_ID",
+          "TABS-lV0r00f4H1",
+          "TAB-gcQJxApOZS"
+        ],
+        "type": "TABS"
+      },
       "TABS-lV0r00f4H1": {
         "children": [
           "TAB-NF3dlrWGS",