Hide emulator loading page for disabkled platforms
Reviewed By: lblasa Differential Revision: D50405264 fbshipit-source-id: c051414ad3b269cf2bc145aa4da13c20517edb36
This commit is contained in:
committed by
Facebook GitHub Bot
parent
65fef5fbc3
commit
3d4b36f14e
@@ -160,133 +160,140 @@ export const LaunchEmulatorDialog = withTrackingScope(
|
|||||||
return <NoSDKsEnabledAlert onClose={onClose} />;
|
return <NoSDKsEnabledAlert onClose={onClose} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = [
|
let items: (JSX.Element | null)[] = [];
|
||||||
<Title key="android-title" name="Android emulators" />,
|
if (androidEnabled) {
|
||||||
androidEmulators.length == 0 ? (
|
items.push(
|
||||||
<Typography.Paragraph style={{textAlign: 'center'}}>
|
<Title key="android-title" name="Android emulators" />,
|
||||||
{androidMessage}
|
androidEmulators.length == 0 ? (
|
||||||
</Typography.Paragraph>
|
<Typography.Paragraph style={{textAlign: 'center'}}>
|
||||||
) : null,
|
{androidMessage}
|
||||||
...chain(
|
</Typography.Paragraph>
|
||||||
androidEmulators.map((name) => ({
|
) : null,
|
||||||
name,
|
...chain(
|
||||||
isFavorite: favoriteVirtualDevices.includes(name),
|
androidEmulators.map((name) => ({
|
||||||
})),
|
name,
|
||||||
)
|
isFavorite: favoriteVirtualDevices.includes(name),
|
||||||
.sortBy((item) => [!item.isFavorite, item.name])
|
})),
|
||||||
.map(({name, isFavorite}) => {
|
)
|
||||||
const launch = async (coldBoot: boolean) => {
|
.sortBy((item) => [!item.isFavorite, item.name])
|
||||||
try {
|
.map(({name, isFavorite}) => {
|
||||||
setPendingEmulators(
|
const launch = async (coldBoot: boolean) => {
|
||||||
produce((draft) => {
|
try {
|
||||||
draft.add(name);
|
setPendingEmulators(
|
||||||
}),
|
produce((draft) => {
|
||||||
);
|
draft.add(name);
|
||||||
await getRenderHostInstance().flipperServer.exec(
|
}),
|
||||||
'android-launch-emulator',
|
);
|
||||||
name,
|
await getRenderHostInstance().flipperServer.exec(
|
||||||
coldBoot,
|
'android-launch-emulator',
|
||||||
);
|
name,
|
||||||
onClose();
|
coldBoot,
|
||||||
} catch (e) {
|
);
|
||||||
console.error('Failed to start emulator: ', e);
|
onClose();
|
||||||
message.error('Failed to start emulator: ' + e);
|
} catch (e) {
|
||||||
} finally {
|
console.error('Failed to start emulator: ', e);
|
||||||
setPendingEmulators(
|
message.error('Failed to start emulator: ' + e);
|
||||||
produce((draft) => {
|
} finally {
|
||||||
draft.delete(name);
|
setPendingEmulators(
|
||||||
}),
|
produce((draft) => {
|
||||||
);
|
draft.delete(name);
|
||||||
}
|
}),
|
||||||
};
|
);
|
||||||
const menu = (
|
}
|
||||||
<Menu
|
};
|
||||||
onClick={({key}) => {
|
const menu = (
|
||||||
switch (key) {
|
<Menu
|
||||||
case COLD_BOOT: {
|
onClick={({key}) => {
|
||||||
launch(true);
|
switch (key) {
|
||||||
break;
|
case COLD_BOOT: {
|
||||||
|
launch(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}}>
|
||||||
}}>
|
<Menu.Item key={COLD_BOOT} icon={<PoweroffOutlined />}>
|
||||||
<Menu.Item key={COLD_BOOT} icon={<PoweroffOutlined />}>
|
Cold Boot
|
||||||
Cold Boot
|
</Menu.Item>
|
||||||
</Menu.Item>
|
</Menu>
|
||||||
</Menu>
|
);
|
||||||
);
|
return (
|
||||||
return (
|
<VirtualDeviceRow
|
||||||
|
key={name}
|
||||||
|
addToFavorites={addToFavorites}
|
||||||
|
removeFromFavorites={removeFromFavorites}
|
||||||
|
isFavorite={isFavorite}
|
||||||
|
name={name}>
|
||||||
|
<Dropdown.Button
|
||||||
|
overlay={menu}
|
||||||
|
icon={<MoreOutlined />}
|
||||||
|
loading={pendingEmulators.has(name)}
|
||||||
|
onClick={() => launch(false)}>
|
||||||
|
{name}
|
||||||
|
</Dropdown.Button>
|
||||||
|
</VirtualDeviceRow>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.value(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (iosEnabled) {
|
||||||
|
items.push(
|
||||||
|
<Title key="ios-title" name="iOS Simulators" />,
|
||||||
|
iosEmulators.length == 0 ? (
|
||||||
|
<Typography.Paragraph style={{textAlign: 'center'}}>
|
||||||
|
{iOSMessage}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : null,
|
||||||
|
...chain(iosEmulators)
|
||||||
|
.map((device) => ({
|
||||||
|
device,
|
||||||
|
isFavorite: favoriteVirtualDevices.includes(device.name),
|
||||||
|
}))
|
||||||
|
.sortBy((item) => [!item.isFavorite, item.device.name])
|
||||||
|
.map(({device, isFavorite}) => (
|
||||||
<VirtualDeviceRow
|
<VirtualDeviceRow
|
||||||
key={name}
|
key={device.udid}
|
||||||
addToFavorites={addToFavorites}
|
addToFavorites={addToFavorites}
|
||||||
removeFromFavorites={removeFromFavorites}
|
removeFromFavorites={removeFromFavorites}
|
||||||
isFavorite={isFavorite}
|
isFavorite={isFavorite}
|
||||||
name={name}>
|
name={device.name}>
|
||||||
<Dropdown.Button
|
<Button
|
||||||
overlay={menu}
|
type="default"
|
||||||
icon={<MoreOutlined />}
|
key={device.udid}
|
||||||
loading={pendingEmulators.has(name)}
|
style={{width: '100%'}}
|
||||||
onClick={() => launch(false)}>
|
loading={pendingEmulators.has(device.udid)}
|
||||||
{name}
|
onClick={async () => {
|
||||||
</Dropdown.Button>
|
try {
|
||||||
|
setPendingEmulators(
|
||||||
|
produce((draft) => {
|
||||||
|
draft.add(device.udid);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await getRenderHostInstance().flipperServer.exec(
|
||||||
|
'ios-launch-simulator',
|
||||||
|
device.udid,
|
||||||
|
);
|
||||||
|
onClose();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to start simulator: ', e);
|
||||||
|
message.error('Failed to start simulator: ' + e);
|
||||||
|
} finally {
|
||||||
|
setPendingEmulators(
|
||||||
|
produce((draft) => {
|
||||||
|
draft.delete(device.udid);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
{device.name}
|
||||||
|
{device.osVersion ? ` (${device.osVersion})` : ''}
|
||||||
|
</Button>
|
||||||
</VirtualDeviceRow>
|
</VirtualDeviceRow>
|
||||||
);
|
))
|
||||||
})
|
.value(),
|
||||||
.value(),
|
);
|
||||||
|
}
|
||||||
<Title key="ios-title" name="iOS Simulators" />,
|
items = items.filter((item) => item != null);
|
||||||
iosEmulators.length == 0 ? (
|
|
||||||
<Typography.Paragraph style={{textAlign: 'center'}}>
|
|
||||||
{iOSMessage}
|
|
||||||
</Typography.Paragraph>
|
|
||||||
) : null,
|
|
||||||
...chain(iosEmulators)
|
|
||||||
.map((device) => ({
|
|
||||||
device,
|
|
||||||
isFavorite: favoriteVirtualDevices.includes(device.name),
|
|
||||||
}))
|
|
||||||
.sortBy((item) => [!item.isFavorite, item.device.name])
|
|
||||||
.map(({device, isFavorite}) => (
|
|
||||||
<VirtualDeviceRow
|
|
||||||
key={device.udid}
|
|
||||||
addToFavorites={addToFavorites}
|
|
||||||
removeFromFavorites={removeFromFavorites}
|
|
||||||
isFavorite={isFavorite}
|
|
||||||
name={device.name}>
|
|
||||||
<Button
|
|
||||||
type="default"
|
|
||||||
key={device.udid}
|
|
||||||
style={{width: '100%'}}
|
|
||||||
loading={pendingEmulators.has(device.udid)}
|
|
||||||
onClick={async () => {
|
|
||||||
try {
|
|
||||||
setPendingEmulators(
|
|
||||||
produce((draft) => {
|
|
||||||
draft.add(device.udid);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
await getRenderHostInstance().flipperServer.exec(
|
|
||||||
'ios-launch-simulator',
|
|
||||||
device.udid,
|
|
||||||
);
|
|
||||||
onClose();
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Failed to start simulator: ', e);
|
|
||||||
message.error('Failed to start simulator: ' + e);
|
|
||||||
} finally {
|
|
||||||
setPendingEmulators(
|
|
||||||
produce((draft) => {
|
|
||||||
draft.delete(device.udid);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
{device.name}
|
|
||||||
{device.osVersion ? ` (${device.osVersion})` : ''}
|
|
||||||
</Button>
|
|
||||||
</VirtualDeviceRow>
|
|
||||||
))
|
|
||||||
.value(),
|
|
||||||
].filter((item) => item != null);
|
|
||||||
|
|
||||||
const loadingSpinner = (
|
const loadingSpinner = (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user