Simplify button logic and enable button updates for custom dialogs (#1283)

This commit is contained in:
Matt Irvine
2018-04-27 16:29:18 -07:00
committed by GitHub
parent 886717d330
commit 24e8c20511
11 changed files with 119 additions and 72 deletions

View File

@@ -22,7 +22,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
constructor(
context: IExtHostContext,
@IInstantiationService instatiationService: IInstantiationService
@IInstantiationService instatiationService: IInstantiationService,
) {
this._proxy = context.getProxy(SqlExtHostContext.ExtHostModelViewDialog);
this._dialogService = new CustomDialogService(instatiationService);
@@ -40,7 +40,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
public $close(handle: number): Thenable<void> {
let dialog = this.getDialog(handle);
dialog.close();
this._dialogService.closeDialog(dialog);
return Promise.resolve();
}
@@ -66,7 +66,6 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
dialog.customButtons = details.customButtons.map(buttonHandle => this.getButton(buttonHandle));
}
dialog.updateContent();
return Promise.resolve();
}
@@ -79,8 +78,6 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
tab.title = details.title;
tab.content = details.content;
tab.updateContent();
return Promise.resolve();
}
@@ -88,11 +85,13 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
let button = this._buttons.get(handle);
if (!button) {
button = new DialogButton(details.label, details.enabled);
button.hidden = details.hidden;
button.onClick(() => this.onButtonClick(handle));
this._buttons.set(handle, button);
} else {
button.label = details.label;
button.enabled = details.enabled;
button.hidden = details.hidden;
}
return Promise.resolve();