mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
dispose view after the operation is done (#22144)
This commit is contained in:
@@ -84,7 +84,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
|
||||
}
|
||||
}
|
||||
|
||||
protected async onDispose(): Promise<void> {
|
||||
protected async disposeView(): Promise<void> {
|
||||
await this.objectManagementService.disposeLoginView(this.contextId);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
const dialogTitle = isNewObject ? NewObjectDialogTitle(objectTypeDisplayName) : ObjectPropertiesDialogTitle(objectTypeDisplayName, objectName);
|
||||
this.dialogObject = azdata.window.createModelViewDialog(dialogTitle, getDialogName(objectType, isNewObject), dialogWidth);
|
||||
this.dialogObject.okButton.label = OkText;
|
||||
this.disposables.push(this.dialogObject.onClosed(async () => { await this.dispose(); }));
|
||||
this.disposables.push(this.dialogObject.onClosed(async (reason: azdata.window.CloseReason) => { await this.dispose(reason); }));
|
||||
this._helpButton = azdata.window.createButton(HelpText, 'left');
|
||||
this.disposables.push(this._helpButton.onClick(async () => {
|
||||
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(docUrl));
|
||||
@@ -81,9 +81,14 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
protected abstract initializeData(): Promise<ViewInfoType>;
|
||||
protected abstract initializeUI(): Promise<void>;
|
||||
protected abstract onComplete(): Promise<void>;
|
||||
protected abstract onDispose(): Promise<void>;
|
||||
protected async onDispose(): Promise<void> { }
|
||||
protected abstract validateInput(): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Dispose the information related to this view in the backend service.
|
||||
*/
|
||||
protected abstract disposeView(): Promise<void>;
|
||||
|
||||
protected onObjectValueChange(): void {
|
||||
this.dialogObject.okButton.enabled = JSON.stringify(this.objectInfo) !== JSON.stringify(this._originalObjectInfo);
|
||||
}
|
||||
@@ -165,6 +170,8 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, actionName, err).withAdditionalProperties({
|
||||
objectType: this.objectType
|
||||
}).send();
|
||||
} finally {
|
||||
await this.disposeView();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -180,9 +187,12 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
||||
}
|
||||
}
|
||||
|
||||
private async dispose(): Promise<void> {
|
||||
private async dispose(reason: azdata.window.CloseReason): Promise<void> {
|
||||
await this.onDispose();
|
||||
this.disposables.forEach(disposable => disposable.dispose());
|
||||
if (reason !== 'ok') {
|
||||
await this.disposeView();
|
||||
}
|
||||
}
|
||||
|
||||
protected async runValidation(showErrorMessage: boolean = true): Promise<boolean> {
|
||||
|
||||
@@ -69,7 +69,7 @@ export class UserDialog extends ObjectManagementDialogBase<ObjectManagement.User
|
||||
}
|
||||
}
|
||||
|
||||
protected async onDispose(): Promise<void> {
|
||||
protected async disposeView(): Promise<void> {
|
||||
await this.objectManagementService.disposeUserView(this.contextId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user