From 535ed88bc361df4bf7206e9963c8f573aa8f44f8 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 11 Feb 2020 07:27:00 -0800 Subject: [PATCH] Unwrap device plugins in sidebar in certain scenarios Summary: This diff removes the 'device plugins' section, and shows plugin at top level in certain scenarios: - there are no other clients - there is only one device plugin - the device has been imported This removes visual clutter Reviewed By: nikoant Differential Revision: D19789511 fbshipit-source-id: 6a5fce120ac811428662828ee43f7ab7f3331362 --- src/chrome/mainsidebar/MainSidebar2.tsx | 74 ++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/chrome/mainsidebar/MainSidebar2.tsx b/src/chrome/mainsidebar/MainSidebar2.tsx index 75b4c6cf6..df4dcc555 100644 --- a/src/chrome/mainsidebar/MainSidebar2.tsx +++ b/src/chrome/mainsidebar/MainSidebar2.tsx @@ -235,6 +235,27 @@ class MainSidebar2 extends PureComponent { selectedDevice, } = this.props; const clients = getAvailableClients(device, this.props.clients); + const devicePluginsItems = device.devicePlugins.map(pluginName => { + const plugin = this.props.devicePlugins.get(pluginName)!; + return ( + + selectPlugin({ + selectedPlugin: plugin.id, + selectedApp: null, + deepLinkPayload: null, + selectedDevice: device, + }) + } + plugin={plugin} + /> + ); + }); + const wrapDevicePlugins = + clients.length > 0 && device.devicePlugins.length > 1 && !device.source; + return ( { level={1} defaultCollapsed={!canBeDefaultDevice(device)}> {this.showArchivedDeviceDetails(device)} - {device.devicePlugins.length > 0 ? ( + {wrapDevicePlugins ? ( - {device.devicePlugins.map(pluginName => { - const plugin = this.props.devicePlugins.get(pluginName)!; - return ( - - selectPlugin({ - selectedPlugin: plugin.id, - selectedApp: null, - deepLinkPayload: null, - selectedDevice: device, - }) - } - plugin={plugin} - /> - ); - })} + {devicePluginsItems} - ) : null} - {clients.length === 0 ? ( - ) : ( - clients.map(client => ( - - )) +
{devicePluginsItems}
)} + {clients.map(client => ( + + ))}
); }