mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Fix Run Query for widgets (#8960)
* format doc * use new line instead of eol * review comments * return false
This commit is contained in:
@@ -5,11 +5,12 @@
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
import { RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { InsightActionContext } from 'sql/workbench/browser/actions';
|
||||
import { openNewQuery } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { isString } from 'vs/base/common/types';
|
||||
|
||||
export class RunInsightQueryAction extends Action {
|
||||
public static ID = 'runQuery';
|
||||
@@ -17,12 +18,25 @@ export class RunInsightQueryAction extends Action {
|
||||
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ITextResourcePropertiesService private _textResourcePropertiesService: ITextResourcePropertiesService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(context: InsightActionContext): Promise<boolean> {
|
||||
return this.instantiationService.invokeFunction(openNewQuery, context.profile, undefined, RunQueryOnConnectionMode.executeQuery).then(() => true, () => false);
|
||||
let queryString: string = undefined;
|
||||
let eol: string = this._textResourcePropertiesService.getEOL(undefined);
|
||||
if (context.insight && context.insight.query) {
|
||||
if (isString(context.insight.query)) {
|
||||
queryString = context.insight.query;
|
||||
} else {
|
||||
queryString = context.insight.query.join(eol);
|
||||
}
|
||||
} else {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
return this.instantiationService.invokeFunction(openNewQuery, context.profile, queryString,
|
||||
RunQueryOnConnectionMode.executeQuery).then(() => true, () => false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user