diff --git a/src/client/package.json b/src/client/package.json index 7aed7a9487..cf6502db5b 100644 --- a/src/client/package.json +++ b/src/client/package.json @@ -20,7 +20,7 @@ }, "scripts": { "precommit": "lint-staged", - "start": "cross-env REACT_APP_BUILD_VERSION=$(git describe) react-scripts start", + "start": "cross-env react-scripts start", "start:https": "cross-env HTTPS=true react-scripts start", "start:local-backend": "cross-env REACT_APP_BROKER_HOST=localhost REACT_APP_BROKER_PORT=8000 npm run start", "start:dev-backend": "cross-env REACT_APP_BROKER_HOST=web-dev.adaptivecluster.com REACT_APP_BROKER_PORT=80 npm run start", @@ -131,7 +131,7 @@ "typescript": "^3.6.4" }, "optionalDependencies": { - "openfin-cli": "^2.0.4" + "openfin-cli": "^2.0.12" }, "browserslist": [ "> 1%", diff --git a/src/client/src/apps/SimpleLauncher/applicationConfigurations.tsx b/src/client/src/apps/SimpleLauncher/applicationConfigurations.tsx index e3bea1bfca..ef74c0efc0 100644 --- a/src/client/src/apps/SimpleLauncher/applicationConfigurations.tsx +++ b/src/client/src/apps/SimpleLauncher/applicationConfigurations.tsx @@ -5,6 +5,7 @@ import { reactiveTraderIcon, } from './icons/index' import { EXCEL_ADAPTER_NAME, PlatformName } from 'rt-platforms' +import { getEnvironment } from 'rt-util/getEnvironment' // Safer than location.origin due to browser support const ORIGIN = `${location.protocol}//${location.host}` @@ -52,6 +53,7 @@ export interface ApplicationProvider { export interface ApplicationConfig { name: string + uuid?: string url?: string icon: JSX.Element provider?: ApplicationProvider @@ -92,9 +94,13 @@ const excelLegacyAppConfig: ApplicationConfig = { const excelAppConfig = EXCEL_ADAPTER_NAME === 'JS' ? excelJSAppConfig : excelLegacyAppConfig +const env = getEnvironment() || 'unknown' +const envFormatted = `(${env.toUpperCase()})` + const baseAppConfigs: ApplicationConfig[] = [ { - name: 'Reactive Trader', + name: `Reactive Trader Cloud (${envFormatted})`, + uuid: `reactive-trader-cloud-web-${env}`, url: `${ORIGIN}`, icon: reactiveTraderIcon, provider: { diff --git a/src/client/src/apps/SimpleLauncher/tools.ts b/src/client/src/apps/SimpleLauncher/tools.ts index a5ea113049..dab56ec7c0 100644 --- a/src/client/src/apps/SimpleLauncher/tools.ts +++ b/src/client/src/apps/SimpleLauncher/tools.ts @@ -16,7 +16,7 @@ function openWindow(provider: ApplicationProvider, name: string, url?: string) { return createOpenFinWindow({name, url, windowOptions: provider.windowOptions}) } -function handleApplication(provider: ApplicationProvider, name: string, url?: string) { +function handleApplication(provider: ApplicationProvider, name: string, uuid?: string, url?: string) { if (!provider.windowOptions) { console.error(`Error opening app - windowOptions object is missing`) return @@ -28,6 +28,7 @@ function handleApplication(provider: ApplicationProvider, name: string, url?: st return createOrBringToFrontOpenFinApplication({ name, url, + uuid, windowOptions: provider.windowOptions, }) } @@ -35,7 +36,7 @@ function handleApplication(provider: ApplicationProvider, name: string, url?: st export async function open( config: ApplicationConfig, ): Promise { - const {provider, url, name} = config + const {provider, url, name, uuid} = config // Not under openfin -> open as url on browser if (typeof fin === 'undefined') { @@ -65,7 +66,7 @@ export async function open( return excelApp.open() case 'application': default: - return handleApplication(provider, name, url) + return handleApplication(provider, name, uuid, url) } } } diff --git a/src/client/src/apps/utils/openfin-utils.ts b/src/client/src/apps/utils/openfin-utils.ts index 3d0e64b4e9..eaad47f844 100644 --- a/src/client/src/apps/utils/openfin-utils.ts +++ b/src/client/src/apps/utils/openfin-utils.ts @@ -3,6 +3,7 @@ import { Application } from 'openfin/_v2/main' export interface ApplicationConfig { name: string url: string + uuid?: string windowOptions?: OpenFinWindowOptions } @@ -31,6 +32,7 @@ async function restoreExistingApp(existingApp: Application): Promise { export async function createOrBringToFrontOpenFinApplication({ name, url, + uuid, windowOptions, }: ApplicationConfig): Promise { const existingApp = await getExistingOpenFinApplication(name) @@ -38,18 +40,19 @@ export async function createOrBringToFrontOpenFinApplication({ await restoreExistingApp(existingApp) return existingApp } - return createAndRunOpenFinApplication({ name, url, windowOptions }) + return createAndRunOpenFinApplication({ name, url, uuid, windowOptions }) } export async function createAndRunOpenFinApplication({ name, url, + uuid, windowOptions, }: ApplicationConfig): Promise { const appOptions: fin.ApplicationOption = { name, url, - uuid: name, + uuid: uuid || name, nonPersistent: true, mainWindowOptions: windowOptions, } diff --git a/src/client/src/rt-util/getEnvironment.ts b/src/client/src/rt-util/getEnvironment.ts new file mode 100644 index 0000000000..dbbd93f11c --- /dev/null +++ b/src/client/src/rt-util/getEnvironment.ts @@ -0,0 +1,8 @@ +export function getEnvironment(): string | undefined { + const serviceUrl = process.env.REACT_APP_BROKER_HOST || window.location.host; + + if (serviceUrl.includes('localhost')) return 'localhost'; + + const envMatch = /web-(?[a-zA-Z]+)\.adaptivecluster\.com/.exec(serviceUrl) + return envMatch ? envMatch['groups'].env : undefined +}