diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx index ffbcefbfb..93bf6d333 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/LaunchEmulator.tsx @@ -21,6 +21,7 @@ import {Layout, renderReactRoot, withTrackingScope} from 'flipper-plugin'; import {Provider} from 'react-redux'; import {IOSDeviceParams} from 'flipper-common'; import {getRenderHostInstance} from '../../RenderHost'; +import SettingsSheet from '../../chrome/SettingsSheet'; const COLD_BOOT = 'cold-boot'; @@ -36,12 +37,47 @@ function LaunchEmulatorContainer({onClose}: {onClose: () => void}) { return ; } +function NoSDKsEnabledAlert({onClose}: {onClose: () => void}) { + const [showSettings, setShowSettings] = useState(false); + const footer = ( + <> + + + + ); + return ( + <> + + + + + + {showSettings && ( + setShowSettings(false)} + /> + )} + + ); +} + export const LaunchEmulatorDialog = withTrackingScope( function LaunchEmulatorDialog({onClose}: {onClose: () => void}) { const iosEnabled = useStore((state) => state.settingsState.enableIOS); const androidEnabled = useStore( (state) => state.settingsState.enableAndroid, ); + const [iosEmulators, setIosEmulators] = useState([]); const [androidEmulators, setAndroidEmulators] = useState([]); @@ -79,6 +115,10 @@ export const LaunchEmulatorDialog = withTrackingScope( }); }, [androidEnabled]); + if (!iosEnabled && !androidEnabled) { + return ; + } + const items = [ ...(androidEmulators.length > 0 ? [] diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/LaunchEmulator.spec.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/LaunchEmulator.spec.tsx index 8aa5d77c3..9ac1f833f 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/LaunchEmulator.spec.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/LaunchEmulator.spec.tsx @@ -17,8 +17,16 @@ import {createRootReducer} from '../../../reducers'; import {sleep} from 'flipper-plugin'; import {getRenderHostInstance} from '../../../RenderHost'; -test('Can render and launch android apps - empty', async () => { +test('Can render and launch android apps - no emulators', async () => { const store = createStore(createRootReducer()); + store.dispatch({ + type: 'UPDATE_SETTINGS', + payload: { + ...store.getState().settingsState, + enableAndroid: true, + enableIOS: true, + }, + }); const responses: any = { 'ios-get-simulators': [], @@ -44,6 +52,43 @@ test('Can render and launch android apps - empty', async () => { `); }); +test('Can render and launch android apps - no SDKs', async () => { + const store = createStore(createRootReducer()); + store.dispatch({ + type: 'UPDATE_SETTINGS', + payload: { + ...store.getState().settingsState, + enableAndroid: false, + enableIOS: false, + }, + }); + + const responses: any = { + 'ios-get-simulators': [], + 'android-get-emulators': [], + }; + getRenderHostInstance().flipperServer.exec = async function (cmd: any) { + return responses[cmd]; + } as any; + const onClose = jest.fn(); + + const renderer = render( + + + , + ); + + expect(await renderer.findByText(/No Mobile SDKs Enabled/)) + .toMatchInlineSnapshot(` +
+ No Mobile SDKs Enabled +
+ `); +}); + test('Can render and launch android apps', async () => { const store = createStore(createRootReducer());