Merge pull request #828 from dbeaver/feat/rm

fix(plugin-resource-manager): CB-2019 1925 remove associated script f…
This commit is contained in:
alex
2022-05-13 14:33:12 +02:00
committed by GitHub
10 changed files with 164 additions and 44 deletions
@@ -50,7 +50,6 @@ export interface ISqlEditorTabState {
query: string;
executionContext?: IConnectionExecutionContextInfo;
currentTabId?: string;
associatedScriptId?: string;
tabs: ISqlEditorResultTab[];
resultGroups: IResultGroup[];
resultTabs: IResultTab[];
@@ -66,7 +66,7 @@ export function useSqlEditor(state: ISqlEditorTabState): ISQLEditorData {
},
get activeSegmentMode(): ISQLEditorMode {
const contexts = this.onMode.execute(this);
const contexts = this.onMode.execute(this);
const mode = contexts.getContext(SQLEditorModeContext);
return mode;
@@ -300,7 +300,7 @@ export function useSqlEditor(state: ISqlEditorTabState): ISQLEditorData {
},
setQuery(query: string): void {
this.state.query = query;
this.sqlEditorService.setQuery(query, this.state);
this.parser.setScript(query);
this.onUpdate.execute();
},
@@ -9,13 +9,22 @@
import { ConnectionExecutionContextResource, ConnectionExecutionContextService, ConnectionsManagerService, IConnectionExecutionContext, IConnectionExecutionContextInfo } from '@cloudbeaver/core-connections';
import { injectable } from '@cloudbeaver/core-di';
import { NotificationService } from '@cloudbeaver/core-events';
import { Executor } from '@cloudbeaver/core-executor';
import { GraphQLService, SqlCompletionProposal, SqlScriptInfoFragment } from '@cloudbeaver/core-sdk';
import type { ISqlEditorTabState } from '@cloudbeaver/plugin-sql-editor';
export type SQLProposal = SqlCompletionProposal;
export interface IQueryChangeData {
prevQuery: string;
query: string;
state: ISqlEditorTabState;
}
@injectable()
export class SqlEditorService {
readonly onQueryChange: Executor<IQueryChangeData>;
constructor(
private readonly gql: GraphQLService,
private readonly connectionsManagerService: ConnectionsManagerService,
@@ -23,6 +32,7 @@ export class SqlEditorService {
private readonly connectionExecutionContextService: ConnectionExecutionContextService,
private readonly connectionExecutionContextResource: ConnectionExecutionContextResource
) {
this.onQueryChange = new Executor();
}
getState(
@@ -31,7 +41,6 @@ export class SqlEditorService {
source?: string,
query?: string,
contextInfo?: IConnectionExecutionContextInfo,
associatedScriptId?: string,
): ISqlEditorTabState {
return {
name,
@@ -46,7 +55,6 @@ export class SqlEditorService {
statisticsTabs: [],
currentModeId: '',
associatedScriptId: associatedScriptId ?? '',
modeState: [],
};
}
@@ -97,16 +105,15 @@ export class SqlEditorService {
return proposals as SQLProposal[];
}
setAssociatedScriptId(scriptId: string, state: ISqlEditorTabState) {
state.associatedScriptId = scriptId;
}
setName(name: string, state: ISqlEditorTabState) {
state.name = name;
}
setQuery(query: string, state: ISqlEditorTabState) {
const prevQuery = state.query;
state.query = query;
this.onQueryChange.execute({ prevQuery, query, state });
}
async resetExecutionContext(state: ISqlEditorTabState) {