From cfb5db4df6ee3545deb79b36717a936fee008ae2 Mon Sep 17 00:00:00 2001 From: Nishtha Ahuja <45535788+nishthaAhujaa@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:16:19 +0530 Subject: [PATCH] Removed screenshot for mongo cloudshell (#2211) Co-authored-by: nishthaAhujaa --- .../ShellTypes/AbstractShellHandler.tsx | 15 ++++++++++++++- .../ShellTypes/MongoShellHandler.tsx | 6 +++++- .../ShellTypes/VCoreMongoShellHandler.tsx | 9 ++++++++- .../Tabs/CloudShellTab/Utils/RegionUtils.tsx | 2 -- .../BaseTerminalComponentAdapter.tsx | 11 +++++------ 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/Explorer/Tabs/CloudShellTab/ShellTypes/AbstractShellHandler.tsx b/src/Explorer/Tabs/CloudShellTab/ShellTypes/AbstractShellHandler.tsx index 9b5fef0a1..b28e0bd12 100644 --- a/src/Explorer/Tabs/CloudShellTab/ShellTypes/AbstractShellHandler.tsx +++ b/src/Explorer/Tabs/CloudShellTab/ShellTypes/AbstractShellHandler.tsx @@ -14,6 +14,11 @@ export const DISABLE_HISTORY = `set +o history`; * Used when shell initialization or connection fails. */ export const EXIT_COMMAND = ` printf "\\033[1;31mSession ended. Please close this tab and initiate a new shell session if needed.\\033[0m\\n" && disown -a && exit`; +/** + * Command that displays error message with MongoDB networking guidance and exits the shell session. + * Used when MongoDB shell connection fails due to networking issues. + */ +export const EXIT_COMMAND_MONGO = ` printf "\\033[1;31mSession ended. Please close this tab and initiate a new shell session if needed.\\033[0m\\n" && printf "\\033[1;36mPlease use the 'Add Azure Cloud Shell IPs' button in the Networking blade to allow Cloud Shell access, if not already configured.\\033[0m\\n" && disown -a && exit`; /** * This command runs mongosh in no-database and quiet mode, @@ -40,6 +45,14 @@ export abstract class AbstractShellHandler { abstract getTerminalSuppressedData(): string[]; updateTerminalData?(data: string): string; + /** + * Gets the exit command to use when connection fails. + * Can be overridden by subclasses to provide custom exit commands. + */ + protected getExitCommand(): string { + return EXIT_COMMAND; + } + /** * Constructs the complete initialization command sequence for the shell. * @@ -64,7 +77,7 @@ export abstract class AbstractShellHandler { START_MARKER, DISABLE_HISTORY, ...setupCommands, - `{ ${connectionCommand}; } || true;${EXIT_COMMAND}`, + `{ ${connectionCommand}; } || true;${this.getExitCommand()}`, ]; return allCommands.join("\n").concat("\n"); diff --git a/src/Explorer/Tabs/CloudShellTab/ShellTypes/MongoShellHandler.tsx b/src/Explorer/Tabs/CloudShellTab/ShellTypes/MongoShellHandler.tsx index ee56f59f6..ab2fb2e7f 100644 --- a/src/Explorer/Tabs/CloudShellTab/ShellTypes/MongoShellHandler.tsx +++ b/src/Explorer/Tabs/CloudShellTab/ShellTypes/MongoShellHandler.tsx @@ -1,6 +1,6 @@ import { userContext } from "../../../../UserContext"; import { filterAndCleanTerminalOutput, getHostFromUrl, getMongoShellRemoveInfoText } from "../Utils/CommonUtils"; -import { AbstractShellHandler, DISABLE_TELEMETRY_COMMAND } from "./AbstractShellHandler"; +import { AbstractShellHandler, DISABLE_TELEMETRY_COMMAND, EXIT_COMMAND_MONGO } from "./AbstractShellHandler"; export class MongoShellHandler extends AbstractShellHandler { private _key: string; @@ -48,6 +48,10 @@ export class MongoShellHandler extends AbstractShellHandler { return ["Warning: Non-Genuine MongoDB Detected", "Telemetry is now disabled."]; } + protected getExitCommand(): string { + return EXIT_COMMAND_MONGO; + } + updateTerminalData(data: string): string { return filterAndCleanTerminalOutput(data, this._removeInfoText); } diff --git a/src/Explorer/Tabs/CloudShellTab/ShellTypes/VCoreMongoShellHandler.tsx b/src/Explorer/Tabs/CloudShellTab/ShellTypes/VCoreMongoShellHandler.tsx index 85b2a7bb6..fb38ce95f 100644 --- a/src/Explorer/Tabs/CloudShellTab/ShellTypes/VCoreMongoShellHandler.tsx +++ b/src/Explorer/Tabs/CloudShellTab/ShellTypes/VCoreMongoShellHandler.tsx @@ -1,6 +1,6 @@ import { userContext } from "../../../../UserContext"; import { filterAndCleanTerminalOutput, getMongoShellRemoveInfoText } from "../Utils/CommonUtils"; -import { AbstractShellHandler, DISABLE_TELEMETRY_COMMAND } from "./AbstractShellHandler"; +import { AbstractShellHandler, DISABLE_TELEMETRY_COMMAND, EXIT_COMMAND_MONGO } from "./AbstractShellHandler"; export class VCoreMongoShellHandler extends AbstractShellHandler { private _endpoint: string | undefined; @@ -35,6 +35,13 @@ export class VCoreMongoShellHandler extends AbstractShellHandler { return ["Warning: Non-Genuine MongoDB Detected", "Telemetry is now disabled."]; } + /** + * Override getExitCommand to include MongoDB networking guidance + */ + protected getExitCommand(): string { + return EXIT_COMMAND_MONGO; + } + updateTerminalData(data: string): string { return filterAndCleanTerminalOutput(data, this._removeInfoText); } diff --git a/src/Explorer/Tabs/CloudShellTab/Utils/RegionUtils.tsx b/src/Explorer/Tabs/CloudShellTab/Utils/RegionUtils.tsx index f9d4516fa..413d46547 100644 --- a/src/Explorer/Tabs/CloudShellTab/Utils/RegionUtils.tsx +++ b/src/Explorer/Tabs/CloudShellTab/Utils/RegionUtils.tsx @@ -7,7 +7,6 @@ const validCloudShellRegions = new Set([ "westeurope", "centralindia", "southeastasia", - "westcentralus", "usgovvirginia", "usgovarizona", ]); @@ -41,7 +40,6 @@ export const getNormalizedRegion = (region: string, defaultCloudshellRegion: str } const regionMap: Record = { - centralus: "westcentralus", eastus2: "eastus", }; diff --git a/src/Explorer/Tabs/ShellAdapters/BaseTerminalComponentAdapter.tsx b/src/Explorer/Tabs/ShellAdapters/BaseTerminalComponentAdapter.tsx index 1664326d9..c049457e8 100644 --- a/src/Explorer/Tabs/ShellAdapters/BaseTerminalComponentAdapter.tsx +++ b/src/Explorer/Tabs/ShellAdapters/BaseTerminalComponentAdapter.tsx @@ -4,7 +4,6 @@ import { QuickstartFirewallNotification } from "Explorer/Quickstart/QuickstartFi import { getShellNameForDisplay } from "Explorer/Tabs/CloudShellTab/Utils/CommonUtils"; import * as React from "react"; import FirewallRuleScreenshot from "../../../../images/firewallRule.png"; -import VcoreFirewallRuleScreenshot from "../../../../images/vcoreMongoFirewallRule.png"; import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; import * as DataModels from "../../../Contracts/DataModels"; import * as ViewModels from "../../../Contracts/ViewModels"; @@ -25,15 +24,15 @@ export abstract class BaseTerminalComponentAdapter implements ReactAdapter { ) {} public renderComponent(): JSX.Element { + if (this.kind === ViewModels.TerminalKind.Mongo || this.kind === ViewModels.TerminalKind.VCoreMongo) { + return this.renderTerminalComponent(); + } + if (!this.isAllPublicIPAddressesEnabled()) { return ( );