From b143b16dff6e92e32e0f10f4e1b9d114af210a31 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Sat, 12 Jan 2019 08:35:53 +0800 Subject: [PATCH] #6588 Clear all other query tabs (#6617) * #6588 Clear all other query tabs * Improve SQLEditor methods bind * Update loop syntax --- .../SqlLab/components/TabbedSqlEditors.jsx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx b/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx index da0d9d127..73c744822 100644 --- a/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx +++ b/superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx @@ -41,6 +41,10 @@ class TabbedSqlEditors extends React.PureComponent { dataPreviewQueries: [], hideLeftBar: false, }; + this.removeQueryEditor = this.removeQueryEditor.bind(this); + this.renameTab = this.renameTab.bind(this); + this.toggleLeftBar = this.toggleLeftBar.bind(this); + this.removeAllOtherQueryEditors = this.removeAllOtherQueryEditors.bind(this); } componentDidMount() { const query = URI(window.location).search(true); @@ -152,6 +156,10 @@ class TabbedSqlEditors extends React.PureComponent { removeQueryEditor(qe) { this.props.actions.removeQueryEditor(qe); } + removeAllOtherQueryEditors(cqe) { + this.props.queryEditors + .forEach(qe => qe !== cqe && this.removeQueryEditor(qe)); + } toggleLeftBar() { this.setState({ hideLeftBar: !this.state.hideLeftBar }); } @@ -171,7 +179,7 @@ class TabbedSqlEditors extends React.PureComponent { const tabTitle = (
- {' '} + this.removeQueryEditor(qe)} tabState={state} />{' '} {qe.title}{' '} - + this.removeQueryEditor(qe)}>
{t('Close tab')}
- + this.renameTab(qe)}>
{t('Rename tab')}
- +
{this.state.hideLeftBar ? t('Expand tool bar') : t('Hide tool bar')}
+ this.removeAllOtherQueryEditors(qe)}> +
+ +
+ {t('Close all other tabs')} +
);