Add button for emu launch selection
Summary: Based on afcoplan's feedback, now we're showing a button for launching the emulators instead of having it inline. Reviewed By: mweststrate Differential Revision: D30603659 fbshipit-source-id: edae6c63fd58647b406398c897215910938ae429
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d48293c30f
commit
4ba426debd
@@ -26,7 +26,6 @@ import isProduction, {isTest} from '../utils/isProduction';
|
|||||||
import restart from '../utils/restartFlipper';
|
import restart from '../utils/restartFlipper';
|
||||||
import BaseDevice from '../server/devices/BaseDevice';
|
import BaseDevice from '../server/devices/BaseDevice';
|
||||||
import Client from '../Client';
|
import Client from '../Client';
|
||||||
import {Button} from 'antd';
|
|
||||||
import {RocketOutlined} from '@ant-design/icons';
|
import {RocketOutlined} from '@ant-design/icons';
|
||||||
import {showEmulatorLauncher} from '../sandy-chrome/appinspect/LaunchEmulator';
|
import {showEmulatorLauncher} from '../sandy-chrome/appinspect/LaunchEmulator';
|
||||||
|
|
||||||
@@ -491,41 +490,42 @@ async function launchDeviceDialog(
|
|||||||
title: string,
|
title: string,
|
||||||
) {
|
) {
|
||||||
return new Promise<boolean>((resolve) => {
|
return new Promise<boolean>((resolve) => {
|
||||||
const dialog = Dialog.alert({
|
const currentDevices = store.getState().connections.devices;
|
||||||
|
const waitForNewDevice = async () =>
|
||||||
|
await waitFor(
|
||||||
|
store,
|
||||||
|
(state) => state.connections.devices !== currentDevices,
|
||||||
|
);
|
||||||
|
const dialog = Dialog.confirm({
|
||||||
title,
|
title,
|
||||||
type: 'warning',
|
|
||||||
message: (
|
message: (
|
||||||
<p>
|
<p>
|
||||||
To open the current deeplink for plugin {params.pluginId} a device{' '}
|
To open the current deeplink for plugin {params.pluginId} a device{' '}
|
||||||
{params.devices.length ? ' of type ' + params.devices.join(', ') : ''}{' '}
|
{params.devices.length ? ' of type ' + params.devices.join(', ') : ''}{' '}
|
||||||
should be up and running. No device was found. Please connect a device
|
should be up and running. No device was found. Please connect a device
|
||||||
or launch an emulator / simulator{' '}
|
or launch an emulator / simulator.
|
||||||
<Button
|
|
||||||
icon={<RocketOutlined />}
|
|
||||||
title="Start Emulator / Simulator"
|
|
||||||
onClick={() => {
|
|
||||||
showEmulatorLauncher(store);
|
|
||||||
}}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
.
|
|
||||||
</p>
|
</p>
|
||||||
),
|
),
|
||||||
okText: 'Cancel',
|
cancelText: 'Cancel',
|
||||||
|
okText: 'Launch Device',
|
||||||
|
onConfirm: async () => {
|
||||||
|
showEmulatorLauncher(store);
|
||||||
|
await waitForNewDevice();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
okButtonProps: {
|
||||||
|
icon: <RocketOutlined />,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line promise/catch-or-return
|
// eslint-disable-next-line promise/catch-or-return
|
||||||
dialog.then(() => {
|
dialog.then(() => {
|
||||||
// dialog was canceled
|
// dialog was cancelled
|
||||||
resolve(false);
|
resolve(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentDevices = store.getState().connections.devices;
|
|
||||||
// new devices were found
|
// new devices were found
|
||||||
// eslint-disable-next-line promise/catch-or-return
|
// eslint-disable-next-line promise/catch-or-return
|
||||||
waitFor(
|
waitForNewDevice().then(() => {
|
||||||
store,
|
|
||||||
(state) => state.connections.devices !== currentDevices,
|
|
||||||
).then(() => {
|
|
||||||
dialog.close();
|
dialog.close();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,13 +7,12 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Alert, Input, Modal, Radio, Space, Typography} from 'antd';
|
import {Alert, ButtonProps, Input, Modal, Radio, Space, Typography} from 'antd';
|
||||||
import {createState, useValue} from '../state/atom';
|
import {createState, useValue} from '../state/atom';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {renderReactRoot} from '../utils/renderReactRoot';
|
import {renderReactRoot} from '../utils/renderReactRoot';
|
||||||
import {Layout} from './Layout';
|
import {Layout} from './Layout';
|
||||||
import {Spinner} from './Spinner';
|
import {Spinner} from './Spinner';
|
||||||
|
|
||||||
type DialogResult<T> = Promise<false | T> & {close: () => void};
|
type DialogResult<T> = Promise<false | T> & {close: () => void};
|
||||||
|
|
||||||
type BaseDialogOptions = {
|
type BaseDialogOptions = {
|
||||||
@@ -21,6 +20,8 @@ type BaseDialogOptions = {
|
|||||||
okText?: string;
|
okText?: string;
|
||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
|
okButtonProps?: ButtonProps;
|
||||||
|
cancelButtonProps?: ButtonProps;
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultWidth = 400;
|
const defaultWidth = 400;
|
||||||
@@ -74,7 +75,9 @@ export const Dialog = {
|
|||||||
disabled: opts.onValidate
|
disabled: opts.onValidate
|
||||||
? !!opts.onValidate(currentValue) // non-falsy value means validation error
|
? !!opts.onValidate(currentValue) // non-falsy value means validation error
|
||||||
: false,
|
: false,
|
||||||
|
...opts.okButtonProps,
|
||||||
}}
|
}}
|
||||||
|
cancelButtonProps={opts.cancelButtonProps}
|
||||||
onCancel={cancel}
|
onCancel={cancel}
|
||||||
width={opts.width ?? defaultWidth}>
|
width={opts.width ?? defaultWidth}>
|
||||||
<Layout.Container gap>
|
<Layout.Container gap>
|
||||||
|
|||||||
Reference in New Issue
Block a user