This is an automated email from the ASF dual-hosted git repository. villebro pushed a commit to branch 0.37 in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 3aadbc4fde924c1c3bf14498dc1ac8adbf897daf Author: Jesse Yang <[email protected]> AuthorDate: Fri Aug 7 14:15:03 2020 -0700 fix: table viz query mode switch not working (#10552) --- .../cypress/integration/explore/visualizations/table.test.ts | 10 ++++++++++ superset-frontend/src/explore/controlUtils.js | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/superset-frontend/cypress-base/cypress/integration/explore/visualizations/table.test.ts b/superset-frontend/cypress-base/cypress/integration/explore/visualizations/table.test.ts index 8fa3041..c7015d9 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/visualizations/table.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/explore/visualizations/table.test.ts @@ -167,8 +167,18 @@ describe('Visualization > Table', () => { }; cy.visitChartByParams(JSON.stringify(formData)); + // should display in raw records mode cy.get('div[data-test="query_mode"] .btn.active').contains('Raw Records'); + cy.get('div[data-test="all_columns"]').should('be.visible'); + cy.get('div[data-test="groupby"]').should('not.be.visible'); + cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' }); + + // should allow switch to aggregate mode + cy.get('div[data-test="query_mode"] .btn').contains('Aggregate').click(); + cy.get('div[data-test="query_mode"] .btn.active').contains('Aggregate'); + cy.get('div[data-test="all_columns"]').should('not.be.visible'); + cy.get('div[data-test="groupby"]').should('be.visible'); }); it('Test table with columns, ordering, and row limit', () => { diff --git a/superset-frontend/src/explore/controlUtils.js b/superset-frontend/src/explore/controlUtils.js index 122214e..b9ed101 100644 --- a/superset-frontend/src/explore/controlUtils.js +++ b/superset-frontend/src/explore/controlUtils.js @@ -112,11 +112,14 @@ function handleMissingChoice(control) { export function applyMapStateToPropsToControl(controlState, controlPanelState) { const { mapStateToProps } = controlState; let state = { ...controlState }; + let { value } = state; // value is current user-input value if (mapStateToProps && controlPanelState) { state = { ...controlState, ...mapStateToProps(controlPanelState, controlState), }; + // `mapStateToProps` may also provide a value + value = value || state.value; } // If default is a function, evaluate it if (typeof state.default === 'function') { @@ -126,7 +129,6 @@ export function applyMapStateToPropsToControl(controlState, controlPanelState) { delete state.default; } } - let { value } = state; // If no current value, set it as default if (state.default && value === undefined) { value = state.default;
