added a pop up in click of mongo shell if its entra only flow (#2531)

* added a pop up in click of mongo shell if its entra only flow

* formatting updated

---------

Co-authored-by: Sakshi Gupta <sakshig@microsoft.com>
This commit is contained in:
sakshigupta12feb
2026-07-13 13:53:16 +05:30
committed by GitHub
parent f678f551bb
commit 4a881651d5
6 changed files with 97 additions and 13 deletions
@@ -19,10 +19,16 @@ import { AuthType } from "../../../AuthType";
import * as Constants from "../../../Common/Constants"; import * as Constants from "../../../Common/Constants";
import { Platform, configContext } from "../../../ConfigContext"; import { Platform, configContext } from "../../../ConfigContext";
import * as ViewModels from "../../../Contracts/ViewModels"; import * as ViewModels from "../../../Contracts/ViewModels";
import { userContext } from "../../../UserContext"; import {
userContext,
isVCoreMongoNativeAuthDisabled,
VCoreMongoNativeAuthDisabledMessage,
VCoreMongoNativeAuthLearnMoreUrl,
} from "../../../UserContext";
import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils"; import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils";
import { useSidePanel } from "../../../hooks/useSidePanel"; import { useSidePanel } from "../../../hooks/useSidePanel";
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
import { useDialog } from "../../Controls/Dialog";
import Explorer from "../../Explorer"; import Explorer from "../../Explorer";
import { useNotebook } from "../../Notebook/useNotebook"; import { useNotebook } from "../../Notebook/useNotebook";
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane"; import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
@@ -499,12 +505,21 @@ function createOpenTerminalButtonByKind(
const label = `Open ${terminalFriendlyName()} shell`; const label = `Open ${terminalFriendlyName()} shell`;
const tooltip = const tooltip =
"This feature is not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks."; "This feature is not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks.";
const isNativeAuthDisabled = terminalKind === ViewModels.TerminalKind.VCoreMongo && isVCoreMongoNativeAuthDisabled();
const disableButton = const disableButton =
!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled; (!useNotebook.getState().isNotebooksEnabledForAccount && !useNotebook.getState().isNotebookEnabled) ||
isNativeAuthDisabled;
return { return {
iconSrc: HostedTerminalIcon, iconSrc: HostedTerminalIcon,
iconAlt: label, iconAlt: label,
onCommandClick: () => { onCommandClick: () => {
if (isNativeAuthDisabled) {
useDialog.getState().showOkModalDialog("Native Authentication Disabled", VCoreMongoNativeAuthDisabledMessage, {
linkText: "Learn more",
linkUrl: VCoreMongoNativeAuthLearnMoreUrl,
});
return;
}
if (useNotebook.getState().isNotebookEnabled || userContext.features.enableCloudShell) { if (useNotebook.getState().isNotebookEnabled || userContext.features.enableCloudShell) {
container.openNotebookTerminal(terminalKind); container.openNotebookTerminal(terminalKind);
} }
@@ -513,7 +528,7 @@ function createOpenTerminalButtonByKind(
hasPopup: false, hasPopup: false,
disabled: disableButton, disabled: disableButton,
ariaLabel: label, ariaLabel: label,
tooltipText: !disableButton ? "" : tooltip, tooltipText: isNativeAuthDisabled ? VCoreMongoNativeAuthDisabledMessage : !disableButton ? "" : tooltip,
}; };
} }
+20 -2
View File
@@ -33,8 +33,14 @@ import QuickStartIcon from "../../../images/Quickstart_Lightning.svg";
import VisualStudioIcon from "../../../images/VisualStudio.svg"; import VisualStudioIcon from "../../../images/VisualStudio.svg";
import CollectionIcon from "../../../images/tree-collection.svg"; import CollectionIcon from "../../../images/tree-collection.svg";
import * as Constants from "../../Common/Constants"; import * as Constants from "../../Common/Constants";
import { userContext } from "../../UserContext"; import {
isVCoreMongoNativeAuthDisabled,
userContext,
VCoreMongoNativeAuthDisabledMessage,
VCoreMongoNativeAuthLearnMoreUrl,
} from "../../UserContext";
import { getCollectionName } from "../../Utils/APITypeUtils"; import { getCollectionName } from "../../Utils/APITypeUtils";
import { useDialog } from "../Controls/Dialog";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity"; import * as MostRecentActivity from "../MostRecentActivity/MostRecentActivity";
import { useNotebook } from "../Notebook/useNotebook"; import { useNotebook } from "../Notebook/useNotebook";
@@ -413,11 +419,23 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({ explorer }) => {
} }
if (userContext.apiType === "VCoreMongo") { if (userContext.apiType === "VCoreMongo") {
const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled();
return { return {
iconSrc: PowerShellIcon, iconSrc: PowerShellIcon,
title: t(Keys.splashScreen.shell.vcoreMongo.title), title: t(Keys.splashScreen.shell.vcoreMongo.title),
description: t(Keys.splashScreen.shell.vcoreMongo.description), description: t(Keys.splashScreen.shell.vcoreMongo.description),
onClick: () => container.openNotebookTerminal(TerminalKind.VCoreMongo), onClick: () => {
if (isNativeAuthDisabled) {
useDialog
.getState()
.showOkModalDialog("Native Authentication Disabled", VCoreMongoNativeAuthDisabledMessage, {
linkText: "Learn more",
linkUrl: VCoreMongoNativeAuthLearnMoreUrl,
});
} else {
container.openNotebookTerminal(TerminalKind.VCoreMongo);
}
},
}; };
} }
+28 -8
View File
@@ -1,24 +1,44 @@
import { Stack } from "@fluentui/react"; import { Link, MessageBar, MessageBarType, Stack, Text } from "@fluentui/react";
import { TerminalKind } from "Contracts/ViewModels"; import { TerminalKind } from "Contracts/ViewModels";
import { VcoreMongoQuickstartGuide } from "Explorer/Quickstart/VCoreMongoQuickstartGuide"; import { VcoreMongoQuickstartGuide } from "Explorer/Quickstart/VCoreMongoQuickstartGuide";
import { CloudShellTerminalComponent } from "Explorer/Tabs/CloudShellTab/CloudShellTerminalComponent"; import { CloudShellTerminalComponent } from "Explorer/Tabs/CloudShellTab/CloudShellTerminalComponent";
import { userContext } from "UserContext"; import {
isVCoreMongoNativeAuthDisabled,
userContext,
VCoreMongoNativeAuthDisabledMessage,
VCoreMongoNativeAuthLearnMoreUrl,
} from "UserContext";
import React from "react"; import React from "react";
export const VcoreMongoQuickstartTab: React.FC = (): JSX.Element => { export const VcoreMongoQuickstartTab: React.FC = (): JSX.Element => {
const isNativeAuthDisabled = isVCoreMongoNativeAuthDisabled();
return ( return (
<Stack style={{ width: "100%" }} horizontal> <Stack style={{ width: "100%" }} horizontal>
<Stack style={{ width: "50%" }}> <Stack style={{ width: "50%" }}>
<VcoreMongoQuickstartGuide /> <VcoreMongoQuickstartGuide />
</Stack> </Stack>
<Stack style={{ width: "50%", borderLeft: "black solid 1px" }}> <Stack style={{ width: "50%", borderLeft: "black solid 1px" }}>
<CloudShellTerminalComponent {isNativeAuthDisabled ? (
databaseAccount={userContext.databaseAccount} <Stack style={{ margin: "auto", padding: 20 }}>
tabId="QuickstartVcoreMongoShell" <MessageBar messageBarType={MessageBarType.warning} isMultiline={true}>
username={userContext.vcoreMongoConnectionParams?.adminLogin} <Text>
shellType={TerminalKind.VCoreMongo} {VCoreMongoNativeAuthDisabledMessage}{" "}
/> <Link href={VCoreMongoNativeAuthLearnMoreUrl} target="_blank">
Learn more
</Link>
</Text>
</MessageBar>
</Stack>
) : (
<CloudShellTerminalComponent
databaseAccount={userContext.databaseAccount}
tabId="QuickstartVcoreMongoShell"
username={userContext.vcoreMongoConnectionParams?.adminLogin}
shellType={TerminalKind.VCoreMongo}
/>
)}
</Stack> </Stack>
</Stack> </Stack>
); );
+2
View File
@@ -36,6 +36,7 @@ export type Features = {
readonly enableContainerCopy: boolean; readonly enableContainerCopy: boolean;
readonly enableCloudShell: boolean; readonly enableCloudShell: boolean;
readonly enableRestoreContainer: boolean; // only for Fabric readonly enableRestoreContainer: boolean; // only for Fabric
readonly mongoDisableNativeAuth: boolean;
// can be set via both flight and feature flag // can be set via both flight and feature flag
autoscaleDefault: boolean; autoscaleDefault: boolean;
@@ -103,6 +104,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
enableContainerCopy: "true" === get("enablecontainercopy"), enableContainerCopy: "true" === get("enablecontainercopy"),
enableRestoreContainer: "true" === get("enablerestorecontainer"), enableRestoreContainer: "true" === get("enablerestorecontainer"),
enableCloudShell: true, enableCloudShell: true,
mongoDisableNativeAuth: "true" === get("mongodisablenativeauth"),
}; };
} }
+28
View File
@@ -42,9 +42,37 @@ export interface PostgresConnectionStrParams {
isFreeTier: boolean; isFreeTier: boolean;
} }
export type VCoreMongoAuthMode = "NativeAuth" | "MicrosoftEntraID";
export interface VCoreMongoAuthConfig {
allowedModes?: VCoreMongoAuthMode[];
}
export interface VCoreMongoConnectionParams { export interface VCoreMongoConnectionParams {
adminLogin: string; adminLogin: string;
connectionString: string; connectionString: string;
authConfig?: VCoreMongoAuthConfig;
isNativeAuthDisabled?: boolean;
}
export const VCoreMongoNativeAuthLearnMoreUrl = "https://go.microsoft.com/fwlink/?linkid=2340100";
export const VCoreMongoNativeAuthDisabledMessage =
"Native DocumentDB authentication is disabled on this cluster. You can use MongoDB Shell with Entra ID authentication outside of the Azure portal.";
export function isVCoreMongoNativeAuthDisabled(): boolean {
if (userContext.features?.mongoDisableNativeAuth) {
return true;
}
const params = userContext.vcoreMongoConnectionParams;
if (!params) {
return false;
}
if (params.isNativeAuthDisabled) {
return true;
}
const allowedModes = params.authConfig?.allowedModes || [];
return allowedModes.length > 0 && !allowedModes.includes("NativeAuth");
} }
export interface FabricArtifactInfo { export interface FabricArtifactInfo {
+1
View File
@@ -48,6 +48,7 @@ describe("AuthorizationUtils", () => {
partitionKeyDefault2: false, partitionKeyDefault2: false,
notebooksDownBanner: false, notebooksDownBanner: false,
enableRestoreContainer: false, enableRestoreContainer: false,
mongoDisableNativeAuth: false,
}, },
}); });
}; };