mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-29 22:02:01 +00:00
Compare commits
20 Commits
fix-mongo-
...
users/sind
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22144982bd | ||
|
|
9274f50500 | ||
|
|
8b4d9bd354 | ||
|
|
2c78625f83 | ||
|
|
602a697fe9 | ||
|
|
28d8216b32 | ||
|
|
3b9261ef76 | ||
|
|
6be839991f | ||
|
|
72eca5ed79 | ||
|
|
473a6d34bd | ||
|
|
805d72c55b | ||
|
|
eb7c737066 | ||
|
|
478467bda5 | ||
|
|
fd3a83dcd8 | ||
|
|
713df1869a | ||
|
|
192a275139 | ||
|
|
77ee359adb | ||
|
|
a50108c375 | ||
|
|
d3fb5eabdb | ||
|
|
4792e2d1c7 |
@@ -186,9 +186,6 @@ export class CassandraProxyAPIs {
|
|||||||
export class Queries {
|
export class Queries {
|
||||||
public static CustomPageOption: string = "custom";
|
public static CustomPageOption: string = "custom";
|
||||||
public static UnlimitedPageOption: string = "unlimited";
|
public static UnlimitedPageOption: string = "unlimited";
|
||||||
public static setAutomaticRBACOption: string = "Automatic";
|
|
||||||
public static setTrueRBACOption: string = "True";
|
|
||||||
public static setFalseRBACOption: string = "False";
|
|
||||||
public static itemsPerPage: number = 100;
|
public static itemsPerPage: number = 100;
|
||||||
public static unlimitedItemsPerPage: number = 100; // TODO: Figure out appropriate value so it works for accounts with a large number of partitions
|
public static unlimitedItemsPerPage: number = 100; // TODO: Figure out appropriate value so it works for accounts with a large number of partitions
|
||||||
public static containersPerPage: number = 50;
|
public static containersPerPage: number = 50;
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import { getAuthorizationTokenUsingResourceTokens } from "Common/getAuthorizatio
|
|||||||
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
||||||
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
|
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
|
import { DatabaseAccountListKeysResult } from "Utils/arm/generatedClients/cosmos/types";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { PriorityLevel } from "../Common/Constants";
|
import { PriorityLevel } from "../Common/Constants";
|
||||||
import { Platform, configContext } from "../ConfigContext";
|
import { Platform, configContext } from "../ConfigContext";
|
||||||
import { userContext } from "../UserContext";
|
import { updateUserContext, userContext } from "../UserContext";
|
||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
||||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||||
@@ -29,15 +31,6 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
}
|
}
|
||||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
||||||
const authorizationToken = `${AUTH_PREFIX}${userContext.aadToken}`;
|
const authorizationToken = `${AUTH_PREFIX}${userContext.aadToken}`;
|
||||||
console.log(`Returning Auth token`);
|
|
||||||
return authorizationToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userContext.dataPlaneRbacEnabled && userContext.authorizationToken) {
|
|
||||||
console.log(` Getting Portal Auth token `);
|
|
||||||
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
|
|
||||||
const authorizationToken = `${AUTH_PREFIX}${userContext.authorizationToken}`;
|
|
||||||
console.log(`Returning Portal Auth token`);
|
|
||||||
return authorizationToken;
|
return authorizationToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +81,12 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let retryAttempts: number = 50;
|
||||||
|
while (retryAttempts > 0 && userContext.listKeysFetchInProgress) {
|
||||||
|
retryAttempts--;
|
||||||
|
await sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
if (userContext.masterKey) {
|
if (userContext.masterKey) {
|
||||||
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||||
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(
|
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(
|
||||||
@@ -98,6 +97,22 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
userContext.masterKey,
|
userContext.masterKey,
|
||||||
);
|
);
|
||||||
return decodeURIComponent(headers.authorization);
|
return decodeURIComponent(headers.authorization);
|
||||||
|
} else if (userContext.dataPlaneRbacEnabled == false) {
|
||||||
|
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
||||||
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
|
|
||||||
|
if (keys.primaryMasterKey) {
|
||||||
|
updateUserContext({ masterKey: keys.primaryMasterKey });
|
||||||
|
// TODO This SDK method mutates the headers object. Find a better one or fix the SDK.
|
||||||
|
await Cosmos.setAuthorizationTokenHeaderUsingMasterKey(
|
||||||
|
verb,
|
||||||
|
resourceId,
|
||||||
|
resourceType,
|
||||||
|
headers,
|
||||||
|
keys.primaryMasterKey,
|
||||||
|
);
|
||||||
|
return decodeURIComponent(headers.authorization);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userContext.resourceToken) {
|
if (userContext.resourceToken) {
|
||||||
@@ -109,6 +124,10 @@ export const tokenProvider = async (requestInfo: Cosmos.RequestInfo) => {
|
|||||||
return decodeURIComponent(result.PrimaryReadWriteToken);
|
return decodeURIComponent(result.PrimaryReadWriteToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function sleep(ms: number) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, diagnosticNode, next) => {
|
export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, diagnosticNode, next) => {
|
||||||
requestContext.endpoint = new URL(configContext.PROXY_PATH, window.location.href).href;
|
requestContext.endpoint = new URL(configContext.PROXY_PATH, window.location.href).href;
|
||||||
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
||||||
@@ -161,11 +180,8 @@ enum SDKSupportedCapabilities {
|
|||||||
let _client: Cosmos.CosmosClient;
|
let _client: Cosmos.CosmosClient;
|
||||||
|
|
||||||
export function client(): Cosmos.CosmosClient {
|
export function client(): Cosmos.CosmosClient {
|
||||||
if (_client) {
|
if (_client) return _client;
|
||||||
if (!userContext.hasDataPlaneRbacSettingChanged) {
|
|
||||||
return _client;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let _defaultHeaders: Cosmos.CosmosHeaders = {};
|
let _defaultHeaders: Cosmos.CosmosHeaders = {};
|
||||||
_defaultHeaders["x-ms-cosmos-sdk-supportedcapabilities"] =
|
_defaultHeaders["x-ms-cosmos-sdk-supportedcapabilities"] =
|
||||||
SDKSupportedCapabilities.None | SDKSupportedCapabilities.PartitionMerge;
|
SDKSupportedCapabilities.None | SDKSupportedCapabilities.PartitionMerge;
|
||||||
@@ -184,7 +200,6 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
|
|
||||||
const options: Cosmos.CosmosClientOptions = {
|
const options: Cosmos.CosmosClientOptions = {
|
||||||
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
||||||
key: userContext.dataPlaneRbacEnabled ? "" : userContext.masterKey,
|
|
||||||
tokenProvider,
|
tokenProvider,
|
||||||
userAgentSuffix: "Azure Portal",
|
userAgentSuffix: "Azure Portal",
|
||||||
defaultHeaders: _defaultHeaders,
|
defaultHeaders: _defaultHeaders,
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import Explorer from "../../Explorer";
|
|||||||
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||||
import { AuthType } from "AuthType";
|
import { AuthType } from "AuthType";
|
||||||
import create, { UseStore } from "zustand";
|
import create, { UseStore } from "zustand";
|
||||||
import { DatabaseAccountListKeysResult } from "@azure/arm-cosmosdb/esm/models";
|
|
||||||
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
|
||||||
|
|
||||||
export interface DataPlaneRbacState {
|
export interface DataPlaneRbacState {
|
||||||
dataPlaneRbacEnabled: boolean;
|
dataPlaneRbacEnabled: boolean;
|
||||||
@@ -162,24 +160,13 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
) {
|
) {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
dataPlaneRbacEnabled: true,
|
dataPlaneRbacEnabled: true,
|
||||||
hasDataPlaneRbacSettingChanged: true,
|
|
||||||
});
|
});
|
||||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: true });
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: true });
|
||||||
} else {
|
} else {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
dataPlaneRbacEnabled: false,
|
dataPlaneRbacEnabled: false,
|
||||||
hasDataPlaneRbacSettingChanged: true,
|
|
||||||
});
|
});
|
||||||
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false });
|
||||||
if (!userContext.features.enableAadDataPlane) {
|
|
||||||
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
|
|
||||||
if (keys.primaryMasterKey) {
|
|
||||||
updateUserContext({ masterKey: keys.primaryMasterKey });
|
|
||||||
|
|
||||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
|
LocalStorageUtility.setEntryBoolean(StorageKey.RUThresholdEnabled, ruThresholdEnabled);
|
||||||
|
|||||||
@@ -759,18 +759,13 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
configContext.CASSANDRA_PROXY_ENDPOINT !== CassandraProxyEndpoints.Development &&
|
configContext.CASSANDRA_PROXY_ENDPOINT !== CassandraProxyEndpoints.Development &&
|
||||||
userContext.databaseAccount.properties.ipRules?.length > 0
|
userContext.databaseAccount.properties.ipRules?.length > 0
|
||||||
) {
|
) {
|
||||||
if (
|
canAccessCassandraProxy = canAccessCassandraProxy && configContext.CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
||||||
configContext.CASSANDRA_PROXY_ENDPOINT !== CassandraProxyEndpoints.Development &&
|
|
||||||
userContext.databaseAccount.properties.ipRules?.length > 0
|
|
||||||
) {
|
|
||||||
canAccessCassandraProxy = canAccessCassandraProxy && configContext.CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
canAccessCassandraProxy &&
|
|
||||||
configContext.NEW_CASSANDRA_APIS?.includes(api) &&
|
|
||||||
activeCassandraProxyEndpoints.includes(configContext.CASSANDRA_PROXY_ENDPOINT)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
canAccessCassandraProxy &&
|
||||||
|
configContext.NEW_CASSANDRA_APIS?.includes(api) &&
|
||||||
|
activeCassandraProxyEndpoints.includes(configContext.CASSANDRA_PROXY_ENDPOINT)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export type Features = {
|
|||||||
readonly enableTtl: boolean;
|
readonly enableTtl: boolean;
|
||||||
readonly executeSproc: boolean;
|
readonly executeSproc: boolean;
|
||||||
readonly enableAadDataPlane: boolean;
|
readonly enableAadDataPlane: boolean;
|
||||||
readonly enableDataPlaneRbac: boolean;
|
|
||||||
readonly enableResourceGraph: boolean;
|
readonly enableResourceGraph: boolean;
|
||||||
readonly enableKoResourceTree: boolean;
|
readonly enableKoResourceTree: boolean;
|
||||||
readonly hostedDataExplorer: boolean;
|
readonly hostedDataExplorer: boolean;
|
||||||
@@ -70,7 +69,6 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
|||||||
canExceedMaximumValue: "true" === get("canexceedmaximumvalue"),
|
canExceedMaximumValue: "true" === get("canexceedmaximumvalue"),
|
||||||
cosmosdb: "true" === get("cosmosdb"),
|
cosmosdb: "true" === get("cosmosdb"),
|
||||||
enableAadDataPlane: "true" === get("enableaaddataplane"),
|
enableAadDataPlane: "true" === get("enableaaddataplane"),
|
||||||
enableDataPlaneRbac: "true" === get("enabledataplanerbac"),
|
|
||||||
enableResourceGraph: "true" === get("enableresourcegraph"),
|
enableResourceGraph: "true" === get("enableresourcegraph"),
|
||||||
enableChangeFeedPolicy: "true" === get("enablechangefeedpolicy"),
|
enableChangeFeedPolicy: "true" === get("enablechangefeedpolicy"),
|
||||||
enableFixedCollectionWithSharedThroughput: "true" === get("enablefixedcollectionwithsharedthroughput"),
|
enableFixedCollectionWithSharedThroughput: "true" === get("enablefixedcollectionwithsharedthroughput"),
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export interface UserContext {
|
|||||||
readonly fabricContext?: FabricContext;
|
readonly fabricContext?: FabricContext;
|
||||||
readonly authType?: AuthType;
|
readonly authType?: AuthType;
|
||||||
readonly masterKey?: string;
|
readonly masterKey?: string;
|
||||||
|
readonly listKeysFetchInProgress?: boolean;
|
||||||
readonly subscriptionId?: string;
|
readonly subscriptionId?: string;
|
||||||
readonly resourceGroup?: string;
|
readonly resourceGroup?: string;
|
||||||
readonly databaseAccount?: DatabaseAccount;
|
readonly databaseAccount?: DatabaseAccount;
|
||||||
@@ -102,7 +103,6 @@ export interface UserContext {
|
|||||||
readonly vcoreMongoConnectionParams?: VCoreMongoConnectionParams;
|
readonly vcoreMongoConnectionParams?: VCoreMongoConnectionParams;
|
||||||
readonly feedbackPolicies?: AdminFeedbackPolicySettings;
|
readonly feedbackPolicies?: AdminFeedbackPolicySettings;
|
||||||
readonly dataPlaneRbacEnabled?: boolean;
|
readonly dataPlaneRbacEnabled?: boolean;
|
||||||
readonly hasDataPlaneRbacSettingChanged?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra" | "Postgres" | "VCoreMongo";
|
export type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra" | "Postgres" | "VCoreMongo";
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import { Node, PortalEnv, updateUserContext, userContext } from "../UserContext"
|
|||||||
import { acquireTokenWithMsal, getAuthorizationHeader, getMsalInstance } from "../Utils/AuthorizationUtils";
|
import { acquireTokenWithMsal, getAuthorizationHeader, getMsalInstance } from "../Utils/AuthorizationUtils";
|
||||||
import { isInvalidParentFrameOrigin, shouldProcessMessage } from "../Utils/MessageValidation";
|
import { isInvalidParentFrameOrigin, shouldProcessMessage } from "../Utils/MessageValidation";
|
||||||
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
|
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
||||||
import { applyExplorerBindings } from "../applyExplorerBindings";
|
import { applyExplorerBindings } from "../applyExplorerBindings";
|
||||||
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
import { useDataPlaneRbac } from "Explorer/Panes/SettingsPane/SettingsPane";
|
||||||
|
|
||||||
@@ -287,26 +288,19 @@ async function configureHostedWithAAD(config: AAD): Promise<Explorer> {
|
|||||||
} else {
|
} else {
|
||||||
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
||||||
}
|
}
|
||||||
if (!dataPlaneRbacEnabled) {
|
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUserContext({ dataPlaneRbacEnabled });
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
} else {
|
} else {
|
||||||
const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
||||||
if (!dataPlaneRbacEnabled) {
|
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUserContext({ dataPlaneRbacEnabled });
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
const keys: DatabaseAccountListKeysResult = await listKeys(subscriptionId, resourceGroup, account.name);
|
||||||
}
|
updateUserContext({
|
||||||
} else {
|
masterKey: keys.primaryMasterKey,
|
||||||
if (!account.properties.disableLocalAuth) {
|
});
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -423,24 +417,10 @@ function configureEmulator(): Explorer {
|
|||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
|
|
||||||
try {
|
|
||||||
const keys = await listKeys(subscriptionId, resourceGroup, account);
|
|
||||||
|
|
||||||
updateUserContext({
|
|
||||||
masterKey: keys.primaryMasterKey,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error during fetching keys or updating user context:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function configurePortal(): Promise<Explorer> {
|
async function configurePortal(): Promise<Explorer> {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
authType: AuthType.AAD,
|
authType: AuthType.AAD,
|
||||||
});
|
});
|
||||||
|
|
||||||
let explorer: Explorer;
|
let explorer: Explorer;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
// In development mode, try to load the iframe message from session storage.
|
// In development mode, try to load the iframe message from session storage.
|
||||||
@@ -455,7 +435,6 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
console.dir(message);
|
console.dir(message);
|
||||||
updateContextsFromPortalMessage(message);
|
updateContextsFromPortalMessage(message);
|
||||||
explorer = new Explorer();
|
explorer = new Explorer();
|
||||||
|
|
||||||
// In development mode, save the iframe message from the portal in session storage.
|
// In development mode, save the iframe message from the portal in session storage.
|
||||||
// This allows webpack hot reload to funciton properly
|
// This allows webpack hot reload to funciton properly
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
@@ -491,6 +470,12 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateContextsFromPortalMessage(inputs);
|
updateContextsFromPortalMessage(inputs);
|
||||||
|
explorer = new Explorer();
|
||||||
|
resolve(explorer);
|
||||||
|
|
||||||
|
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") {
|
||||||
|
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
||||||
|
}
|
||||||
|
|
||||||
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
const { databaseAccount: account, subscriptionId, resourceGroup } = userContext;
|
||||||
|
|
||||||
@@ -504,33 +489,19 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
} else {
|
} else {
|
||||||
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
dataPlaneRbacEnabled = isDataPlaneRbacSetting === Constants.RBACOptions.setTrueRBACOption;
|
||||||
}
|
}
|
||||||
if (!dataPlaneRbacEnabled) {
|
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUserContext({ dataPlaneRbacEnabled });
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
||||||
} else {
|
} else {
|
||||||
const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
const dataPlaneRbacEnabled = account.properties.disableLocalAuth;
|
||||||
|
|
||||||
if (!dataPlaneRbacEnabled) {
|
|
||||||
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUserContext({ dataPlaneRbacEnabled });
|
updateUserContext({ dataPlaneRbacEnabled });
|
||||||
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
useDataPlaneRbac.setState({ dataPlaneRbacEnabled: dataPlaneRbacEnabled });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (userContext.apiType !== "Postgres" && userContext.apiType !== "VCoreMongo") {
|
(async () => {
|
||||||
await listKeys(subscriptionId, resourceGroup, account.name);
|
await fetchAndUpdateKeys(subscriptionId, resourceGroup, account.name);
|
||||||
}
|
})();
|
||||||
}
|
|
||||||
|
|
||||||
explorer = new Explorer();
|
|
||||||
resolve(explorer);
|
|
||||||
|
|
||||||
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") {
|
|
||||||
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openAction) {
|
if (openAction) {
|
||||||
@@ -558,6 +529,18 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
|
||||||
|
try {
|
||||||
|
updateUserContext({ listKeysFetchInProgress: true });
|
||||||
|
const keys = await listKeys(subscriptionId, resourceGroup, account);
|
||||||
|
|
||||||
|
updateUserContext({ masterKey: keys.primaryMasterKey, listKeysFetchInProgress: false });
|
||||||
|
} catch (error) {
|
||||||
|
updateUserContext({ listKeysFetchInProgress: false });
|
||||||
|
console.error("Error during fetching keys or updating user context:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function shouldForwardMessage(message: PortalMessage, messageOrigin: string) {
|
function shouldForwardMessage(message: PortalMessage, messageOrigin: string) {
|
||||||
// Only allow forwarding messages from the same origin
|
// Only allow forwarding messages from the same origin
|
||||||
return messageOrigin === window.document.location.origin && message.type === MessageTypes.TelemetryInfo;
|
return messageOrigin === window.document.location.origin && message.type === MessageTypes.TelemetryInfo;
|
||||||
@@ -595,6 +578,7 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
collectionCreationDefaults: inputs.defaultCollectionThroughput,
|
collectionCreationDefaults: inputs.defaultCollectionThroughput,
|
||||||
isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription,
|
isTryCosmosDBSubscription: inputs.isTryCosmosDBSubscription,
|
||||||
feedbackPolicies: inputs.feedbackPolicies,
|
feedbackPolicies: inputs.feedbackPolicies,
|
||||||
|
listKeysFetchInProgress: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (inputs.isPostgresAccount) {
|
if (inputs.isPostgresAccount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user