Dev/brih/hotfix status page (#16407)

* add dispose pattern, fix migration status enum

* format strings

* add dispose handler to more events
This commit is contained in:
brian-harris
2021-07-22 22:20:10 -07:00
committed by GitHub
parent 107023c7d0
commit df5ed2c889
22 changed files with 351 additions and 249 deletions

View File

@@ -31,6 +31,7 @@ export class MigrationStatusDialog {
private _statusTable!: azdata.DeclarativeTableComponent;
private _refreshLoader!: azdata.LoadingComponent;
private _autoRefreshHandle!: NodeJS.Timeout;
private _disposables: vscode.Disposable[] = [];
constructor(migrations: MigrationContext[], private _filter: AdsMigrationStatus) {
this._model = new MigrationStatusDialogModel(migrations);
@@ -48,9 +49,9 @@ export class MigrationStatusDialog {
width: '220px'
}).component();
this._statusDropdown.onValueChanged((value) => {
this._disposables.push(this._statusDropdown.onValueChanged((value) => {
this.populateMigrationTable();
});
}));
if (this._filter) {
this._statusDropdown.value = (<azdata.CategoryValue[]>this._statusDropdown.values).find((value) => {
@@ -76,17 +77,20 @@ export class MigrationStatusDialog {
}
);
const form = formBuilder.withLayout({ width: '100%' }).component();
this._view.onClosed(e => {
this._disposables.push(this._view.onClosed(e => {
clearInterval(this._autoRefreshHandle);
});
this._disposables.forEach(
d => { try { d.dispose(); } catch { } });
}));
return view.initializeModel(form);
});
this._dialogObject.content = [tab];
this._dialogObject.cancelButton.hidden = true;
this._dialogObject.okButton.label = loc.CLOSE;
this._dialogObject.okButton.onClick(e => {
this._disposables.push(this._dialogObject.okButton.onClick(e => {
clearInterval(this._autoRefreshHandle);
});
}));
azdata.window.openDialog(this._dialogObject);
}
@@ -100,9 +104,9 @@ export class MigrationStatusDialog {
width: '360px'
}).component();
this._searchBox.onTextChanged((value) => {
this._disposables.push(this._searchBox.onTextChanged((value) => {
this.populateMigrationTable();
});
}));
this._refresh = this._view.modelBuilder.button().withProps({
iconPath: {
@@ -115,9 +119,9 @@ export class MigrationStatusDialog {
label: loc.REFRESH_BUTTON_LABEL,
}).component();
this._refresh.onDidClick((e) => {
this._disposables.push(this._refresh.onDidClick((e) => {
this.refreshTable();
});
}));
const flexContainer = this._view.modelBuilder.flexContainer().withProps({
width: 900,
@@ -170,7 +174,7 @@ export class MigrationStatusDialog {
}
private registerCommands(): void {
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.cutover',
async (migrationId: string) => {
try {
@@ -186,9 +190,9 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.view.database',
async (migrationId: string) => {
try {
@@ -198,9 +202,9 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.view.target',
async (migrationId: string) => {
try {
@@ -210,9 +214,9 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.view.service',
async (migrationId: string) => {
try {
@@ -222,9 +226,9 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.copy.migration',
async (migrationId: string) => {
try {
@@ -244,9 +248,9 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
vscode.commands.registerCommand(
this._disposables.push(vscode.commands.registerCommand(
'sqlmigration.cancel.migration',
async (migrationId: string) => {
try {
@@ -265,7 +269,7 @@ export class MigrationStatusDialog {
} catch (e) {
console.log(e);
}
});
}));
}
private async populateMigrationTable(): Promise<void> {
@@ -336,8 +340,8 @@ export class MigrationStatusDialog {
CSSStyles: statusCellStyles
}).component();
databaseHyperLink.onDidClick(
async (e) => await (new MigrationCutoverDialog(migration)).initialize());
this._disposables.push(databaseHyperLink.onDidClick(
async (e) => await (new MigrationCutoverDialog(migration)).initialize()));
return this._view.modelBuilder
.flexContainer()
@@ -563,7 +567,7 @@ export class MigrationStatusDialog {
return IconPathHelper.notStartedMigration;
case 'Completing':
return IconPathHelper.completingCutover;
case 'Cancelling':
case 'Canceling':
return IconPathHelper.cancel;
case 'Failed':
default: