From a581a6dccb198c9c6e88a0f99fad08f14b8b4962 Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Mon, 8 Jul 2024 20:53:24 -0400 Subject: [PATCH] Mongo Shell and MS Graph CRI fixes --- src/Contracts/AzureResourceGraph.ts | 3 ++- .../MongoShellTab/MongoShellTabComponent.tsx | 9 ++++++++- src/hooks/useSubscriptions.tsx | 18 +++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Contracts/AzureResourceGraph.ts b/src/Contracts/AzureResourceGraph.ts index 52120dec5..18eeed5a8 100644 --- a/src/Contracts/AzureResourceGraph.ts +++ b/src/Contracts/AzureResourceGraph.ts @@ -1,7 +1,8 @@ export interface QueryRequestOptions { $skipToken?: string; $top?: number; - subscriptions: string[]; + $allowPartialScopes: boolean; + subscriptions?: string[]; } export interface QueryResponse { diff --git a/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx b/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx index 61907c90a..bcf8b7d05 100644 --- a/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx +++ b/src/Explorer/Tabs/MongoShellTab/MongoShellTabComponent.tsx @@ -1,5 +1,6 @@ import { useMongoProxyEndpoint } from "Common/MongoProxyClient"; import React, { Component } from "react"; +import * as Constants from "../../../Common/Constants"; import { configContext } from "../../../ConfigContext"; import * as ViewModels from "../../../Contracts/ViewModels"; import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; @@ -112,6 +113,12 @@ 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 @@ -125,7 +132,7 @@ export default class MongoShellTabComponent extends Component< data: { resourceId: resourceId, accountName: accountName, - mongoEndpoint: documentEndpoint, + mongoEndpoint: this._useMongoProxyEndpoint ? documentEndpoint : mongoEndpoint, authorization: authorization, databaseId: databaseId, collectionId: collectionId, diff --git a/src/hooks/useSubscriptions.tsx b/src/hooks/useSubscriptions.tsx index a8e4addf5..ca80a87f5 100644 --- a/src/hooks/useSubscriptions.tsx +++ b/src/hooks/useSubscriptions.tsx @@ -51,17 +51,13 @@ export async function fetchSubscriptionsFromGraph(accessToken: string): Promise< do { const body = { query: subscriptionsQuery, - ...(skipToken - ? { - options: { - $skipToken: skipToken, - } as QueryRequestOptions, - } - : { - options: { - $top: 150, - } as QueryRequestOptions, - }), + options: { + $allowPartialScopes: true, + $top: 150, + ...(skipToken && { + $skipToken: skipToken, + }), + } as QueryRequestOptions, }; const response = await fetch(managementResourceGraphAPIURL, {