Skip to content

Commit

Permalink
Merge pull request #1345 from mattydono/release/v1.2
Browse files Browse the repository at this point in the history
Release/v1.2 - Launcher instance (ARTP-900)
  • Loading branch information
rikoe authored Jan 8, 2020
2 parents b3693c1 + f701549 commit e541e8d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -131,7 +131,7 @@
"typescript": "^3.6.4"
},
"optionalDependencies": {
"openfin-cli": "^2.0.4"
"openfin-cli": "^2.0.12"
},
"browserslist": [
"> 1%",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -52,6 +53,7 @@ export interface ApplicationProvider {

export interface ApplicationConfig {
name: string
uuid?: string
url?: string
icon: JSX.Element
provider?: ApplicationProvider
Expand Down Expand Up @@ -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: {
Expand Down
7 changes: 4 additions & 3 deletions src/client/src/apps/SimpleLauncher/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,14 +28,15 @@ function handleApplication(provider: ApplicationProvider, name: string, url?: st
return createOrBringToFrontOpenFinApplication({
name,
url,
uuid,
windowOptions: provider.windowOptions,
})
}

export async function open(
config: ApplicationConfig,
): Promise<Window | fin.OpenFinWindow | Application | void | null> {
const {provider, url, name} = config
const {provider, url, name, uuid} = config

// Not under openfin -> open as url on browser
if (typeof fin === 'undefined') {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/client/src/apps/utils/openfin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Application } from 'openfin/_v2/main'
export interface ApplicationConfig {
name: string
url: string
uuid?: string
windowOptions?: OpenFinWindowOptions
}

Expand Down Expand Up @@ -31,25 +32,27 @@ async function restoreExistingApp(existingApp: Application): Promise<void> {
export async function createOrBringToFrontOpenFinApplication({
name,
url,
uuid,
windowOptions,
}: ApplicationConfig): Promise<Application> {
const existingApp = await getExistingOpenFinApplication(name)
if (existingApp) {
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<Application> {
const appOptions: fin.ApplicationOption = {
name,
url,
uuid: name,
uuid: uuid || name,
nonPersistent: true,
mainWindowOptions: windowOptions,
}
Expand Down
8 changes: 8 additions & 0 deletions src/client/src/rt-util/getEnvironment.ts
Original file line number Diff line number Diff line change
@@ -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-(?<env>[a-zA-Z]+)\.adaptivecluster\.com/.exec(serviceUrl)
return envMatch ? envMatch['groups'].env : undefined
}

0 comments on commit e541e8d

Please sign in to comment.