mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-25 03:41:19 +00:00
- Load Legacy Mongo Shell V2 by default - Add/Keep feature flags to load from portal BE and V1 - Skip code coverage if skipCodeCoverage environment variable is set to "true"
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { configContext, Platform } from "../../../ConfigContext";
|
|
import { userContext } from "../../../UserContext";
|
|
|
|
export function getMongoShellUrl(): string {
|
|
const { databaseAccount: account } = userContext;
|
|
const resourceId = account?.id;
|
|
const accountName = account?.name;
|
|
const mongoEndpoint = account?.properties?.mongoEndpoint || account?.properties?.documentEndpoint;
|
|
const queryString = `resourceId=${resourceId}&accountName=${accountName}&mongoEndpoint=${mongoEndpoint}`;
|
|
|
|
if (userContext.features.enableLegacyMongoShellV1 === true) {
|
|
return `/mongoshell/index.html?${queryString}`;
|
|
}
|
|
|
|
if (userContext.features.enableLegacyMongoShellV1Debug === true) {
|
|
return `/mongoshell/debug/index.html?${queryString}`;
|
|
}
|
|
|
|
if (userContext.features.enableLegacyMongoShellV2 === true) {
|
|
return `/mongoshell/indexv2.html?${queryString}`;
|
|
}
|
|
|
|
if (userContext.features.enableLegacyMongoShellV2Debug === true) {
|
|
return `/mongoshell/debug/indexv2.html?${queryString}`;
|
|
}
|
|
|
|
if (userContext.portalEnv === "localhost") {
|
|
return `/mongoshell/indexv2.html?${queryString}`;
|
|
}
|
|
|
|
if (userContext.features.loadLegacyMongoShellFromBE === true) {
|
|
const extensionEndpoint: string = getExtensionEndpoint(configContext.platform, configContext.BACKEND_ENDPOINT);
|
|
return `${extensionEndpoint}/content/mongoshell/debug/index.html?${queryString}`;
|
|
}
|
|
|
|
return `/mongoshell/indexv2.html?${queryString}`;
|
|
}
|
|
|
|
export function getExtensionEndpoint(platform: string, backendEndpoint: string): string {
|
|
const runtimeEndpoint = platform === Platform.Hosted ? backendEndpoint : "";
|
|
|
|
const extensionEndpoint: string = backendEndpoint || runtimeEndpoint || "";
|
|
|
|
return extensionEndpoint;
|
|
}
|