From fe2918301452555c8f0e4a64543b8b04c975ad05 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 24 May 2022 07:55:40 -0700 Subject: [PATCH] Show custom messages for no SDKs in Launch Emulator dialog Summary: Our launch emulator button isn't very helpful when you don't have any SDKs set up as it shows you exactly the same message as if it was loading for a bit longer. We've seen a low, but constant flow of support requests and it's often not easy to debug remotely unless you dig into the state export. This sets up a new actionable message when you have neither Android nor iOS support enabled and sends you straight to the settings. Changelog: Show alert in Launch Emulator dialogue if no SDKs are enabled Reviewed By: mweststrate Differential Revision: D36596972 fbshipit-source-id: ba72e9aaeb136c1a7e2f360ef9fbbeec6bc76f4d --- .../appinspect/LaunchEmulator.tsx | 40 ++++++++++++++++ .../__tests__/LaunchEmulator.spec.tsx | 47 ++++++++++++++++++- 2 files changed, 86 insertions(+), 1 deletion(-) 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());