Skip to content

Commit

Permalink
[dashboard] fix nested tab component visible logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo committed Jun 13, 2019
1 parent 0d12243 commit 072ba2c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 17 deletions.
33 changes: 27 additions & 6 deletions superset/assets/cypress/integration/dashboard/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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.');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Tabs extends React.PureComponent {
handleComponentDrop,
renderTabContent,
renderHoverMenu,
isComponentVisible: isCurrentTabVisible,
editMode,
} = this.props;

Expand Down Expand Up @@ -238,7 +239,9 @@ class Tabs extends React.PureComponent {
onResize={onResize}
onResizeStop={onResizeStop}
onDropOnTab={this.handleDropOnTab}
isComponentVisible={selectedTabIndex === tabIndex}
isComponentVisible={
selectedTabIndex === tabIndex && isCurrentTabVisible
}
/>
)}
</BootstrapTab>
Expand Down
53 changes: 43 additions & 10 deletions superset/data/tabbed_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def load_tabbed_dashboard():
"ROOT_ID",
"TABS-lV0r00f4H1",
"TAB-gcQJxApOZS",
"ROW-3PphCz4GD"
"TABS-afnrUvdxYF",
"TAB-jNNd4WWar1",
"ROW-7ygtDczaQ"
],
"type": "CHART"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -249,7 +253,7 @@ def load_tabbed_dashboard():
},
"TAB-gcQJxApOZS": {
"children": [
"ROW-3PphCz4GD"
"TABS-afnrUvdxYF"
],
"id": "TAB-gcQJxApOZS",
"meta": {
Expand All @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 072ba2c

Please sign in to comment.