Enable the "Enable notebooks" button (#734)

* enable notebooks initial commit

* use only first write location

* addressed PR comments

* Minor edits
This commit is contained in:
Srinath Narayanan 2021-05-04 13:06:27 -07:00 committed by GitHub
parent b7579d5c8b
commit 1fdb339fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -1643,7 +1643,9 @@ export default class Explorer {
} }
const databaseAccount = this.databaseAccount(); const databaseAccount = this.databaseAccount();
const databaseAccountLocation = databaseAccount && databaseAccount.location.toLowerCase(); const firstWriteLocation =
databaseAccount?.properties?.writeLocations &&
databaseAccount?.properties?.writeLocations[0]?.locationName.toLowerCase();
const disallowedLocationsUri = `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`; const disallowedLocationsUri = `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`;
const authorizationHeader = getAuthorizationHeader(); const authorizationHeader = getAuthorizationHeader();
try { try {
@ -1668,9 +1670,9 @@ export default class Explorer {
this.isNotebooksEnabledForAccount(true); this.isNotebooksEnabledForAccount(true);
return; return;
} }
const isAccountInAllowedLocation = !disallowedLocations.some(
(disallowedLocation) => disallowedLocation === databaseAccountLocation // firstWriteLocation should not be disallowed
); const isAccountInAllowedLocation = firstWriteLocation && disallowedLocations.indexOf(firstWriteLocation) === -1;
this.isNotebooksEnabledForAccount(isAccountInAllowedLocation); this.isNotebooksEnabledForAccount(isAccountInAllowedLocation);
} catch (error) { } catch (error) {
Logger.logError(getErrorMessage(error), "Explorer/isNotebooksEnabledForAccount"); Logger.logError(getErrorMessage(error), "Explorer/isNotebooksEnabledForAccount");