Enable notebooks should use account regions

This commit is contained in:
Vignesh Rangaishenvi 2021-03-17 15:24:23 -07:00
parent 3530633fa2
commit b52f425b4c
1 changed files with 24 additions and 14 deletions

View File

@ -2006,7 +2006,11 @@ export default class Explorer {
}
const databaseAccount = this.databaseAccount();
const databaseAccountLocation = databaseAccount && databaseAccount.location.toLowerCase();
const databaseAccountLocations = databaseAccount && [
databaseAccount?.location.toLowerCase(),
...databaseAccount?.properties?.readLocations?.map(location => location?.locationName?.toLowerCase()),
...databaseAccount?.properties?.writeLocations?.map(location => location?.locationName?.toLowerCase())
];
const disallowedLocationsUri = `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`;
const authorizationHeader = getAuthorizationHeader();
try {
@ -2031,9 +2035,15 @@ export default class Explorer {
this.isNotebooksEnabledForAccount(true);
return;
}
const isAccountInAllowedLocation = !disallowedLocations.some(
(disallowedLocation) => disallowedLocation === databaseAccountLocation
);
const isAccountInAllowedLocation = databaseAccountLocations?.some(
(accountLocation) => {
if (!accountLocation) {
return false;
}
return !disallowedLocations.some(disallowedLocation => disallowedLocation === accountLocation); // not a disallowed location
}
) || false;
this.isNotebooksEnabledForAccount(isAccountInAllowedLocation);
} catch (error) {
Logger.logError(getErrorMessage(error), "Explorer/isNotebooksEnabledForAccount");