diff --git a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts index 1eeb105ef300..a4619f3b107b 100644 --- a/extensions/mssql/src/objectManagement/ui/databaseDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/databaseDialog.ts @@ -930,7 +930,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, @@ -956,6 +957,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): boolean { return true; } + protected addButtonEnabled(table: azdata.TableComponent): boolean { return true; } + protected validateInput(): Promise { return Promise.resolve([]); } public async open(): Promise { @@ -295,12 +298,13 @@ export abstract class DialogBase { if (editButton !== undefined) { editButtonComponent.enabled = tableSelectedRowsLengthCheck; } + addButtonComponent.enabled = this.addButtonEnabled(table); removeButtonComponent.enabled = !!isRemoveEnabled && tableSelectedRowsLengthCheck; } addButtonComponent = this.createButton(uiLoc.AddText, addbutton.buttonAriaLabel, async () => { await addbutton.buttonHandler(addButtonComponent); updateButtons(); - }); + }, addbutton.enabled ?? true); buttonComponents.push(addButtonComponent); if (editButton !== undefined) {