mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Select available tenant Id instead of first one as default (#21190)
This commit is contained in:
@@ -648,7 +648,23 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
let options = selectedAccount.properties.tenants.map(tenant => tenant.displayName);
|
||||
this._azureTenantDropdown.setOptions(options);
|
||||
this._tableContainer.classList.remove(hideTenantsClassName);
|
||||
this.onAzureTenantSelected(0);
|
||||
|
||||
// If we have a tenant ID available, select that instead of the first one
|
||||
if (this._azureTenantId) {
|
||||
let tenant = selectedAccount.properties.tenants.find(tenant => tenant.id === this._azureTenantId);
|
||||
if (tenant) {
|
||||
this.onAzureTenantSelected(options.indexOf(tenant.displayName));
|
||||
}
|
||||
else {
|
||||
// This should ideally never ever happen!
|
||||
this._logService.error(`onAzureAccountSelected : Could not find tenant with ID ${this._azureTenantId} for account ${selectedAccount.displayInfo.displayName}`);
|
||||
this.onAzureTenantSelected(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.onAzureTenantSelected(0);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (selectedAccount && selectedAccount.properties.tenants && selectedAccount.properties.tenants.length === 1) {
|
||||
this._azureTenantId = selectedAccount.properties.tenants[0].id;
|
||||
@@ -668,6 +684,10 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
this._azureTenantId = tenant.id;
|
||||
this._callbacks.onAzureTenantSelection(tenant.id);
|
||||
}
|
||||
else {
|
||||
// This should ideally never ever happen!
|
||||
this._logService.error(`onAzureTenantSelected : Could not find tenant with ID ${this._azureTenantId} for account ${account.displayInfo.displayName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,11 +821,15 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
this._azureAccountDropdown.selectWithOptionName(this.getModelValue(accountName));
|
||||
await this.onAzureAccountSelected();
|
||||
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (account && account.properties.tenants.length > 1) {
|
||||
if (account && account.properties.tenants && account.properties.tenants.length > 1) {
|
||||
let tenant = account.properties.tenants.find(tenant => tenant.id === tenantId);
|
||||
if (tenant) {
|
||||
this._azureTenantDropdown.selectWithOptionName(tenant.displayName);
|
||||
}
|
||||
else {
|
||||
// This should ideally never ever happen!
|
||||
this._logService.error(`fillInConnectionInputs : Could not find tenant with ID ${this._azureTenantId} for account ${accountName}`);
|
||||
}
|
||||
this.onAzureTenantSelected(this._azureTenantDropdown.values.indexOf(this._azureTenantDropdown.value));
|
||||
}
|
||||
}).catch(err => this._logService.error(`Unexpected error populating initial Azure Account options : ${err}`));
|
||||
|
||||
Reference in New Issue
Block a user