From f3501d8cb8b3cb3bd5e9815555c70f76e326beb7 Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Mon, 28 Oct 2024 14:36:08 -0400 Subject: [PATCH] Remove old backend references --- src/Common/Constants.ts | 33 -- src/Common/CosmosClient.ts | 35 +- src/Common/MongoProxyClient.test.ts | 4 +- src/Common/MongoProxyClient.ts | 420 +----------------- src/ConfigContext.ts | 25 +- src/Contracts/ViewModels.ts | 1 - src/Explorer/Notebook/useNotebook.ts | 5 +- .../QueryCopilot/Shared/QueryCopilotClient.ts | 8 +- src/Explorer/Tables/TableDataClient.ts | 199 +-------- .../Tabs/DocumentsTabV2/DocumentsTabV2.tsx | 36 +- .../MongoShellTab/MongoShellTabComponent.tsx | 21 +- .../MongoShellTab/getMongoShellUrl.test.ts | 12 +- .../Tabs/MongoShellTab/getMongoShellUrl.ts | 4 +- src/Explorer/Tabs/Tabs.tsx | 74 --- .../Hosted/Components/ConnectExplorer.tsx | 27 +- src/Utils/EndpointUtils.ts | 95 +--- src/hooks/useKnockoutExplorer.ts | 29 +- src/hooks/usePortalAccessToken.tsx | 28 +- 18 files changed, 41 insertions(+), 1015 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index 7459df960..246e07653 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -130,15 +130,6 @@ export enum MongoBackendEndpointType { remote, } -export class BackendApi { - public static readonly GenerateToken: string = "GenerateToken"; - public static readonly PortalSettings: string = "PortalSettings"; - public static readonly AccountRestrictions: string = "AccountRestrictions"; - public static readonly RuntimeProxy: string = "RuntimeProxy"; - public static readonly DisallowedLocations: string = "DisallowedLocations"; - public static readonly SampleData: string = "SampleData"; -} - export class PortalBackendEndpoints { public static readonly Development: string = "https://localhost:7235"; public static readonly Mpac: string = "https://cdb-ms-mpac-pbe.cosmos.azure.com"; @@ -155,18 +146,6 @@ export class MongoProxyEndpoints { public static readonly Mooncake: string = "https://cdb-mc-prod-mp.cosmos.azure.cn"; } -export class MongoProxyApi { - public static readonly ResourceList: string = "ResourceList"; - public static readonly QueryDocuments: string = "QueryDocuments"; - public static readonly CreateDocument: string = "CreateDocument"; - public static readonly ReadDocument: string = "ReadDocument"; - public static readonly UpdateDocument: string = "UpdateDocument"; - public static readonly DeleteDocument: string = "DeleteDocument"; - public static readonly CreateCollectionWithProxy: string = "CreateCollectionWithProxy"; - public static readonly LegacyMongoShell: string = "LegacyMongoShell"; - public static readonly BulkDelete: string = "BulkDelete"; -} - export class CassandraProxyEndpoints { public static readonly Development: string = "https://localhost:7240"; public static readonly Mpac: string = "https://cdb-ms-mpac-cp.cosmos.azure.com"; @@ -175,18 +154,6 @@ export class CassandraProxyEndpoints { public static readonly Mooncake: string = "https://cdb-mc-prod-cp.cosmos.azure.cn"; } -//TODO: Remove this when new backend is migrated over -export class CassandraBackend { - public static readonly createOrDeleteApi: string = "api/cassandra/createordelete"; - public static readonly guestCreateOrDeleteApi: string = "api/guest/cassandra/createordelete"; - public static readonly queryApi: string = "api/cassandra"; - public static readonly guestQueryApi: string = "api/guest/cassandra"; - public static readonly keysApi: string = "api/cassandra/keys"; - public static readonly guestKeysApi: string = "api/guest/cassandra/keys"; - public static readonly schemaApi: string = "api/cassandra/schema"; - public static readonly guestSchemaApi: string = "api/guest/cassandra/schema"; -} - export class CassandraProxyAPIs { public static readonly createOrDeleteApi: string = "api/cassandra/createordelete"; public static readonly connectionStringCreateOrDeleteApi: string = "api/connectionstring/cassandra/createordelete"; diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index f7a4fbfc5..1e81dffb4 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -3,9 +3,8 @@ import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizatio import { AuthorizationToken } from "Contracts/FabricMessageTypes"; import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil"; import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; -import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils"; import { AuthType } from "../AuthType"; -import { BackendApi, PriorityLevel } from "../Common/Constants"; +import { PriorityLevel } from "../Common/Constants"; import * as Logger from "../Common/Logger"; import { Platform, configContext } from "../ConfigContext"; import { userContext } from "../UserContext"; @@ -125,10 +124,6 @@ export async function getTokenFromAuthService( resourceType: string, resourceId?: string, ): Promise { - if (!useNewPortalBackendEndpoint(BackendApi.RuntimeProxy)) { - return getTokenFromAuthService_ToBeDeprecated(verb, resourceType, resourceId); - } - try { const host: string = configContext.PORTAL_BACKEND_ENDPOINT; const response: Response = await _global.fetch(host + "/api/connectionstring/runtimeproxy/authorizationtokens", { @@ -151,34 +146,6 @@ export async function getTokenFromAuthService( } } -export async function getTokenFromAuthService_ToBeDeprecated( - verb: string, - resourceType: string, - resourceId?: string, -): Promise { - try { - const host = configContext.BACKEND_ENDPOINT; - const response = await _global.fetch(host + "/api/guest/runtimeproxy/authorizationTokens", { - method: "POST", - headers: { - "content-type": "application/json", - "x-ms-encrypted-auth-token": userContext.accessToken, - }, - body: JSON.stringify({ - verb, - resourceType, - resourceId, - }), - }); - //TODO I am not sure why we have to parse the JSON again here. fetch should do it for us when we call .json() - const result = JSON.parse(await response.json()); - return result; - } catch (error) { - logConsoleError(`Failed to get authorization headers for ${resourceType}: ${getErrorMessage(error)}`); - return Promise.reject(error); - } -} - // The Capability is a bitmap, which cosmosdb backend decodes as per the below enum enum SDKSupportedCapabilities { None = 0, diff --git a/src/Common/MongoProxyClient.test.ts b/src/Common/MongoProxyClient.test.ts index a63190651..4062905ae 100644 --- a/src/Common/MongoProxyClient.test.ts +++ b/src/Common/MongoProxyClient.test.ts @@ -295,12 +295,12 @@ describe("MongoProxyClient", () => { }); it("returns a local endpoint", () => { - const endpoint = getFeatureEndpointOrDefault("readDocument"); + const endpoint = getFeatureEndpointOrDefault(); expect(endpoint).toEqual(`${configContext.MONGO_PROXY_ENDPOINT}/api/mongo/explorer`); }); it("returns a production endpoint", () => { - const endpoint = getFeatureEndpointOrDefault("DeleteDocument"); + const endpoint = getFeatureEndpointOrDefault(); expect(endpoint).toEqual(`${configContext.MONGO_PROXY_ENDPOINT}/api/mongo/explorer`); }); }); diff --git a/src/Common/MongoProxyClient.ts b/src/Common/MongoProxyClient.ts index 0513d48cc..e0454b52b 100644 --- a/src/Common/MongoProxyClient.ts +++ b/src/Common/MongoProxyClient.ts @@ -1,20 +1,13 @@ import { Constants as CosmosSDKConstants } from "@azure/cosmos"; -import { - allowedMongoProxyEndpoints_ToBeDeprecated, - defaultAllowedMongoProxyEndpoints, - validateEndpoint, -} from "Utils/EndpointUtils"; -import queryString from "querystring"; import { AuthType } from "../AuthType"; import { configContext } from "../ConfigContext"; import * as DataModels from "../Contracts/DataModels"; import { MessageTypes } from "../Contracts/ExplorerContracts"; import { Collection } from "../Contracts/ViewModels"; import DocumentId from "../Explorer/Tree/DocumentId"; -import { hasFlag } from "../Platform/Hosted/extractFeatures"; import { userContext } from "../UserContext"; import { logConsoleError } from "../Utils/NotificationConsoleUtils"; -import { ApiType, ContentType, HttpHeaders, HttpStatusCodes, MongoProxyApi, MongoProxyEndpoints } from "./Constants"; +import { ApiType, ContentType, HttpHeaders, HttpStatusCodes } from "./Constants"; import { MinimalQueryIterator } from "./IteratorUtilities"; import { sendMessage } from "./MessageHandler"; @@ -67,10 +60,6 @@ export function queryDocuments( query: string, continuationToken?: string, ): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.ResourceList) || !useMongoProxyEndpoint(MongoProxyApi.QueryDocuments)) { - return queryDocuments_ToBeDeprecated(databaseId, collection, isResourceList, query, continuationToken); - } - const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const params = { @@ -89,7 +78,7 @@ export function queryDocuments( query, }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.ResourceList) || ""; + const endpoint = getFeatureEndpointOrDefault(); const headers = { ...defaultHeaders, @@ -127,76 +116,11 @@ export function queryDocuments( }); } -function queryDocuments_ToBeDeprecated( - databaseId: string, - collection: Collection, - isResourceList: boolean, - query: string, - continuationToken?: string, -): Promise { - const { databaseAccount } = userContext; - const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; - const params = { - db: databaseId, - coll: collection.id(), - resourceUrl: `${resourceEndpoint}dbs/${databaseId}/colls/${collection.id()}/docs/`, - rid: collection.rid, - rtype: "docs", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - pk: - collection && collection.partitionKey && !collection.partitionKey.systemKey - ? collection.partitionKeyProperties?.[0] - : "", - }; - - const endpoint = getFeatureEndpointOrDefault("resourcelist") || ""; - - const headers = { - ...defaultHeaders, - ...authHeaders(), - [CosmosSDKConstants.HttpHeaders.IsQuery]: "true", - [CosmosSDKConstants.HttpHeaders.PopulateQueryMetrics]: "true", - [CosmosSDKConstants.HttpHeaders.EnableScanInQuery]: "true", - [CosmosSDKConstants.HttpHeaders.EnableCrossPartitionQuery]: "true", - [CosmosSDKConstants.HttpHeaders.ParallelizeCrossPartitionQuery]: "true", - [HttpHeaders.contentType]: "application/query+json", - }; - - if (continuationToken) { - headers[CosmosSDKConstants.HttpHeaders.Continuation] = continuationToken; - } - - const path = isResourceList ? "/resourcelist" : ""; - - return window - .fetch(`${endpoint}${path}?${queryString.stringify(params)}`, { - method: "POST", - body: JSON.stringify({ query }), - headers, - }) - .then(async (response) => { - if (response.ok) { - return { - continuationToken: response.headers.get(CosmosSDKConstants.HttpHeaders.Continuation), - documents: (await response.json()).Documents as DataModels.DocumentId[], - headers: response.headers, - }; - } - await errorHandling(response, "querying documents", params); - return undefined; - }); -} - export function readDocument( databaseId: string, collection: Collection, documentId: DocumentId, ): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.ReadDocument)) { - return readDocument_ToBeDeprecated(databaseId, collection, documentId); - } const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const idComponents = documentId.self.split("/"); @@ -217,7 +141,7 @@ export function readDocument( : "", }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.ReadDocument); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(endpoint, { @@ -237,61 +161,12 @@ export function readDocument( }); } -export function readDocument_ToBeDeprecated( - databaseId: string, - collection: Collection, - documentId: DocumentId, -): Promise { - const { databaseAccount } = userContext; - const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; - const idComponents = documentId.self.split("/"); - const path = idComponents.slice(0, 4).join("/"); - const rid = encodeURIComponent(idComponents[5]); - const params = { - db: databaseId, - coll: collection.id(), - resourceUrl: `${resourceEndpoint}${path}/${rid}`, - rid, - rtype: "docs", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - pk: - documentId && documentId.partitionKey && !documentId.partitionKey.systemKey - ? documentId.partitionKeyProperties?.[0] - : "", - }; - - const endpoint = getFeatureEndpointOrDefault("readDocument"); - - return window - .fetch(`${endpoint}?${queryString.stringify(params)}`, { - method: "GET", - headers: { - ...defaultHeaders, - ...authHeaders(), - [CosmosSDKConstants.HttpHeaders.PartitionKey]: encodeURIComponent( - JSON.stringify(documentId.partitionKeyHeader()), - ), - }, - }) - .then(async (response) => { - if (response.ok) { - return response.json(); - } - return await errorHandling(response, "reading document", params); - }); -} - export function createDocument( databaseId: string, collection: Collection, partitionKeyProperty: string, documentContent: unknown, ): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.CreateDocument)) { - return createDocument_ToBeDeprecated(databaseId, collection, partitionKeyProperty, documentContent); - } const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const params = { @@ -308,7 +183,7 @@ export function createDocument( documentContent: JSON.stringify(documentContent), }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.CreateDocument); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(`${endpoint}/createDocument`, { @@ -328,54 +203,12 @@ export function createDocument( }); } -export function createDocument_ToBeDeprecated( - databaseId: string, - collection: Collection, - partitionKeyProperty: string, - documentContent: unknown, -): Promise { - const { databaseAccount } = userContext; - const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; - const params = { - db: databaseId, - coll: collection.id(), - resourceUrl: `${resourceEndpoint}dbs/${databaseId}/colls/${collection.id()}/docs/`, - rid: collection.rid, - rtype: "docs", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - pk: collection && collection.partitionKey && !collection.partitionKey.systemKey ? partitionKeyProperty : "", - }; - - const endpoint = getFeatureEndpointOrDefault("createDocument"); - - return window - .fetch(`${endpoint}/resourcelist?${queryString.stringify(params)}`, { - method: "POST", - body: JSON.stringify(documentContent), - headers: { - ...defaultHeaders, - ...authHeaders(), - }, - }) - .then(async (response) => { - if (response.ok) { - return response.json(); - } - return await errorHandling(response, "creating document", params); - }); -} - export function updateDocument( databaseId: string, collection: Collection, documentId: DocumentId, documentContent: string, ): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.UpdateDocument)) { - return updateDocument_ToBeDeprecated(databaseId, collection, documentId, documentContent); - } const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const idComponents = documentId.self.split("/"); @@ -396,7 +229,7 @@ export function updateDocument( : "", documentContent, }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.UpdateDocument); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(endpoint, { @@ -417,56 +250,7 @@ export function updateDocument( }); } -export function updateDocument_ToBeDeprecated( - databaseId: string, - collection: Collection, - documentId: DocumentId, - documentContent: string, -): Promise { - const { databaseAccount } = userContext; - const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; - const idComponents = documentId.self.split("/"); - const path = idComponents.slice(0, 5).join("/"); - const rid = encodeURIComponent(idComponents[5]); - const params = { - db: databaseId, - coll: collection.id(), - resourceUrl: `${resourceEndpoint}${path}/${rid}`, - rid, - rtype: "docs", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - pk: - documentId && documentId.partitionKey && !documentId.partitionKey.systemKey - ? documentId.partitionKeyProperties?.[0] - : "", - }; - const endpoint = getFeatureEndpointOrDefault("updateDocument"); - - return window - .fetch(`${endpoint}?${queryString.stringify(params)}`, { - method: "PUT", - body: documentContent, - headers: { - ...defaultHeaders, - ...authHeaders(), - [HttpHeaders.contentType]: ContentType.applicationJson, - [CosmosSDKConstants.HttpHeaders.PartitionKey]: JSON.stringify(documentId.partitionKeyHeader()), - }, - }) - .then(async (response) => { - if (response.ok) { - return response.json(); - } - return await errorHandling(response, "updating document", params); - }); -} - export function deleteDocument(databaseId: string, collection: Collection, documentId: DocumentId): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.DeleteDocument)) { - return deleteDocument_ToBeDeprecated(databaseId, collection, documentId); - } const { databaseAccount } = userContext; const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; const idComponents = documentId.self.split("/"); @@ -486,7 +270,7 @@ export function deleteDocument(databaseId: string, collection: Collection, docum ? documentId.partitionKeyProperties?.[0] : "", }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.DeleteDocument); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(endpoint, { @@ -506,50 +290,6 @@ export function deleteDocument(databaseId: string, collection: Collection, docum }); } -export function deleteDocument_ToBeDeprecated( - databaseId: string, - collection: Collection, - documentId: DocumentId, -): Promise { - const { databaseAccount } = userContext; - const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; - const idComponents = documentId.self.split("/"); - const path = idComponents.slice(0, 5).join("/"); - const rid = encodeURIComponent(idComponents[5]); - const params = { - db: databaseId, - coll: collection.id(), - resourceUrl: `${resourceEndpoint}${path}/${rid}`, - rid, - rtype: "docs", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - pk: - documentId && documentId.partitionKey && !documentId.partitionKey.systemKey - ? documentId.partitionKeyProperties?.[0] - : "", - }; - const endpoint = getFeatureEndpointOrDefault("deleteDocument"); - - return window - .fetch(`${endpoint}?${queryString.stringify(params)}`, { - method: "DELETE", - headers: { - ...defaultHeaders, - ...authHeaders(), - [HttpHeaders.contentType]: ContentType.applicationJson, - [CosmosSDKConstants.HttpHeaders.PartitionKey]: JSON.stringify(documentId.partitionKeyHeader()), - }, - }) - .then(async (response) => { - if (response.ok) { - return undefined; - } - return await errorHandling(response, "deleting document", params); - }); -} - export function deleteDocuments( databaseId: string, collection: Collection, @@ -575,7 +315,7 @@ export function deleteDocuments( resourceGroup: userContext.resourceGroup, databaseAccountName: databaseAccount.name, }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.BulkDelete); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(`${endpoint}/bulkdelete`, { @@ -599,9 +339,6 @@ export function deleteDocuments( export function createMongoCollectionWithProxy( params: DataModels.CreateCollectionParams, ): Promise { - if (!useMongoProxyEndpoint(MongoProxyApi.CreateCollectionWithProxy)) { - return createMongoCollectionWithProxy_ToBeDeprecated(params); - } const { databaseAccount } = userContext; const shardKey: string = params.partitionKey?.paths[0]; @@ -622,7 +359,7 @@ export function createMongoCollectionWithProxy( isSharded: !!shardKey, }; - const endpoint = getFeatureEndpointOrDefault(MongoProxyApi.CreateCollectionWithProxy); + const endpoint = getFeatureEndpointOrDefault(); return window .fetch(`${endpoint}/createCollection`, { @@ -642,67 +379,8 @@ export function createMongoCollectionWithProxy( }); } -export function createMongoCollectionWithProxy_ToBeDeprecated( - params: DataModels.CreateCollectionParams, -): Promise { - const { databaseAccount } = userContext; - const shardKey: string = params.partitionKey?.paths[0]; - const mongoParams: DataModels.MongoParameters = { - resourceUrl: databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint, - db: params.databaseId, - coll: params.collectionId, - pk: shardKey, - offerThroughput: params.autoPilotMaxThroughput || params.offerThroughput, - cd: params.createNewDatabase, - st: params.databaseLevelThroughput, - is: !!shardKey, - rid: "", - rtype: "colls", - sid: userContext.subscriptionId, - rg: userContext.resourceGroup, - dba: databaseAccount.name, - isAutoPilot: !!params.autoPilotMaxThroughput, - }; - - const endpoint = getFeatureEndpointOrDefault("createCollectionWithProxy"); - - return window - .fetch( - `${endpoint}/createCollection?${queryString.stringify( - mongoParams as unknown as queryString.ParsedUrlQueryInput, - )}`, - { - method: "POST", - headers: { - ...defaultHeaders, - ...authHeaders(), - [HttpHeaders.contentType]: "application/json", - }, - }, - ) - .then(async (response) => { - if (response.ok) { - return response.json(); - } - return await errorHandling(response, "creating collection", mongoParams); - }); -} -export function getFeatureEndpointOrDefault(feature: string): string { - let endpoint; - if (useMongoProxyEndpoint(feature)) { - endpoint = configContext.MONGO_PROXY_ENDPOINT; - } else { - const allowedMongoProxyEndpoints = configContext.allowedMongoProxyEndpoints || [ - ...defaultAllowedMongoProxyEndpoints, - ...allowedMongoProxyEndpoints_ToBeDeprecated, - ]; - endpoint = - hasFlag(userContext.features.mongoProxyAPIs, feature) && - validateEndpoint(userContext.features.mongoProxyEndpoint, allowedMongoProxyEndpoints) - ? userContext.features.mongoProxyEndpoint - : configContext.MONGO_BACKEND_ENDPOINT || configContext.BACKEND_ENDPOINT; - } - +export function getFeatureEndpointOrDefault(): string { + const endpoint: string = configContext.MONGO_PROXY_ENDPOINT; return getEndpoint(endpoint); } @@ -719,84 +397,6 @@ export function getEndpoint(endpoint: string): string { return url; } -export function useMongoProxyEndpoint(mongoProxyApi: string): boolean { - const mongoProxyEnvironmentMap: { [key: string]: string[] } = { - [MongoProxyApi.ResourceList]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.QueryDocuments]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.CreateDocument]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.ReadDocument]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.UpdateDocument]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.DeleteDocument]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.CreateCollectionWithProxy]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.LegacyMongoShell]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - [MongoProxyApi.BulkDelete]: [ - MongoProxyEndpoints.Local, - MongoProxyEndpoints.Mpac, - MongoProxyEndpoints.Prod, - MongoProxyEndpoints.Fairfax, - MongoProxyEndpoints.Mooncake, - ], - }; - - if (!mongoProxyEnvironmentMap[mongoProxyApi] || !configContext.MONGO_PROXY_ENDPOINT) { - return false; - } - - if (configContext.globallyEnabledMongoAPIs.includes(mongoProxyApi)) { - return true; - } - - return mongoProxyEnvironmentMap[mongoProxyApi].includes(configContext.MONGO_PROXY_ENDPOINT); -} - export class ThrottlingError extends Error { constructor(message: string) { super(message); diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index 113a6d5e5..039db4863 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -1,10 +1,4 @@ -import { - BackendApi, - CassandraProxyEndpoints, - JunoEndpoints, - MongoProxyEndpoints, - PortalBackendEndpoints, -} from "Common/Constants"; +import { CassandraProxyEndpoints, JunoEndpoints, MongoProxyEndpoints, PortalBackendEndpoints } from "Common/Constants"; import { allowedAadEndpoints, allowedArcadiaEndpoints, @@ -15,7 +9,6 @@ import { allowedMongoBackendEndpoints, allowedMsalRedirectEndpoints, defaultAllowedArmEndpoints, - defaultAllowedBackendEndpoints, defaultAllowedCassandraProxyEndpoints, defaultAllowedMongoProxyEndpoints, validateEndpoint, @@ -31,7 +24,6 @@ export enum Platform { export interface ConfigContext { platform: Platform; allowedArmEndpoints: ReadonlyArray; - allowedBackendEndpoints: ReadonlyArray; allowedCassandraProxyEndpoints: ReadonlyArray; allowedMongoProxyEndpoints: ReadonlyArray; allowedParentFrameOrigins: ReadonlyArray; @@ -50,13 +42,10 @@ export interface ConfigContext { CATALOG_API_KEY: string; ARCADIA_ENDPOINT: string; ARCADIA_LIVY_ENDPOINT_DNS_ZONE: string; - BACKEND_ENDPOINT?: string; PORTAL_BACKEND_ENDPOINT: string; - NEW_BACKEND_APIS?: BackendApi[]; MONGO_BACKEND_ENDPOINT?: string; MONGO_PROXY_ENDPOINT: string; CASSANDRA_PROXY_ENDPOINT: string; - NEW_CASSANDRA_APIS?: string[]; PROXY_PATH?: string; JUNO_ENDPOINT: string; GITHUB_CLIENT_ID: string; @@ -75,7 +64,6 @@ export interface ConfigContext { let configContext: Readonly = { platform: Platform.Portal, allowedArmEndpoints: defaultAllowedArmEndpoints, - allowedBackendEndpoints: defaultAllowedBackendEndpoints, allowedCassandraProxyEndpoints: defaultAllowedCassandraProxyEndpoints, allowedMongoProxyEndpoints: defaultAllowedMongoProxyEndpoints, allowedParentFrameOrigins: [ @@ -109,11 +97,9 @@ let configContext: Readonly = { GITHUB_CLIENT_ID: "6cb2f63cf6f7b5cbdeca", // Registered OAuth app: https://github.com/organizations/AzureCosmosDBNotebooks/settings/applications/1189306 GITHUB_TEST_ENV_CLIENT_ID: "b63fc8cbf87fd3c6e2eb", // Registered OAuth app: https://github.com/organizations/AzureCosmosDBNotebooks/settings/applications/1777772 JUNO_ENDPOINT: JunoEndpoints.Prod, - BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com", PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod, MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod, CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Prod, - NEW_CASSANDRA_APIS: ["postQuery", "createOrDelete", "getKeys", "getSchema"], isTerminalEnabled: false, isPhoenixEnabled: false, globallyEnabledCassandraAPIs: [], @@ -152,15 +138,6 @@ export function updateConfigContext(newContext: Partial): void { delete newContext.ARCADIA_ENDPOINT; } - if ( - !validateEndpoint( - newContext.BACKEND_ENDPOINT, - configContext.allowedBackendEndpoints || defaultAllowedBackendEndpoints, - ) - ) { - delete newContext.BACKEND_ENDPOINT; - } - if ( !validateEndpoint( newContext.MONGO_PROXY_ENDPOINT, diff --git a/src/Contracts/ViewModels.ts b/src/Contracts/ViewModels.ts index 09e03b2d6..1ea283913 100644 --- a/src/Contracts/ViewModels.ts +++ b/src/Contracts/ViewModels.ts @@ -390,7 +390,6 @@ export interface DataExplorerInputsFrame { csmEndpoint?: string; dnsSuffix?: string; serverId?: string; - extensionEndpoint?: string; portalBackendEndpoint?: string; mongoProxyEndpoint?: string; cassandraProxyEndpoint?: string; diff --git a/src/Explorer/Notebook/useNotebook.ts b/src/Explorer/Notebook/useNotebook.ts index a0f6efbf0..64acb2e3f 100644 --- a/src/Explorer/Notebook/useNotebook.ts +++ b/src/Explorer/Notebook/useNotebook.ts @@ -1,6 +1,5 @@ import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility"; import { PhoenixClient } from "Phoenix/PhoenixClient"; -import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils"; import { cloneDeep } from "lodash"; import create, { UseStore } from "zustand"; import { AuthType } from "../../AuthType"; @@ -128,9 +127,7 @@ export const useNotebook: UseStore = create((set, get) => ({ userContext.apiType === "Postgres" || userContext.apiType === "VCoreMongo" ? databaseAccount?.location : databaseAccount?.properties?.writeLocations?.[0]?.locationName.toLowerCase(); - const disallowedLocationsUri: string = useNewPortalBackendEndpoint(Constants.BackendApi.DisallowedLocations) - ? `${configContext.PORTAL_BACKEND_ENDPOINT}/api/disallowedlocations` - : `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`; + const disallowedLocationsUri: string = `${configContext.PORTAL_BACKEND_ENDPOINT}/api/disallowedlocations`; const authorizationHeader = getAuthorizationHeader(); try { const response = await fetch(disallowedLocationsUri, { diff --git a/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts b/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts index 5d187be85..394d44036 100644 --- a/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts +++ b/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts @@ -1,7 +1,6 @@ import { FeedOptions } from "@azure/cosmos"; import { Areas, - BackendApi, ConnectionStatusType, ContainerStatusType, HttpStatusCodes, @@ -32,7 +31,6 @@ import { Action } from "Shared/Telemetry/TelemetryConstants"; import { traceFailure, traceStart, traceSuccess } from "Shared/Telemetry/TelemetryProcessor"; import { userContext } from "UserContext"; import { getAuthorizationHeader } from "Utils/AuthorizationUtils"; -import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils"; import { queryPagesUntilContentPresent } from "Utils/QueryUtils"; import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot"; import { useTabs } from "hooks/useTabs"; @@ -82,11 +80,7 @@ export const isCopilotFeatureRegistered = async (subscriptionId: string): Promis }; export const getCopilotEnabled = async (): Promise => { - const backendEndpoint: string = useNewPortalBackendEndpoint(BackendApi.PortalSettings) - ? configContext.PORTAL_BACKEND_ENDPOINT - : configContext.BACKEND_ENDPOINT; - - const url = `${backendEndpoint}/api/portalsettings/querycopilot`; + const url = `${configContext.PORTAL_BACKEND_ENDPOINT}/api/portalsettings/querycopilot`; const authorizationHeader: AuthorizationTokenHeaderMetadata = getAuthorizationHeader(); const headers = { [authorizationHeader.header]: authorizationHeader.token }; diff --git a/src/Explorer/Tables/TableDataClient.ts b/src/Explorer/Tables/TableDataClient.ts index 8e652d6b0..a842e9986 100644 --- a/src/Explorer/Tables/TableDataClient.ts +++ b/src/Explorer/Tables/TableDataClient.ts @@ -3,7 +3,7 @@ import * as ko from "knockout"; import Q from "q"; import { AuthType } from "../../AuthType"; import * as Constants from "../../Common/Constants"; -import { CassandraProxyAPIs, CassandraProxyEndpoints } from "../../Common/Constants"; +import { CassandraProxyAPIs } from "../../Common/Constants"; import { handleError } from "../../Common/ErrorHandlingUtils"; import * as HeadersUtility from "../../Common/HeadersUtility"; import { createDocument } from "../../Common/dataAccess/createDocument"; @@ -264,9 +264,6 @@ export class CassandraAPIDataClient extends TableDataClient { shouldNotify?: boolean, paginationToken?: string, ): Promise { - if (!this.useCassandraProxyEndpoint("postQuery")) { - return this.queryDocuments_ToBeDeprecated(collection, query, shouldNotify, paginationToken); - } const clearMessage = shouldNotify && NotificationConsoleUtils.logConsoleProgress(`Querying rows for table ${collection.id()}`); try { @@ -309,55 +306,6 @@ export class CassandraAPIDataClient extends TableDataClient { } } - public async queryDocuments_ToBeDeprecated( - collection: ViewModels.Collection, - query: string, - shouldNotify?: boolean, - paginationToken?: string, - ): Promise { - const clearMessage = - shouldNotify && NotificationConsoleUtils.logConsoleProgress(`Querying rows for table ${collection.id()}`); - try { - const { authType, databaseAccount } = userContext; - const apiEndpoint: string = - authType === AuthType.EncryptedToken - ? Constants.CassandraBackend.guestQueryApi - : Constants.CassandraBackend.queryApi; - const data: any = await $.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, { - type: "POST", - data: { - accountName: databaseAccount?.name, - cassandraEndpoint: this.trimCassandraEndpoint(databaseAccount?.properties.cassandraEndpoint), - resourceId: databaseAccount?.id, - keyspaceId: collection.databaseId, - tableId: collection.id(), - query, - paginationToken, - }, - beforeSend: this.setAuthorizationHeader as any, - cache: false, - }); - shouldNotify && - NotificationConsoleUtils.logConsoleInfo( - `Successfully fetched ${data.result.length} rows for table ${collection.id()}`, - ); - return { - Results: data.result, - ContinuationToken: data.paginationToken, - }; - } catch (error) { - shouldNotify && - handleError( - error, - "QueryDocuments_ToBeDeprecated_Cassandra", - `Failed to query rows for table ${collection.id()}`, - ); - throw error; - } finally { - clearMessage?.(); - } - } - public async deleteDocuments( collection: ViewModels.Collection, entitiesToDelete: Entities.ITableEntity[], @@ -471,10 +419,6 @@ export class CassandraAPIDataClient extends TableDataClient { } public getTableKeys(collection: ViewModels.Collection): Q.Promise { - if (!this.useCassandraProxyEndpoint("getKeys")) { - return this.getTableKeys_ToBeDeprecated(collection); - } - if (!!collection.cassandraKeys) { return Q.resolve(collection.cassandraKeys); } @@ -515,52 +459,7 @@ export class CassandraAPIDataClient extends TableDataClient { return deferred.promise; } - public getTableKeys_ToBeDeprecated(collection: ViewModels.Collection): Q.Promise { - if (!!collection.cassandraKeys) { - return Q.resolve(collection.cassandraKeys); - } - const clearInProgressMessage = logConsoleProgress(`Fetching keys for table ${collection.id()}`); - const { authType, databaseAccount } = userContext; - const apiEndpoint: string = - authType === AuthType.EncryptedToken - ? Constants.CassandraBackend.guestKeysApi - : Constants.CassandraBackend.keysApi; - let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`; - const deferred = Q.defer(); - - $.ajax(endpoint, { - type: "POST", - data: { - accountName: databaseAccount?.name, - cassandraEndpoint: this.trimCassandraEndpoint(databaseAccount?.properties.cassandraEndpoint), - resourceId: databaseAccount?.id, - keyspaceId: collection.databaseId, - tableId: collection.id(), - }, - beforeSend: this.setAuthorizationHeader as any, - cache: false, - }) - .then( - (data: CassandraTableKeys) => { - collection.cassandraKeys = data; - logConsoleInfo(`Successfully fetched keys for table ${collection.id()}`); - deferred.resolve(data); - }, - (error: any) => { - const errorText = error.responseJSON?.message ?? JSON.stringify(error); - handleError(errorText, "FetchKeysCassandra", `Error fetching keys for table ${collection.id()}`); - deferred.reject(errorText); - }, - ) - .done(clearInProgressMessage); - return deferred.promise; - } - public getTableSchema(collection: ViewModels.Collection): Q.Promise { - if (!this.useCassandraProxyEndpoint("getSchema")) { - return this.getTableSchema_ToBeDeprecated(collection); - } - if (!!collection.cassandraSchema) { return Q.resolve(collection.cassandraSchema); } @@ -602,52 +501,7 @@ export class CassandraAPIDataClient extends TableDataClient { return deferred.promise; } - public getTableSchema_ToBeDeprecated(collection: ViewModels.Collection): Q.Promise { - if (!!collection.cassandraSchema) { - return Q.resolve(collection.cassandraSchema); - } - const clearInProgressMessage = logConsoleProgress(`Fetching schema for table ${collection.id()}`); - const { databaseAccount, authType } = userContext; - const apiEndpoint: string = - authType === AuthType.EncryptedToken - ? Constants.CassandraBackend.guestSchemaApi - : Constants.CassandraBackend.schemaApi; - let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`; - const deferred = Q.defer(); - - $.ajax(endpoint, { - type: "POST", - data: { - accountName: databaseAccount?.name, - cassandraEndpoint: this.trimCassandraEndpoint(databaseAccount?.properties.cassandraEndpoint), - resourceId: databaseAccount?.id, - keyspaceId: collection.databaseId, - tableId: collection.id(), - }, - beforeSend: this.setAuthorizationHeader as any, - cache: false, - }) - .then( - (data: any) => { - collection.cassandraSchema = data.columns; - logConsoleInfo(`Successfully fetched schema for table ${collection.id()}`); - deferred.resolve(data.columns); - }, - (error: any) => { - const errorText = error.responseJSON?.message ?? JSON.stringify(error); - handleError(errorText, "FetchSchemaCassandra", `Error fetching schema for table ${collection.id()}`); - deferred.reject(errorText); - }, - ) - .done(clearInProgressMessage); - return deferred.promise; - } - private createOrDeleteQuery(cassandraEndpoint: string, resourceId: string, query: string): Q.Promise { - if (!this.useCassandraProxyEndpoint("createOrDelete")) { - return this.createOrDeleteQuery_ToBeDeprecated(cassandraEndpoint, resourceId, query); - } - const deferred = Q.defer(); const { authType, databaseAccount } = userContext; const apiEndpoint: string = @@ -677,38 +531,6 @@ export class CassandraAPIDataClient extends TableDataClient { return deferred.promise; } - private createOrDeleteQuery_ToBeDeprecated( - cassandraEndpoint: string, - resourceId: string, - query: string, - ): Q.Promise { - const deferred = Q.defer(); - const { authType, databaseAccount } = userContext; - const apiEndpoint: string = - authType === AuthType.EncryptedToken - ? Constants.CassandraBackend.guestCreateOrDeleteApi - : Constants.CassandraBackend.createOrDeleteApi; - $.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, { - type: "POST", - data: { - accountName: databaseAccount?.name, - cassandraEndpoint: this.trimCassandraEndpoint(cassandraEndpoint), - resourceId: resourceId, - query: query, - }, - beforeSend: this.setAuthorizationHeader as any, - cache: false, - }).then( - (data: any) => { - deferred.resolve(); - }, - (reason) => { - deferred.reject(reason); - }, - ); - return deferred.promise; - } - private trimCassandraEndpoint(cassandraEndpoint: string): string { if (!cassandraEndpoint) { return cassandraEndpoint; @@ -747,23 +569,4 @@ export class CassandraAPIDataClient extends TableDataClient { private getCassandraPartitionKeyProperty(collection: ViewModels.Collection): string { return collection.cassandraKeys.partitionKeys[0].property; } - - private useCassandraProxyEndpoint(api: string): boolean { - const activeCassandraProxyEndpoints: string[] = [ - CassandraProxyEndpoints.Development, - CassandraProxyEndpoints.Mpac, - CassandraProxyEndpoints.Prod, - CassandraProxyEndpoints.Fairfax, - CassandraProxyEndpoints.Mooncake, - ]; - - if (configContext.globallyEnabledCassandraAPIs.includes(api)) { - return true; - } - - return ( - configContext.NEW_CASSANDRA_APIS?.includes(api) && - activeCassandraProxyEndpoints.includes(configContext.CASSANDRA_PROXY_ENDPOINT) - ); - } } diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx index d36f7cc4d..dad190dc8 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx @@ -1164,27 +1164,16 @@ export const DocumentsTabComponent: React.FunctionComponent [toDeleteDocumentIds[0]]); - // ---------------------------------------------------------------------------------------------------- - } else { - deletePromise = MongoProxyClient.deleteDocuments( - _collection.databaseId, - _collection as ViewModels.Collection, - toDeleteDocumentIds, - ).then(({ deletedCount, isAcknowledged }) => { - if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) { - return toDeleteDocumentIds; - } - throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`); - }); - } + deletePromise = MongoProxyClient.deleteDocuments( + _collection.databaseId, + _collection as ViewModels.Collection, + toDeleteDocumentIds, + ).then(({ deletedCount, isAcknowledged }) => { + if (deletedCount === toDeleteDocumentIds.length && isAcknowledged) { + return toDeleteDocumentIds; + } + throw new Error(`Delete failed with deletedCount: ${deletedCount} and isAcknowledged: ${isAcknowledged}`); + }); } return deletePromise @@ -2096,11 +2085,8 @@ export const DocumentsTabComponent: React.FunctionComponent { private _logTraces: Map; - private _useMongoProxyEndpoint: boolean; constructor(props: IMongoShellTabComponentProps) { super(props); this._logTraces = new Map(); - this._useMongoProxyEndpoint = useMongoProxyEndpoint(Constants.MongoProxyApi.LegacyMongoShell); this.state = { - url: getMongoShellUrl(this._useMongoProxyEndpoint), + url: getMongoShellUrl(), }; props.onMongoShellTabAccessor({ @@ -113,17 +109,8 @@ export default class MongoShellTabComponent extends Component< const resourceId = databaseAccount?.id; const accountName = databaseAccount?.name; const documentEndpoint = databaseAccount?.properties.mongoEndpoint || databaseAccount?.properties.documentEndpoint; - const mongoEndpoint = - documentEndpoint.substr( - Constants.MongoDBAccounts.protocol.length + 3, - documentEndpoint.length - - (Constants.MongoDBAccounts.protocol.length + 2 + Constants.MongoDBAccounts.defaultPort.length), - ) + Constants.MongoDBAccounts.defaultPort.toString(); const databaseId = this.props.collection.databaseId; const collectionId = this.props.collection.id(); - const apiEndpoint = this._useMongoProxyEndpoint - ? configContext.MONGO_PROXY_ENDPOINT - : configContext.BACKEND_ENDPOINT; const encryptedAuthToken: string = userContext.accessToken; shellIframe.contentWindow.postMessage( @@ -132,12 +119,12 @@ export default class MongoShellTabComponent extends Component< data: { resourceId: resourceId, accountName: accountName, - mongoEndpoint: this._useMongoProxyEndpoint ? documentEndpoint : mongoEndpoint, + mongoEndpoint: documentEndpoint, authorization: authorization, databaseId: databaseId, collectionId: collectionId, encryptedAuthToken: encryptedAuthToken, - apiEndpoint: apiEndpoint, + apiEndpoint: configContext.MONGO_PROXY_ENDPOINT, }, }, window.origin, diff --git a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.test.ts b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.test.ts index 8b16816ab..924b2eb13 100644 --- a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.test.ts +++ b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.test.ts @@ -2,8 +2,6 @@ import { Platform, resetConfigContext, updateConfigContext } from "../../../Conf import { updateUserContext, userContext } from "../../../UserContext"; import { getMongoShellUrl } from "./getMongoShellUrl"; -const mongoBackendEndpoint = "https://localhost:1234"; - describe("getMongoShellUrl", () => { let queryString = ""; @@ -11,7 +9,6 @@ describe("getMongoShellUrl", () => { resetConfigContext(); updateConfigContext({ - BACKEND_ENDPOINT: mongoBackendEndpoint, platform: Platform.Hosted, }); @@ -37,12 +34,7 @@ describe("getMongoShellUrl", () => { queryString = `resourceId=${userContext.databaseAccount.id}&accountName=${userContext.databaseAccount.name}&mongoEndpoint=${userContext.databaseAccount.properties.documentEndpoint}`; }); - it("should return /indexv2.html by default", () => { - expect(getMongoShellUrl().toString()).toContain(`/indexv2.html?${queryString}`); - }); - - it("should return /index.html when useMongoProxyEndpoint is true", () => { - const useMongoProxyEndpoint: boolean = true; - expect(getMongoShellUrl(useMongoProxyEndpoint).toString()).toContain(`/index.html?${queryString}`); + it("should return /index.html by default", () => { + expect(getMongoShellUrl().toString()).toContain(`/index.html?${queryString}`); }); }); diff --git a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts index a3b49b373..36f47ce74 100644 --- a/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts +++ b/src/Explorer/Tabs/MongoShellTab/getMongoShellUrl.ts @@ -1,11 +1,11 @@ import { userContext } from "../../../UserContext"; -export function getMongoShellUrl(useMongoProxyEndpoint?: boolean): string { +export function getMongoShellUrl(): string { const { databaseAccount: account } = userContext; const resourceId = account?.id; const accountName = account?.name; const mongoEndpoint = account?.properties?.mongoEndpoint || account?.properties?.documentEndpoint; const queryString = `resourceId=${resourceId}&accountName=${accountName}&mongoEndpoint=${mongoEndpoint}`; - return useMongoProxyEndpoint ? `/mongoshell/index.html?${queryString}` : `/mongoshell/indexv2.html?${queryString}`; + return `/mongoshell/index.html?${queryString}`; } diff --git a/src/Explorer/Tabs/Tabs.tsx b/src/Explorer/Tabs/Tabs.tsx index 3ee50992c..5ba78f2a3 100644 --- a/src/Explorer/Tabs/Tabs.tsx +++ b/src/Explorer/Tabs/Tabs.tsx @@ -1,8 +1,5 @@ import { IMessageBarStyles, MessageBar, MessageBarButton, MessageBarType } from "@fluentui/react"; -import { CassandraProxyEndpoints, MongoProxyEndpoints } from "Common/Constants"; import { sendMessage } from "Common/MessageHandler"; -import { configContext } from "ConfigContext"; -import { IpRule } from "Contracts/DataModels"; import { MessageTypes } from "Contracts/ExplorerContracts"; import { CollectionTabKind } from "Contracts/ViewModels"; import Explorer from "Explorer/Explorer"; @@ -17,7 +14,6 @@ import { VcoreMongoQuickstartTab } from "Explorer/Tabs/VCoreMongoQuickstartTab"; import { LayoutConstants } from "Explorer/Theme/ThemeUtil"; import { KeyboardAction, KeyboardActionGroup, useKeyboardActionGroup } from "KeyboardShortcuts"; import { userContext } from "UserContext"; -import { CassandraProxyOutboundIPs, MongoProxyOutboundIPs, PortalBackendIPs } from "Utils/EndpointUtils"; import { useTeachingBubble } from "hooks/useTeachingBubble"; import ko from "knockout"; import React, { MutableRefObject, useEffect, useRef, useState } from "react"; @@ -36,10 +32,6 @@ interface TabsProps { export const Tabs = ({ explorer }: TabsProps): JSX.Element => { const { openedTabs, openedReactTabs, activeTab, activeReactTab, networkSettingsWarning } = useTabs(); - const [ - showMongoAndCassandraProxiesNetworkSettingsWarningState, - setShowMongoAndCassandraProxiesNetworkSettingsWarningState, - ] = useState(showMongoAndCassandraProxiesNetworkSettingsWarning()); const setKeyboardHandlers = useKeyboardActionGroup(KeyboardActionGroup.TABS); useEffect(() => { @@ -83,18 +75,6 @@ export const Tabs = ({ explorer }: TabsProps): JSX.Element => { {networkSettingsWarning} )} - {showMongoAndCassandraProxiesNetworkSettingsWarningState && ( - { - setShowMongoAndCassandraProxiesNetworkSettingsWarningState(false); - }} - > - {`We have migrated our middleware to new infrastructure. To avoid issues with Data Explorer access, please - re-enable "Allow access from Azure Portal" on the Networking blade for your account.`} - - )}