Skip to content

Commit

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

* make data source name more descriptive

* add user name to datasource name as well
  • Loading branch information
Alanna Scott authored Feb 9, 2017
1 parent 80cfb08 commit 2ace73e
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 2ace73e

Please sign in to comment.