diff --git a/superset/assets/spec/javascripts/sqllab/TabbedSqlEditors_spec.jsx b/superset/assets/spec/javascripts/sqllab/TabbedSqlEditors_spec.jsx index b3232df6bd1..20fb5deb7c2 100644 --- a/superset/assets/spec/javascripts/sqllab/TabbedSqlEditors_spec.jsx +++ b/superset/assets/spec/javascripts/sqllab/TabbedSqlEditors_spec.jsx @@ -162,6 +162,14 @@ describe('TabbedSqlEditors', () => { expect(wrapper.instance().props.actions.addQueryEditor.getCall(0).args[0].title) .toContain('Untitled Query'); }); + it('should duplicate query editor', () => { + wrapper = getWrapper(); + sinon.stub(wrapper.instance().props.actions, 'cloneQueryToNewTab'); + + wrapper.instance().duplicateQueryEditor(queryEditors[0]); + expect(wrapper.instance().props.actions.cloneQueryToNewTab.getCall(0).args[0]) + .toBe(queryEditors[0]); + }); it('should handle select', () => { wrapper = getWrapper(); sinon.spy(wrapper.instance(), 'newQueryEditor'); diff --git a/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx b/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx index 7b7f1773d43..3e37123b363 100644 --- a/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx +++ b/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx @@ -67,6 +67,7 @@ class TabbedSqlEditors extends React.PureComponent { this.renameTab = this.renameTab.bind(this); this.toggleLeftBar = this.toggleLeftBar.bind(this); this.removeAllOtherQueryEditors = this.removeAllOtherQueryEditors.bind(this); + this.duplicateQueryEditor = this.duplicateQueryEditor.bind(this); } componentDidMount() { const query = URI(window.location).search(true); @@ -182,6 +183,9 @@ class TabbedSqlEditors extends React.PureComponent { this.props.queryEditors .forEach(qe => qe !== cqe && this.removeQueryEditor(qe)); } + duplicateQueryEditor(qe) { + this.props.actions.cloneQueryToNewTab(qe); + } toggleLeftBar() { this.setState({ hideLeftBar: !this.state.hideLeftBar }); } @@ -236,6 +240,12 @@ class TabbedSqlEditors extends React.PureComponent { {t('Close all other tabs')} + this.duplicateQueryEditor(qe)}> +
+ +
+ {t('Duplicate tab')} +
); return (