From b9245101bcd48b8a6e7fb02332821807b2a640d2 Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Fri, 16 Oct 2020 12:24:45 -0700 Subject: [PATCH] Fix two bugs with tables database offer (#282) 1. After moving read databases call to RP for Tables API, we lose the `_rid` property. Since we are reading Table's database offer with SDK, we need the `_rid` of the database to find its offer. Without `_rid`, we won't be able to find the database offer and the Scale tab would disappear again. The fix is to use SDK to read databases for Table API so we have `_rid`. 2. There's a bug in the non-aad code path for updating offers which prevents users from switching from manual to autoscale and vice versa. The fix is to properly set the option headers. --- src/Common/dataAccess/readDatabases.ts | 10 +++++----- src/Common/dataAccess/updateOffer.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Common/dataAccess/readDatabases.ts b/src/Common/dataAccess/readDatabases.ts index e6a845abc..5f65f526b 100644 --- a/src/Common/dataAccess/readDatabases.ts +++ b/src/Common/dataAccess/readDatabases.ts @@ -12,14 +12,14 @@ import { sendNotificationForError } from "./sendNotificationForError"; import { userContext } from "../../UserContext"; export async function readDatabases(): Promise { - if (userContext.defaultExperience === DefaultAccountExperienceType.Table) { - return [{ id: "TablesDB" } as DataModels.Database]; - } - let databases: DataModels.Database[]; const clearMessage = logConsoleProgress(`Querying databases`); try { - if (window.authType === AuthType.AAD && !userContext.useSDKOperations) { + if ( + window.authType === AuthType.AAD && + !userContext.useSDKOperations && + userContext.defaultExperience !== DefaultAccountExperienceType.Table + ) { databases = await readDatabasesWithARM(); } else { const sdkResponse = await client() diff --git a/src/Common/dataAccess/updateOffer.ts b/src/Common/dataAccess/updateOffer.ts index 3b276bb50..7d7758381 100644 --- a/src/Common/dataAccess/updateOffer.ts +++ b/src/Common/dataAccess/updateOffer.ts @@ -406,10 +406,14 @@ const updateOfferWithSDK = async (params: UpdateOfferParams): Promise => const options: RequestOptions = {}; if (params.migrateToAutoPilot) { - options.initialHeaders[HttpHeaders.migrateOfferToAutopilot] = "true"; + options.initialHeaders = { + [HttpHeaders.migrateOfferToAutopilot]: "true" + }; delete newOffer.content.offerAutopilotSettings; } else if (params.migrateToManual) { - options.initialHeaders[HttpHeaders.migrateOfferToManualThroughput] = "true"; + options.initialHeaders = { + [HttpHeaders.migrateOfferToManualThroughput]: "true" + }; newOffer.content.offerAutopilotSettings = { maxThroughput: 0 }; }