Back out "Back out "[flipper][js] JS apps support 1/n""

Summary:
Original commit changeset: ff84080d43fa

This re-adds JS client support. The original version had a small bug that inadvertantly wrapped support for Android emulators in the dropdown in a GK that was only meant to cover JS clients. This is addressed here.

Reviewed By: timur-valiev

Differential Revision: D18707485

fbshipit-source-id: ceea8e279a21111f96073f8b784e852f6313e2a4
This commit is contained in:
Pascal Hartig
2019-11-26 08:07:29 -08:00
committed by Facebook Github Bot
parent e99f2bcd8b
commit 0a7c57f5a0
10 changed files with 499 additions and 6 deletions

View File

@@ -12,11 +12,17 @@ import {connect, ReactReduxContext} from 'react-redux';
import {spawn} from 'child_process';
import {dirname} from 'path';
import {selectDevice, preferDevice} from '../reducers/connections';
import {
setActiveSheet,
ActiveSheet,
ACTIVE_SHEET_JS_EMULATOR_LAUNCHER,
} from '../reducers/application';
import {default as which} from 'which';
import {showOpenDialog} from '../utils/exportData';
import BaseDevice from '../devices/BaseDevice';
import React, {Component} from 'react';
import {State} from '../reducers';
import GK from '../fb-stubs/GK';
type StateFromProps = {
selectedDevice: BaseDevice | null | undefined;
@@ -27,6 +33,7 @@ type StateFromProps = {
type DispatchFromProps = {
selectDevice: (device: BaseDevice) => void;
preferDevice: (device: string) => void;
setActiveSheet: (sheet: ActiveSheet) => void;
};
type OwnProps = {};
@@ -154,6 +161,19 @@ class DevicesButton extends Component<Props> {
label: name,
click: () => this.launchEmulator(name),
}));
// Launch JS emulator
if (GK.get('flipper_js_client_emulator')) {
dropdown.push(
{type: 'separator' as 'separator'},
{
label: 'Launch JS Web App',
click: () =>
this.props.setActiveSheet(ACTIVE_SHEET_JS_EMULATOR_LAUNCHER),
},
);
}
if (emulators.length > 0) {
dropdown.push(
{type: 'separator' as 'separator'},
@@ -165,6 +185,7 @@ class DevicesButton extends Component<Props> {
);
}
}
if (dropdown.length > 0) {
dropdown.push({type: 'separator' as 'separator'});
}
@@ -196,5 +217,6 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, State>(
{
selectDevice,
preferDevice,
setActiveSheet,
},
)(DevicesButton);