Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cb 4548 sql editor resultsets can be closed one by one only when execute sql statement has been used for several queries #2503

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SqlEditorGroupTabsBootstrap extends Bootstrap {
return items;
},
});

this.actionService.addHandler({
id: 'result-tabs-group-base-handler',
isActionApplicable: (context, action) => {
Expand All @@ -50,11 +51,13 @@ export class SqlEditorGroupTabsBootstrap extends Bootstrap {
return [ACTION_TAB_CLOSE_SQL_RESULT_GROUP].includes(action);
},
handler: async (context, action) => {
const state = context.get(DATA_CONTEXT_SQL_EDITOR_STATE);
const tab = context.get(DATA_CONTEXT_SQL_EDITOR_RESULT_ID);
const sqlEditorState = context.get(DATA_CONTEXT_SQL_EDITOR_STATE);
const tabs = context.get(DATA_CONTEXT_TABS_CONTEXT);

switch (action) {
case ACTION_TAB_CLOSE_SQL_RESULT_GROUP:
this.sqlResultTabsService.closeTabGroup(state, tab.id);
this.sqlResultTabsService.closeTabGroup(sqlEditorState, tabs, context, tab.id);
Wroud marked this conversation as resolved.
Show resolved Hide resolved
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/
import { action, makeObservable } from 'mobx';

import type { IDataContextProvider } from '@cloudbeaver/core-data-context';
import { injectable } from '@cloudbeaver/core-di';
import type { ITabsContext } from '@cloudbeaver/core-ui';

import type { ISqlEditorResultTab, ISqlEditorTabState } from '../ISqlEditorTabState';
import { SqlExecutionPlanService } from './ExecutionPlan/SqlExecutionPlanService';
Expand Down Expand Up @@ -75,16 +77,16 @@ export class SqlResultTabsService {
}
}

async closeTabGroup(state: ISqlEditorTabState, tabId: string) {
async closeTabGroup(state: ISqlEditorTabState, tabsContext: ITabsContext, context: IDataContextProvider, tabId: string) {
const resultTab = state.resultTabs.find(tabState => tabState.tabId === tabId);
const groupResultTabs = state.resultTabs.filter(tab => tab.groupId === resultTab?.groupId);

if (groupResultTabs.length) {
for (const groupTab of groupResultTabs) {
const canClose = await this.sqlQueryResultService.canCloseResultTab(state, groupTab.tabId);
const canClose = tabsContext.canClose(groupTab.tabId);

if (canClose) {
this.removeResultTab(state, groupTab.tabId);
tabsContext.close(groupTab.tabId);
Wroud marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading