From 1fdb339fbfd43cade8971ff36b6de7b7d5c9aee3 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Tue, 4 May 2021 13:06:27 -0700 Subject: [PATCH] Enable the "Enable notebooks" button (#734) * enable notebooks initial commit * use only first write location * addressed PR comments * Minor edits --- src/Explorer/Explorer.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index b68d1756f..5b368781f 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -1643,7 +1643,9 @@ export default class Explorer { } 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 authorizationHeader = getAuthorizationHeader(); try { @@ -1668,9 +1670,9 @@ export default class Explorer { this.isNotebooksEnabledForAccount(true); return; } - const isAccountInAllowedLocation = !disallowedLocations.some( - (disallowedLocation) => disallowedLocation === databaseAccountLocation - ); + + // firstWriteLocation should not be disallowed + const isAccountInAllowedLocation = firstWriteLocation && disallowedLocations.indexOf(firstWriteLocation) === -1; this.isNotebooksEnabledForAccount(isAccountInAllowedLocation); } catch (error) { Logger.logError(getErrorMessage(error), "Explorer/isNotebooksEnabledForAccount");