From aaa58a79f61dec42d963f1a105b0790589792066 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 30 May 2019 15:14:03 -0700 Subject: [PATCH 1/5] Show expanded columns in gray --- .../assets/src/SqlLab/components/ResultSet.jsx | 1 + .../FilterableTable/FilterableTable.jsx | 12 +++++++++++- .../FilterableTable/FilterableTableStyles.css | 5 ++++- superset/views/core.py | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx b/superset/assets/src/SqlLab/components/ResultSet.jsx index 443eb16b29998..785ed9074e309 100644 --- a/superset/assets/src/SqlLab/components/ResultSet.jsx +++ b/superset/assets/src/SqlLab/components/ResultSet.jsx @@ -216,6 +216,7 @@ export default class ResultSet extends React.PureComponent { orderedColumnKeys={results.columns.map(col => col.name)} height={height} filterText={this.state.searchText} + expandedColumns={results.expanded_columns.map(col => col.name)} /> ); diff --git a/superset/assets/src/components/FilterableTable/FilterableTable.jsx b/superset/assets/src/components/FilterableTable/FilterableTable.jsx index 702f2b96493f8..e4f21a514d5e6 100644 --- a/superset/assets/src/components/FilterableTable/FilterableTable.jsx +++ b/superset/assets/src/components/FilterableTable/FilterableTable.jsx @@ -44,6 +44,7 @@ const propTypes = { overscanRowCount: PropTypes.number, rowHeight: PropTypes.number, striped: PropTypes.bool, + expandedColumns: PropTypes.array, }; const defaultProps = { @@ -52,6 +53,7 @@ const defaultProps = { overscanRowCount: 10, rowHeight: 32, striped: true, + expandedColumns: [], }; export default class FilterableTable extends PureComponent { @@ -141,7 +143,15 @@ export default class FilterableTable extends PureComponent { return (
- {label} + -1 + ? 'header-style-disabled' + : '' + } + > + {label} + {sortBy === dataKey && } diff --git a/superset/assets/src/components/FilterableTable/FilterableTableStyles.css b/superset/assets/src/components/FilterableTable/FilterableTableStyles.css index 7a0d3ba0ea7d3..f24df737e9bc2 100644 --- a/superset/assets/src/components/FilterableTable/FilterableTableStyles.css +++ b/superset/assets/src/components/FilterableTable/FilterableTableStyles.css @@ -76,4 +76,7 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; -} \ No newline at end of file +} +.header-style-disabled { + color: #aaa; +} diff --git a/superset/views/core.py b/superset/views/core.py index d8a3692c24404..e65692f7a10e3 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -21,6 +21,7 @@ import logging import os import re +import string import traceback from typing import Dict, List # noqa: F401 from urllib import parse @@ -2502,6 +2503,22 @@ def results(self, key): if display_limit: payload_json = json.loads(payload) payload_json['data'] = payload_json['data'][:display_limit] + + # mock new payload + payload_json['selected_columns'] = payload_json['columns'] + payload_json['expanded_columns'] = [] + for col in payload_json['columns']: + for i in range(2): + # 0: {name: "event_id", agg: "count_distinct", type: "VARCHAR", is_date: false, is_dim: false} + letter = string.ascii_lowercase[i] + expanded_col = col.copy() + expanded_col['name'] = f'{col["name"]}.{letter}' + payload_json['expanded_columns'].append(expanded_col) + for j in range(len(payload_json['data'])): + payload_json['data'][j][expanded_col['name']] = i + j * 10 + payload_json['columns'] = \ + payload_json['selected_columns'] + payload_json['expanded_columns'] + return json_success( json.dumps( payload_json, From 9642038706ae7e69aa8c3f025d786dd002670bf1 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 30 May 2019 15:14:26 -0700 Subject: [PATCH 2/5] Remove payload mocking --- superset/views/core.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/superset/views/core.py b/superset/views/core.py index e65692f7a10e3..c077cecf77da6 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -21,7 +21,6 @@ import logging import os import re -import string import traceback from typing import Dict, List # noqa: F401 from urllib import parse @@ -2504,21 +2503,6 @@ def results(self, key): payload_json = json.loads(payload) payload_json['data'] = payload_json['data'][:display_limit] - # mock new payload - payload_json['selected_columns'] = payload_json['columns'] - payload_json['expanded_columns'] = [] - for col in payload_json['columns']: - for i in range(2): - # 0: {name: "event_id", agg: "count_distinct", type: "VARCHAR", is_date: false, is_dim: false} - letter = string.ascii_lowercase[i] - expanded_col = col.copy() - expanded_col['name'] = f'{col["name"]}.{letter}' - payload_json['expanded_columns'].append(expanded_col) - for j in range(len(payload_json['data'])): - payload_json['data'][j][expanded_col['name']] = i + j * 10 - payload_json['columns'] = \ - payload_json['selected_columns'] + payload_json['expanded_columns'] - return json_success( json.dumps( payload_json, From 0ae474661646c6de3f44ee45a7dff9578b6109ec Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 30 May 2019 15:15:41 -0700 Subject: [PATCH 3/5] Remove empty line --- superset/views/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/superset/views/core.py b/superset/views/core.py index c077cecf77da6..d8a3692c24404 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -2502,7 +2502,6 @@ def results(self, key): if display_limit: payload_json = json.loads(payload) payload_json['data'] = payload_json['data'][:display_limit] - return json_success( json.dumps( payload_json, From bb70893fac5f5f327013b763081910986895ee32 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 30 May 2019 15:17:47 -0700 Subject: [PATCH 4/5] Safety fallback if expanded_columns is not in the payload --- superset/assets/src/SqlLab/components/ResultSet.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx b/superset/assets/src/SqlLab/components/ResultSet.jsx index 785ed9074e309..28ce436295c61 100644 --- a/superset/assets/src/SqlLab/components/ResultSet.jsx +++ b/superset/assets/src/SqlLab/components/ResultSet.jsx @@ -207,6 +207,9 @@ export default class ResultSet extends React.PureComponent { data = results.data; } if (data && data.length > 0) { + const expandendColumns = results.expanded_columns + ? results.expanded_columns.map(col => col.name) + : []; return ( {this.renderControls.bind(this)()} @@ -216,7 +219,7 @@ export default class ResultSet extends React.PureComponent { orderedColumnKeys={results.columns.map(col => col.name)} height={height} filterText={this.state.searchText} - expandedColumns={results.expanded_columns.map(col => col.name)} + expandedColumns={expandendColumns} /> ); From c439fad1bae50d0c0a9e200a96634ec1853c7eba Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 30 May 2019 16:42:30 -0700 Subject: [PATCH 5/5] Fix typo --- superset/assets/src/SqlLab/components/ResultSet.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx b/superset/assets/src/SqlLab/components/ResultSet.jsx index 28ce436295c61..7ac04b3292c51 100644 --- a/superset/assets/src/SqlLab/components/ResultSet.jsx +++ b/superset/assets/src/SqlLab/components/ResultSet.jsx @@ -207,7 +207,7 @@ export default class ResultSet extends React.PureComponent { data = results.data; } if (data && data.length > 0) { - const expandendColumns = results.expanded_columns + const expandedColumns = results.expanded_columns ? results.expanded_columns.map(col => col.name) : []; return ( @@ -219,7 +219,7 @@ export default class ResultSet extends React.PureComponent { orderedColumnKeys={results.columns.map(col => col.name)} height={height} filterText={this.state.searchText} - expandedColumns={expandendColumns} + expandedColumns={expandedColumns} /> );