mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 01:25:38 -05:00
Refactor functionality into LoginMigrationsModel (#21933)
This PR refactors to encapsulate all login migration functionality into LoginMigrationModel
This commit is contained in:
@@ -88,7 +88,7 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
this.wizard.message = {
|
||||
text: constants.LOGIN_MIGRATIONS_FAILED,
|
||||
level: azdata.window.MessageLevel.Error,
|
||||
description: constants.LOGIN_MIGRATIONS_ERROR(this.migrationStateModel._loginMigrationsError.message),
|
||||
description: constants.LOGIN_MIGRATIONS_ERROR(this.migrationStateModel._loginMigrationModel.loginMigrationsError.message),
|
||||
};
|
||||
|
||||
this._progressLoader.loading = false;
|
||||
@@ -292,7 +292,7 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
}
|
||||
|
||||
private async _loadMigratingLoginsList(stateMachine: MigrationStateModel): Promise<void> {
|
||||
const loginList = stateMachine._loginsForMigration || [];
|
||||
const loginList = stateMachine._loginMigrationModel.loginsForMigration || [];
|
||||
loginList.sort((a, b) => a.loginName.localeCompare(b.loginName));
|
||||
|
||||
this._loginsTableValues = loginList.map(login => {
|
||||
@@ -300,13 +300,13 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
|
||||
var status = LoginMigrationStatusCodes.InProgress;
|
||||
var title = constants.LOGIN_MIGRATION_STATUS_IN_PROGRESS;
|
||||
if (stateMachine._loginMigrationsError) {
|
||||
if (stateMachine._loginMigrationModel.loginMigrationsError) {
|
||||
status = LoginMigrationStatusCodes.Failed;
|
||||
title = constants.LOGIN_MIGRATION_STATUS_FAILED;
|
||||
} else if (stateMachine._loginMigrationsResult) {
|
||||
} else if (stateMachine._loginMigrationModel.loginMigrationsResult) {
|
||||
status = LoginMigrationStatusCodes.Succeeded;
|
||||
title = constants.LOGIN_MIGRATION_STATUS_SUCCEEDED;
|
||||
var didLoginFail = Object.keys(stateMachine._loginMigrationsResult.exceptionMap).some(key => key.toLocaleLowerCase() === loginName.toLocaleLowerCase());
|
||||
var didLoginFail = Object.keys(stateMachine._loginMigrationModel.loginMigrationsResult.exceptionMap).some(key => key.toLocaleLowerCase() === loginName.toLocaleLowerCase());
|
||||
if (didLoginFail) {
|
||||
status = LoginMigrationStatusCodes.Failed;
|
||||
title = constants.LOGIN_MIGRATION_STATUS_FAILED;
|
||||
@@ -352,7 +352,7 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
'value': constants.STARTING_LOGIN_MIGRATION
|
||||
});
|
||||
|
||||
var result = await this.migrationStateModel.migrateLogins();
|
||||
var result = await this.migrationStateModel._loginMigrationModel.MigrateLogins(this.migrationStateModel);
|
||||
|
||||
if (!result) {
|
||||
await this._migrationProgressDetails.updateProperties({
|
||||
@@ -366,7 +366,7 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
'value': constants.ESTABLISHING_USER_MAPPINGS
|
||||
});
|
||||
|
||||
result = await this.migrationStateModel.establishUserMappings();
|
||||
result = await this.migrationStateModel._loginMigrationModel.EstablishUserMappings(this.migrationStateModel);
|
||||
|
||||
if (!result) {
|
||||
await this._migrationProgressDetails.updateProperties({
|
||||
@@ -380,7 +380,7 @@ export class LoginMigrationStatusPage extends MigrationWizardPage {
|
||||
'value': constants.MIGRATING_SERVER_ROLES_AND_SET_PERMISSIONS
|
||||
});
|
||||
|
||||
result = await this.migrationStateModel.migrateServerRolesAndSetPermissions();
|
||||
result = await this.migrationStateModel._loginMigrationModel.MigrateServerRolesAndSetPermissions(this.migrationStateModel);
|
||||
|
||||
if (!result) {
|
||||
await this._migrationProgressDetails.updateProperties({
|
||||
|
||||
@@ -92,7 +92,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
await this._loadLoginList(false);
|
||||
|
||||
// load unfiltered table list and pre-select list of logins saved in state
|
||||
await this._filterTableList('', this.migrationStateModel._loginsForMigration);
|
||||
await this._filterTableList('', this.migrationStateModel._loginMigrationModel.loginsForMigration);
|
||||
}
|
||||
|
||||
public async onPageLeave(): Promise<void> {
|
||||
@@ -115,7 +115,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
}).component();
|
||||
|
||||
this._disposables.push(
|
||||
resourceSearchBox.onTextChanged(value => this._filterTableList(value, this.migrationStateModel._loginsForMigration || [])));
|
||||
resourceSearchBox.onTextChanged(value => this._filterTableList(value, this.migrationStateModel._loginMigrationModel.loginsForMigration || [])));
|
||||
|
||||
const searchContainer = this._view.modelBuilder.divContainer().withItems([resourceSearchBox]).withProps({
|
||||
CSSStyles: {
|
||||
@@ -326,7 +326,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
}));
|
||||
|
||||
// load unfiltered table list and pre-select list of logins saved in state
|
||||
await this._filterTableList('', this.migrationStateModel._loginsForMigration);
|
||||
await this._filterTableList('', this.migrationStateModel._loginMigrationModel.loginsForMigration);
|
||||
|
||||
const flex = view.modelBuilder.flexContainer().withLayout({
|
||||
flexFlow: 'column',
|
||||
@@ -416,7 +416,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
|
||||
private async _loadLoginList(runQuery: boolean = true): Promise<void> {
|
||||
const stateMachine: MigrationStateModel = this.migrationStateModel;
|
||||
const selectedLogins: LoginTableInfo[] = stateMachine._loginsForMigration || [];
|
||||
const selectedLogins: LoginTableInfo[] = stateMachine._loginMigrationModel.loginsForMigration || [];
|
||||
|
||||
// Get source logins if caller asked us to or if we haven't collected in the past
|
||||
if (runQuery || !stateMachine._loginMigrationModel.collectedSourceLogins) {
|
||||
@@ -488,7 +488,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
await utils.updateControlDisplay(this._aadDomainNameContainer, hasSelectedWindowsLogins);
|
||||
await this._loginSelectorTable.updateProperty("height", hasSelectedWindowsLogins ? 600 : 650);
|
||||
|
||||
this.migrationStateModel._loginsForMigration = selectedLogins;
|
||||
this.migrationStateModel._loginMigrationModel.loginsForMigration = selectedLogins;
|
||||
this.updateNextButton();
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ export class LoginSelectorPage extends MigrationWizardPage {
|
||||
// Only uppdate next label if we are currently on this page
|
||||
if (this._isCurrentPage) {
|
||||
this.wizard.nextButton.label = constants.LOGIN_MIGRATE_BUTTON_TEXT;
|
||||
this.wizard.nextButton.enabled = this.migrationStateModel?._loginsForMigration?.length > 0;
|
||||
this.wizard.nextButton.enabled = this.migrationStateModel?._loginMigrationModel.loginsForMigration?.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user