From 60a76a69f6dd88bb22b039396901a019153acef9 Mon Sep 17 00:00:00 2001 From: "Craig Boger (from Dev Box)" Date: Fri, 26 Jan 2024 16:03:10 -0800 Subject: [PATCH] Initial attempt at updating the user context with a regional endpoint. Successful. --- src/Common/CosmosClient.ts | 20 +++++++++++++++++++ .../CommandBarComponentButtonFactory.tsx | 2 ++ src/hooks/useKnockoutExplorer.ts | 14 ++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index b7fcae089..ed6e9ab33 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -172,6 +172,26 @@ export function client(): Cosmos.CosmosClient { }, }; + // Account details from userContext. + console.log(`userContext details: ${JSON.stringify(userContext)}`); + console.log(`userContext.databaseaccount details: ${JSON.stringify(userContext.databaseAccount)}`); + console.log( + `userContext?.databaseAccount?.properties?.documentEndpoint details: ${JSON.stringify( + userContext?.databaseAccount?.properties?.documentEndpoint, + )}`, + ); + console.log(`userContext?.endpoint details: ${JSON.stringify(userContext?.endpoint)}`); + console.log( + `userContext?.databaseAccount?.properties?.readLocations details: ${JSON.stringify( + userContext?.databaseAccount?.properties?.readLocations, + )}`, + ); + console.log( + `userContext?.databaseAccount?.properties?.writeLocations details: ${JSON.stringify( + userContext?.databaseAccount?.properties?.writeLocations, + )}`, + ); + if (configContext.PROXY_PATH !== undefined) { (options as any).plugins = [{ on: "request", plugin: requestPlugin }]; } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx index 869dd2383..b145c1a7a 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.tsx @@ -168,6 +168,8 @@ export function createStaticCommandBarButtons( } } + // Attempting to add region selection button here. + return buttons; } diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index b04b16c72..ac2a4d301 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -280,13 +280,25 @@ async function configureHostedWithAAD(config: AAD): Promise { throw new Error(`List keys failed: ${e.message}`); } } + // Updating database account endpoint for testing purposes. + const updatedDatabaseAccount = { + ...config.databaseAccount, + properties: { + ...config.databaseAccount.properties, + documentEndpoint: "https://test-craig-nosql-periodic.documents.azure.com:443/", + }, + }; updateUserContext({ subscriptionId, resourceGroup, aadToken, - databaseAccount: config.databaseAccount, + databaseAccount: updatedDatabaseAccount, masterKey: keys.primaryMasterKey, }); + console.log(`INITIALIZED ENDPOINT: ${JSON.stringify(userContext.databaseAccount.properties.documentEndpoint)}`); + userContext.databaseAccount.properties.readLocations.forEach((readLocation) => { + console.log(`REGIONAL READ ENDPOINT(S): ${JSON.stringify(readLocation)}`); + }); const explorer = new Explorer(); return explorer; }