Skip to content

Commit

Permalink
[sql-lab] make datasource name in visualize flow more descriptive (ap…
Browse files Browse the repository at this point in the history
…ache#2103)

* make data source name more descriptive

* add user name to datasource name as well
  • Loading branch information
Alanna Scott authored and Saleh Hindi committed Jun 9, 2017
1 parent 98fa739 commit 7360e58
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions superset/assets/javascripts/SqlLab/components/VisualizeModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
};
Expand All @@ -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();
Expand Down

0 comments on commit 7360e58

Please sign in to comment.