diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index ba32b900f37e..28ad6b551f78 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -958,7 +958,8 @@ export class DatabaseDialog extends ObjectManagementDialogBase this.onAddDatabaseFileGroupsButtonClicked(this.memoryOptimizedFilegroupsTable) + buttonHandler: () => this.onAddDatabaseFileGroupsButtonClicked(this.memoryOptimizedFilegroupsTable), + enabled: this.memoryoptimizedFileGroupsTableRows.length < 1 }; const removeButtonComponent: DialogButton = { buttonAriaLabel: localizedConstants.RemoveButton, @@ -984,6 +985,19 @@ export class DatabaseDialog extends ObjectManagementDialogBase Promise + buttonHandler: (button: azdata.ButtonComponent) => Promise; + enabled?: boolean; } export type TableListItemEnabledStateGetter = (item: T) => boolean; @@ -80,6 +81,8 @@ export abstract class DialogBase { protected removeButtonEnabled(table: azdata.TableComponent | azdata.DeclarativeTableComponent): boolean { return true; } + protected addButtonEnabled(table: azdata.TableComponent | azdata.DeclarativeTableComponent): boolean { return true; } + protected validateInput(): Promise { return Promise.resolve([]); } public async open(): Promise { @@ -341,13 +344,13 @@ export abstract class DialogBase { let buttonComponents: azdata.ButtonComponent[] = []; const updateButtons = (isRemoveEnabled: boolean = undefined) => { this.onFormFieldChange(); + addButtonComponent.enabled = this.addButtonEnabled(table); removeButtonComponent.enabled = !!isRemoveEnabled; } - addButtonComponent = this.createButton(uiLoc.AddText, addbutton.buttonAriaLabel, async () => { await addbutton.buttonHandler(addButtonComponent); updateButtons(); - }); + }, addbutton.enabled ?? true); buttonComponents.push(addButtonComponent); removeButtonComponent = this.createButton(uiLoc.RemoveText, removeButton.buttonAriaLabel, async () => {