From 39f7ef331aba2d37453645226d53ff86941d3de8 Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Wed, 14 Oct 2020 11:10:14 -0700 Subject: [PATCH] Use RP to read databases for all API (#280) Since I've cleaned up all the places that use `_rid` and `_self` of a database in my previous commit (https://github.com/Azure/cosmos-explorer/commit/d525afa14272ea3c7c90df2c20949aba2f145daa), we are safe to use RP to read databases for all APIs except Tables. For Tables API, since RP doesn't support any database level operations, I have to hardcode the read database response. The only property we need in the Tables database is the id which is the string that we display in the resource tree. --- src/Common/dataAccess/readDatabases.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Common/dataAccess/readDatabases.ts b/src/Common/dataAccess/readDatabases.ts index b106a4e06..e6a845abc 100644 --- a/src/Common/dataAccess/readDatabases.ts +++ b/src/Common/dataAccess/readDatabases.ts @@ -12,16 +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 && - userContext.defaultExperience !== DefaultAccountExperienceType.MongoDB && - userContext.defaultExperience !== DefaultAccountExperienceType.Table && - userContext.defaultExperience !== DefaultAccountExperienceType.Cassandra - ) { + if (window.authType === AuthType.AAD && !userContext.useSDKOperations) { databases = await readDatabasesWithARM(); } else { const sdkResponse = await client()