fix sql migration bugs on showing/hiding content based on scenarios (#16778)

This commit is contained in:
Rachel Kim
2021-08-13 19:35:06 -07:00
committed by GitHub
parent 4efdb0e651
commit 7a57e62cd6
2 changed files with 34 additions and 55 deletions

View File

@@ -6,7 +6,7 @@
import * as azdata from 'azdata'; import * as azdata from 'azdata';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { IconPathHelper } from '../../constants/iconPathHelper'; import { IconPathHelper } from '../../constants/iconPathHelper';
import { MigrationContext, MigrationStatus, ProvisioningState } from '../../models/migrationLocalStorage'; import { MigrationContext, MigrationStatus } from '../../models/migrationLocalStorage';
import { MigrationCutoverDialogModel } from './migrationCutoverDialogModel'; import { MigrationCutoverDialogModel } from './migrationCutoverDialogModel';
import * as loc from '../../constants/strings'; import * as loc from '../../constants/strings';
import { convertByteSizeToReadableUnit, convertIsoTimeToLocalTime, getSqlServerName, getMigrationStatusImage, SupportedAutoRefreshIntervals, clearDialogMessage } from '../../api/utils'; import { convertByteSizeToReadableUnit, convertIsoTimeToLocalTime, getSqlServerName, getMigrationStatusImage, SupportedAutoRefreshIntervals, clearDialogMessage } from '../../api/utils';
@@ -145,16 +145,6 @@ export class MigrationCutoverDialog {
} }
}).component(); }).component();
const _emptyTableSubText = view.modelBuilder.text().withProps({
value: loc.EMPTY_TABLE_SUBTEXT,
CSSStyles: {
'text-align': 'center',
'margin-top': '0px',
'font-size': '15px',
'width': '300px'
}
}).component();
this._emptyTableFill = view.modelBuilder.flexContainer() this._emptyTableFill = view.modelBuilder.flexContainer()
.withLayout({ .withLayout({
flexFlow: 'column', flexFlow: 'column',
@@ -162,7 +152,6 @@ export class MigrationCutoverDialog {
}).withItems([ }).withItems([
_emptyTableImage, _emptyTableImage,
_emptyTableText, _emptyTableText,
_emptyTableSubText
]).withProps({ ]).withProps({
width: 1000, width: 1000,
display: 'none' display: 'none'
@@ -450,11 +439,12 @@ export class MigrationCutoverDialog {
addInfoFieldToContainer(this._targetServerInfoField, flexTarget); addInfoFieldToContainer(this._targetServerInfoField, flexTarget);
addInfoFieldToContainer(this._targetVersionInfoField, flexTarget); addInfoFieldToContainer(this._targetVersionInfoField, flexTarget);
const isBlobMigration = this._model.isBlobMigration();
const flexStatus = this._view.modelBuilder.flexContainer().withLayout({ const flexStatus = this._view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column' flexFlow: 'column'
}).component(); }).component();
this._migrationStatusInfoField = this.createInfoField(loc.MIGRATION_STATUS, '', false, ' '); this._migrationStatusInfoField = this.createInfoField(loc.MIGRATION_STATUS, '', false, ' ');
this._fullBackupFileOnInfoField = this.createInfoField(loc.FULL_BACKUP_FILES, '', true); this._fullBackupFileOnInfoField = this.createInfoField(loc.FULL_BACKUP_FILES, '', isBlobMigration);
this._backupLocationInfoField = this.createInfoField(loc.BACKUP_LOCATION, ''); this._backupLocationInfoField = this.createInfoField(loc.BACKUP_LOCATION, '');
addInfoFieldToContainer(this._migrationStatusInfoField, flexStatus); addInfoFieldToContainer(this._migrationStatusInfoField, flexStatus);
addInfoFieldToContainer(this._fullBackupFileOnInfoField, flexStatus); addInfoFieldToContainer(this._fullBackupFileOnInfoField, flexStatus);
@@ -463,9 +453,9 @@ export class MigrationCutoverDialog {
const flexFile = this._view.modelBuilder.flexContainer().withLayout({ const flexFile = this._view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column' flexFlow: 'column'
}).component(); }).component();
this._lastLSNInfoField = this.createInfoField(loc.LAST_APPLIED_LSN, '', true); this._lastLSNInfoField = this.createInfoField(loc.LAST_APPLIED_LSN, '', isBlobMigration);
this._lastAppliedBackupInfoField = this.createInfoField(loc.LAST_APPLIED_BACKUP_FILES, ''); this._lastAppliedBackupInfoField = this.createInfoField(loc.LAST_APPLIED_BACKUP_FILES, '');
this._lastAppliedBackupTakenOnInfoField = this.createInfoField(loc.LAST_APPLIED_BACKUP_FILES_TAKEN_ON, '', true); this._lastAppliedBackupTakenOnInfoField = this.createInfoField(loc.LAST_APPLIED_BACKUP_FILES_TAKEN_ON, '', isBlobMigration);
addInfoFieldToContainer(this._lastLSNInfoField, flexFile); addInfoFieldToContainer(this._lastLSNInfoField, flexFile);
addInfoFieldToContainer(this._lastAppliedBackupInfoField, flexFile); addInfoFieldToContainer(this._lastAppliedBackupInfoField, flexFile);
addInfoFieldToContainer(this._lastAppliedBackupTakenOnInfoField, flexFile); addInfoFieldToContainer(this._lastAppliedBackupTakenOnInfoField, flexFile);
@@ -610,7 +600,6 @@ export class MigrationCutoverDialog {
this._migrationStatusInfoField.icon!.iconPath = getMigrationStatusImage(migrationStatusTextValue); this._migrationStatusInfoField.icon!.iconPath = getMigrationStatusImage(migrationStatusTextValue);
this._fullBackupFileOnInfoField.text.value = this._model.migrationStatus?.properties?.migrationStatusDetails?.fullBackupSetInfo?.listOfBackupFiles[0]?.fileName! ?? '-'; this._fullBackupFileOnInfoField.text.value = this._model.migrationStatus?.properties?.migrationStatusDetails?.fullBackupSetInfo?.listOfBackupFiles[0]?.fileName! ?? '-';
this.showInfoField(this._fullBackupFileOnInfoField);
let backupLocation; let backupLocation;
const isBlobMigration = this._model.isBlobMigration(); const isBlobMigration = this._model.isBlobMigration();
@@ -628,15 +617,6 @@ export class MigrationCutoverDialog {
this._lastLSNInfoField.text.value = lastAppliedSSN! ?? '-'; this._lastLSNInfoField.text.value = lastAppliedSSN! ?? '-';
this._lastAppliedBackupInfoField.text.value = this._model.migrationStatus.properties.migrationStatusDetails?.lastRestoredFilename ?? '-'; this._lastAppliedBackupInfoField.text.value = this._model.migrationStatus.properties.migrationStatusDetails?.lastRestoredFilename ?? '-';
this._lastAppliedBackupTakenOnInfoField.text.value = lastAppliedBackupFileTakenOn! ? convertIsoTimeToLocalTime(lastAppliedBackupFileTakenOn).toLocaleString() : '-'; this._lastAppliedBackupTakenOnInfoField.text.value = lastAppliedBackupFileTakenOn! ? convertIsoTimeToLocalTime(lastAppliedBackupFileTakenOn).toLocaleString() : '-';
this.showInfoField(this._lastLSNInfoField);
this.showInfoField(this._lastAppliedBackupTakenOnInfoField);
if (tableData.length === 0 && this._shouldDisplayBackupFileTable()) {
this._emptyTableFill.updateCssStyles({
'display': 'flex'
});
this._fileTable.height = '50px';
}
if (this._shouldDisplayBackupFileTable()) { if (this._shouldDisplayBackupFileTable()) {
this._fileCount.updateCssStyles({ this._fileCount.updateCssStyles({
@@ -648,21 +628,33 @@ export class MigrationCutoverDialog {
this._fileCount.value = loc.ACTIVE_BACKUP_FILES_ITEMS(tableData.length); this._fileCount.value = loc.ACTIVE_BACKUP_FILES_ITEMS(tableData.length);
// Sorting files in descending order of backupStartTime if (tableData.length === 0) {
tableData.sort((file1, file2) => new Date(file1.backupStartTime) > new Date(file2.backupStartTime) ? - 1 : 1); this._emptyTableFill.updateCssStyles({
'display': 'flex'
});
this._fileTable.height = '50px';
} else {
this._emptyTableFill.updateCssStyles({
'display': 'none'
});
this._fileTable.height = '300px';
this._fileTable.data = tableData.map((row) => { // Sorting files in descending order of backupStartTime
return [ tableData.sort((file1, file2) => new Date(file1.backupStartTime) > new Date(file2.backupStartTime) ? - 1 : 1);
row.fileName,
row.type, this._fileTable.data = tableData.map((row) => {
row.status, return [
row.dataUploaded, row.fileName,
row.copyThroughput, row.type,
convertIsoTimeToLocalTime(row.backupStartTime).toLocaleString(), row.status,
row.firstLSN, row.dataUploaded,
row.lastLSN row.copyThroughput,
]; convertIsoTimeToLocalTime(row.backupStartTime).toLocaleString(),
}); row.firstLSN,
row.lastLSN
];
});
}
} }
if (migrationStatusTextValue === MigrationStatus.InProgress) { if (migrationStatusTextValue === MigrationStatus.InProgress) {
@@ -766,27 +758,12 @@ export class MigrationCutoverDialog {
}; };
} }
private showInfoField(infoField: InfoFieldSchema): void {
if (infoField.text.value !== '-') {
infoField.flexContainer.updateCssStyles({
'display': 'inline'
});
}
}
private _isProvisioned(): boolean {
const { migrationStatus, provisioningState } = this._model._migration.migrationContext.properties;
return provisioningState === ProvisioningState.Succeeded
|| migrationStatus === MigrationStatus.Completing
|| migrationStatus === MigrationStatus.Canceling;
}
private _isOnlineMigration(): boolean { private _isOnlineMigration(): boolean {
return this._model._migration.migrationContext.properties.autoCutoverConfiguration?.autoCutover?.valueOf() ? false : true; return this._model._migration.migrationContext.properties.autoCutoverConfiguration?.autoCutover?.valueOf() ? false : true;
} }
private _shouldDisplayBackupFileTable(): boolean { private _shouldDisplayBackupFileTable(): boolean {
return this._isProvisioned() && this._isOnlineMigration() && !this._model.isBlobMigration(); return !this._model.isBlobMigration();
} }
private getMigrationStatus(): string { private getMigrationStatus(): string {

View File

@@ -735,6 +735,8 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobTableContainer.display = 'none'; this._blobTableContainer.display = 'none';
this._blobContainer.updateCssStyles({ 'display': 'none' }); this._blobContainer.updateCssStyles({ 'display': 'none' });
this._targetDatabaseContainer.updateCssStyles({ 'display': 'none' });
this._networkShareStorageAccountDetails.updateCssStyles({ 'display': 'none' });
const connectionProfile = await this.migrationStateModel.getSourceConnectionProfile(); const connectionProfile = await this.migrationStateModel.getSourceConnectionProfile();
const queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>((await this.migrationStateModel.getSourceConnectionProfile()).providerId, azdata.DataProviderType.QueryProvider); const queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>((await this.migrationStateModel.getSourceConnectionProfile()).providerId, azdata.DataProviderType.QueryProvider);
const query = 'select SUSER_NAME()'; const query = 'select SUSER_NAME()';