mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Simplify button logic and enable button updates for custom dialogs (#1283)
This commit is contained in:
@@ -26,18 +26,6 @@ class DialogImpl implements sqlops.window.modelviewdialog.Dialog {
|
||||
this.okButton = this._extHostModelViewDialog.createButton(nls.localize('dialogOkLabel', 'Done'));
|
||||
this.cancelButton = this._extHostModelViewDialog.createButton(nls.localize('dialogCancelLabel', 'Cancel'));
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this._extHostModelViewDialog.open(this);
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
this._extHostModelViewDialog.close(this);
|
||||
}
|
||||
|
||||
public updateContent(): void {
|
||||
this._extHostModelViewDialog.updateDialogContent(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TabImpl implements sqlops.window.modelviewdialog.DialogTab {
|
||||
@@ -45,21 +33,19 @@ class TabImpl implements sqlops.window.modelviewdialog.DialogTab {
|
||||
public content: string;
|
||||
|
||||
constructor(private _extHostModelViewDialog: ExtHostModelViewDialog) { }
|
||||
|
||||
public updateContent(): void {
|
||||
this._extHostModelViewDialog.updateTabContent(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonImpl implements sqlops.window.modelviewdialog.Button {
|
||||
private _label: string;
|
||||
private _enabled: boolean;
|
||||
private _hidden: boolean;
|
||||
|
||||
private _onClick = new Emitter<void>();
|
||||
public onClick = this._onClick.event;
|
||||
|
||||
constructor(private _extHostModelViewDialog: ExtHostModelViewDialog) {
|
||||
this._enabled = true;
|
||||
this._hidden = false;
|
||||
}
|
||||
|
||||
public get label(): string {
|
||||
@@ -80,6 +66,15 @@ class ButtonImpl implements sqlops.window.modelviewdialog.Button {
|
||||
this._extHostModelViewDialog.updateButton(this);
|
||||
}
|
||||
|
||||
public get hidden(): boolean {
|
||||
return this._hidden;
|
||||
}
|
||||
|
||||
public set hidden(hidden: boolean) {
|
||||
this._hidden = hidden;
|
||||
this._extHostModelViewDialog.updateButton(this);
|
||||
}
|
||||
|
||||
public getOnClickCallback(): () => void {
|
||||
return () => this._onClick.fire();
|
||||
}
|
||||
@@ -154,7 +149,7 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
|
||||
let handle = this.getDialogHandle(dialog);
|
||||
let tabs = dialog.content;
|
||||
if (tabs && typeof tabs !== 'string') {
|
||||
tabs.forEach(tab => tab.updateContent());
|
||||
tabs.forEach(tab => this.updateTabContent(tab));
|
||||
}
|
||||
if (dialog.customButtons) {
|
||||
dialog.customButtons.forEach(button => this.updateButton(button));
|
||||
@@ -182,7 +177,8 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
|
||||
let handle = this.getButtonHandle(button);
|
||||
this._proxy.$setButtonDetails(handle, {
|
||||
label: button.label,
|
||||
enabled: button.enabled
|
||||
enabled: button.enabled,
|
||||
hidden: button.hidden
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user