From 2ace73e9a1f1cf1a20eff632d08ea440f5f88607 Mon Sep 17 00:00:00 2001 From: Alanna Scott Date: Thu, 9 Feb 2017 12:11:25 -0800 Subject: [PATCH] [sql-lab] make datasource name in visualize flow more descriptive (#2103) * make data source name more descriptive * add user name to datasource name as well --- .../SqlLab/components/VisualizeModal.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx b/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx index 0536068ee19e2..e612c9f97e97e 100644 --- a/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx +++ b/superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx @@ -27,10 +27,9 @@ const defaultProps = { class VisualizeModal extends React.PureComponent { constructor(props) { super(props); - const uniqueId = shortid.generate(); this.state = { chartType: CHART_TYPES[0], - datasourceName: uniqueId, + datasourceName: this.datasourceName(), columns: {}, hints: [], }; @@ -54,6 +53,17 @@ class VisualizeModal extends React.PureComponent { }); this.setState({ columns }); } + datasourceName() { + const { query } = this.props; + const uniqueId = shortid.generate(); + let datasourceName = uniqueId; + if (query) { + datasourceName = query.user ? `${query.user}-` : ''; + datasourceName += query.db ? `${query.db}-` : ''; + datasourceName += `${query.tab}-${uniqueId}`; + } + return datasourceName; + } validate() { const hints = []; const cols = this.mergedColumns();