mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
improve account and tenant selection error handling (#17476)
* improve account/tenant selection error handling * remove extra space from user string
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
"aiKey": "AIF-37eefaf0-8022-4671-a3fb-64752724682e",
|
"aiKey": "AIF-37eefaf0-8022-4671-a3fb-64752724682e",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "*",
|
"vscode": "*",
|
||||||
"azdata": ">=1.29.0"
|
"azdata": ">=1.33.0"
|
||||||
},
|
},
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onDashboardOpen",
|
"onDashboardOpen",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export type AzureProduct = azureResource.AzureGraphResource;
|
|||||||
|
|
||||||
export async function getResourceGroups(account: azdata.Account, subscription: Subscription): Promise<azureResource.AzureResourceResourceGroup[]> {
|
export async function getResourceGroups(account: azdata.Account, subscription: Subscription): Promise<azureResource.AzureResourceResourceGroup[]> {
|
||||||
const api = await getAzureCoreAPI();
|
const api = await getAzureCoreAPI();
|
||||||
const result = await api.getResourceGroups(account, subscription, false);
|
const result = await api.getResourceGroups(account, subscription, true);
|
||||||
sortResourceArrayByName(result.resourceGroups);
|
sortResourceArrayByName(result.resourceGroups);
|
||||||
return result.resourceGroups;
|
return result.resourceGroups;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,10 +92,19 @@ export function accountLinkedMessage(count: number): string {
|
|||||||
}
|
}
|
||||||
export const AZURE_TENANT = localize('sql.migration.azure.tenant', "Azure AD tenant");
|
export const AZURE_TENANT = localize('sql.migration.azure.tenant', "Azure AD tenant");
|
||||||
export function ACCOUNT_STALE_ERROR(account: AzureAccount) {
|
export function ACCOUNT_STALE_ERROR(account: AzureAccount) {
|
||||||
return localize('azure.accounts.accountStaleError', "The access token for selected account '{0}' is no longer valid. Select 'Link account' and refresh the account, or select a different account.", `${account.displayInfo.displayName} (${account.displayInfo.userId})`);
|
return localize(
|
||||||
|
'azure.accounts.accountStaleError',
|
||||||
|
"The access token for selected account '{0}' and tenant '{1}' is no longer valid. Select 'Link account' and refresh the account, or select a different account.",
|
||||||
|
`${account?.displayInfo?.displayName} (${account?.displayInfo?.userId})`,
|
||||||
|
`${account?.properties?.tenants[0]?.displayName} (${account?.properties?.tenants[0]?.userId})`);
|
||||||
}
|
}
|
||||||
export function ACCOUNT_ACCESS_ERROR(account: AzureAccount, error: Error) {
|
export function ACCOUNT_ACCESS_ERROR(account: AzureAccount, error: Error) {
|
||||||
return localize('azure.accounts.accountAccessError', "An error occurred while accessing the selected account '{0}'. Select 'Link account' and refresh the account, or select a different account. Error '{1}'", `${account.displayInfo.displayName} (${account.displayInfo.userId})`, error.message);
|
return localize(
|
||||||
|
'azure.accounts.accountAccessError',
|
||||||
|
"An error occurred while accessing the selected account '{0}' and tenant '{1}'. Select 'Link account' and refresh the account, or select a different account. Error '{2}'",
|
||||||
|
`${account?.displayInfo?.displayName} (${account?.displayInfo?.userId})`,
|
||||||
|
`${account?.properties?.tenants[0]?.displayName} (${account?.properties?.tenants[0]?.userId})`,
|
||||||
|
error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// database backup page
|
// database backup page
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ export class AccountsSelectionPage extends MigrationWizardPage {
|
|||||||
}
|
}
|
||||||
if (this.migrationStateModel._azureAccount?.isStale) {
|
if (this.migrationStateModel._azureAccount?.isStale) {
|
||||||
this.wizard.message = {
|
this.wizard.message = {
|
||||||
|
level: azdata.window.MessageLevel.Error,
|
||||||
text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount)
|
text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount)
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
@@ -193,8 +194,6 @@ export class AccountsSelectionPage extends MigrationWizardPage {
|
|||||||
this.migrationStateModel._targetSubscription = undefined!;
|
this.migrationStateModel._targetSubscription = undefined!;
|
||||||
this.migrationStateModel._databaseBackup.subscription = undefined!;
|
this.migrationStateModel._databaseBackup.subscription = undefined!;
|
||||||
}
|
}
|
||||||
const selectedAzureAccount = this.migrationStateModel.getAccount(selectedIndex);
|
|
||||||
this.migrationStateModel._azureAccount = deepClone(selectedAzureAccount);
|
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -233,16 +232,24 @@ export class AccountsSelectionPage extends MigrationWizardPage {
|
|||||||
public async onPageEnter(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise<void> {
|
public async onPageEnter(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise<void> {
|
||||||
this.wizard.registerNavigationValidator(async pageChangeInfo => {
|
this.wizard.registerNavigationValidator(async pageChangeInfo => {
|
||||||
try {
|
try {
|
||||||
if (!this.migrationStateModel._azureAccount?.isStale) {
|
this.wizard.message = { text: '', };
|
||||||
|
|
||||||
|
if (this.migrationStateModel._azureAccount && !this.migrationStateModel._azureAccount?.isStale) {
|
||||||
const subscriptions = await getSubscriptions(this.migrationStateModel._azureAccount);
|
const subscriptions = await getSubscriptions(this.migrationStateModel._azureAccount);
|
||||||
if (subscriptions?.length > 0) {
|
if (subscriptions?.length > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wizard.message = { text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount) };
|
this.wizard.message = {
|
||||||
|
level: azdata.window.MessageLevel.Error,
|
||||||
|
text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount),
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.wizard.message = { text: constants.ACCOUNT_ACCESS_ERROR(this.migrationStateModel._azureAccount, error) };
|
this.wizard.message = {
|
||||||
|
level: azdata.window.MessageLevel.Error,
|
||||||
|
text: constants.ACCOUNT_ACCESS_ERROR(this.migrationStateModel._azureAccount, error),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user