mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Fix more floating promises (#8460)
This commit is contained in:
@@ -20,8 +20,7 @@ export class CopyInsightDialogSelectionAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(event?: IInsightDialogActionContext): Promise<any> {
|
||||
this._clipboardService.writeText(event.cellData);
|
||||
return Promise.resolve(void 0);
|
||||
public async run(event?: IInsightDialogActionContext): Promise<void> {
|
||||
await this._clipboardService.writeText(event.cellData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ export const IInsightsDialogService = createDecorator<IInsightsDialogService>('i
|
||||
|
||||
export interface IInsightsDialogService {
|
||||
_serviceBrand: undefined;
|
||||
show(input: IInsightsConfig, connectionProfile: IConnectionProfile): void;
|
||||
close();
|
||||
show(input: IInsightsConfig, connectionProfile: IConnectionProfile): Promise<void>;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface IInsightDialogActionContext extends BaseActionContext {
|
||||
|
||||
@@ -20,7 +20,7 @@ export class InsightsDialogService implements IInsightsDialogService {
|
||||
constructor(@IInstantiationService private _instantiationService: IInstantiationService) { }
|
||||
|
||||
// query string
|
||||
public show(input: IInsightsConfig, connectionProfile: IConnectionProfile): void {
|
||||
public async show(input: IInsightsConfig, connectionProfile: IConnectionProfile): Promise<void> {
|
||||
if (!this._insightsDialogView) {
|
||||
this._insightsDialogModel = new InsightsDialogModel();
|
||||
this._insightsDialogController = this._instantiationService.createInstance(InsightsDialogController, this._insightsDialogModel);
|
||||
@@ -32,7 +32,7 @@ export class InsightsDialogService implements IInsightsDialogService {
|
||||
}
|
||||
|
||||
this._insightsDialogModel.insight = input.details;
|
||||
this._insightsDialogController.update(input.details, connectionProfile);
|
||||
await this._insightsDialogController.update(input.details, connectionProfile);
|
||||
this._insightsDialogView.open(input.details, connectionProfile);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import { IInsightsConfigDetails } from 'sql/platform/dashboard/browser/insightRe
|
||||
import { TaskRegistry } from 'sql/platform/tasks/browser/tasksRegistry';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
const labelDisplay = nls.localize("insights.item", "Item");
|
||||
const valueDisplay = nls.localize("insights.value", "Value");
|
||||
@@ -353,7 +354,7 @@ export class InsightsDialogView extends Modal {
|
||||
return;
|
||||
}
|
||||
let context = this.topInsightContext(resource);
|
||||
this._commandService.executeCommand(action, context);
|
||||
this._commandService.executeCommand(action, context).catch(err => onUnexpectedError(err));
|
||||
}, 'left');
|
||||
button.enabled = false;
|
||||
this._taskButtonDisposables.push(button);
|
||||
|
||||
@@ -29,7 +29,7 @@ const testColumns: string[] = [
|
||||
];
|
||||
|
||||
suite('Insights Dialog Controller Tests', () => {
|
||||
test('updates correctly with good input', done => {
|
||||
test('updates correctly with good input', async (done) => {
|
||||
|
||||
let model = new InsightsDialogModel();
|
||||
|
||||
@@ -71,20 +71,19 @@ suite('Insights Dialog Controller Tests', () => {
|
||||
options: {}
|
||||
};
|
||||
|
||||
controller.update(<IInsightsConfigDetails>{ query: 'query' }, profile).then(() => {
|
||||
// Once we update the controller, listen on when it changes the model and verify the data it
|
||||
// puts in is correct
|
||||
model.onDataChange(() => {
|
||||
for (let i = 0; i < testData.length; i++) {
|
||||
for (let j = 0; j < testData[i].length; j++) {
|
||||
equal(testData[i][j], model.rows[i][j]);
|
||||
}
|
||||
await controller.update(<IInsightsConfigDetails>{ query: 'query' }, profile);
|
||||
// Once we update the controller, listen on when it changes the model and verify the data it
|
||||
// puts in is correct
|
||||
model.onDataChange(() => {
|
||||
for (let i = 0; i < testData.length; i++) {
|
||||
for (let j = 0; j < testData[i].length; j++) {
|
||||
equal(testData[i][j], model.rows[i][j]);
|
||||
}
|
||||
done();
|
||||
});
|
||||
// Fake the query Runner telling the controller the query is complete
|
||||
complete();
|
||||
}
|
||||
done();
|
||||
});
|
||||
// Fake the query Runner telling the controller the query is complete
|
||||
complete();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user