open Legacy Mongo SHell with correct base URL in sovereign clouds (#1823)

Co-authored-by: Asier Isayas <aisayas@microsoft.com>
This commit is contained in:
Asier Isayas 2024-04-26 14:55:47 -04:00 committed by GitHub
parent 618c5ec0fe
commit cbd5e6bf76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 8 deletions

View File

@ -35,7 +35,7 @@ export interface IMongoShellTabAccessor {
} }
export interface IMongoShellTabComponentStates { export interface IMongoShellTabComponentStates {
url: URL; url: string;
} }
export interface IMongoShellTabComponentProps { export interface IMongoShellTabComponentProps {
@ -221,7 +221,7 @@ export default class MongoShellTabComponent extends Component<
name="explorer" name="explorer"
className="iframe" className="iframe"
style={{ width: "100%", height: "100%", border: 0, padding: 0, margin: 0, overflow: "hidden" }} style={{ width: "100%", height: "100%", border: 0, padding: 0, margin: 0, overflow: "hidden" }}
src={this.state.url.toString()} src={this.state.url}
id={this.props.tabsBaseInstance.tabId} id={this.props.tabsBaseInstance.tabId}
onLoad={(event) => this.setContentFocus(event)} onLoad={(event) => this.setContentFocus(event)}
title="Mongo Shell" title="Mongo Shell"

View File

@ -1,15 +1,11 @@
import { configContext } from "ConfigContext";
import { userContext } from "../../../UserContext"; import { userContext } from "../../../UserContext";
export function getMongoShellUrl(useMongoProxyEndpoint?: boolean): URL { export function getMongoShellUrl(useMongoProxyEndpoint?: boolean): string {
const { databaseAccount: account } = userContext; const { databaseAccount: account } = userContext;
const resourceId = account?.id; const resourceId = account?.id;
const accountName = account?.name; const accountName = account?.name;
const mongoEndpoint = account?.properties?.mongoEndpoint || account?.properties?.documentEndpoint; const mongoEndpoint = account?.properties?.mongoEndpoint || account?.properties?.documentEndpoint;
const queryString = `resourceId=${resourceId}&accountName=${accountName}&mongoEndpoint=${mongoEndpoint}`; const queryString = `resourceId=${resourceId}&accountName=${accountName}&mongoEndpoint=${mongoEndpoint}`;
const path: string = useMongoProxyEndpoint
? `/mongoshell/index.html?${queryString}`
: `/mongoshell/indexv2.html?${queryString}`;
return new URL(path, configContext.hostedExplorerURL); return useMongoProxyEndpoint ? `/mongoshell/index.html?${queryString}` : `/mongoshell/indexv2.html?${queryString}`;
} }