Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filegroup Memory optimized table Add button should be disabled when have at least one filegroup #24446

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion extensions/mssql/src/objectManagement/ui/databaseDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ export class DatabaseDialog extends ObjectManagementDialogBase<Database, Databas
this.memoryOptimizedFilegroupNameInput = this.getFilegroupNameInput(this.memoryOptimizedFilegroupsTable, FileGroupType.MemoryOptimizedDataFileGroup);
const addButtonComponent: DialogButton = {
buttonAriaLabel: localizedConstants.AddFilegroupText,
buttonHandler: () => this.onAddDatabaseFileGroupsButtonClicked(this.memoryOptimizedFilegroupsTable)
buttonHandler: () => this.onAddDatabaseFileGroupsButtonClicked(this.memoryOptimizedFilegroupsTable),
enabled: this.memoryoptimizedFileGroupsTableRows.length < 1
};
const removeButtonComponent: DialogButton = {
buttonAriaLabel: localizedConstants.RemoveButton,
Expand All @@ -956,6 +957,19 @@ export class DatabaseDialog extends ObjectManagementDialogBase<Database, Databas
return this.createGroup(localizedConstants.MemoryOptimizedFileGroupsSectionText, [this.memoryOptimizedFilegroupsTable, memoryOptimizedContainer], true);
}

/**
* Overrides declarative table add button enabled/disabled state
* @param table table component
* @returns table add button enabled/disabled state
*/
public override addButtonEnabled(table: azdata.TableComponent | azdata.DeclarativeTableComponent): boolean {
let enabled = true;
if (table === this.memoryOptimizedFilegroupsTable) {
enabled = this.memoryoptimizedFileGroupsTableRows.length < 1;
}
return enabled;
}

/**
* Update the default value for the filegroup
* @param arg selected checkbox event
Expand Down
8 changes: 6 additions & 2 deletions extensions/mssql/src/ui/dialogBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function getTableHeight(rowCount: number, minRowCount: number = DefaultMi

export interface DialogButton {
buttonAriaLabel: string;
buttonHandler: (button: azdata.ButtonComponent) => Promise<void>
buttonHandler: (button: azdata.ButtonComponent) => Promise<void>,
enabled?: boolean
}

export type TableListItemEnabledStateGetter<T> = (item: T) => boolean;
Expand Down Expand Up @@ -80,6 +81,8 @@ export abstract class DialogBase<DialogResult> {

protected removeButtonEnabled(table: azdata.TableComponent): boolean { return true; }

protected addButtonEnabled(table: azdata.TableComponent): boolean { return true; }

protected validateInput(): Promise<string[]> { return Promise.resolve([]); }

public async open(): Promise<void> {
Expand Down Expand Up @@ -295,12 +298,13 @@ export abstract class DialogBase<DialogResult> {
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) {
Expand Down
Loading