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
This commit is contained in:
committed by
Facebook Github Bot
parent
3dcfe9f3ae
commit
535ed88bc3
@@ -235,6 +235,27 @@ class MainSidebar2 extends PureComponent<Props, State> {
|
|||||||
selectedDevice,
|
selectedDevice,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const clients = getAvailableClients(device, this.props.clients);
|
const clients = getAvailableClients(device, this.props.clients);
|
||||||
|
const devicePluginsItems = device.devicePlugins.map(pluginName => {
|
||||||
|
const plugin = this.props.devicePlugins.get(pluginName)!;
|
||||||
|
return (
|
||||||
|
<PluginSidebarListItem
|
||||||
|
key={plugin.id}
|
||||||
|
isActive={plugin.id === selectedPlugin && selectedDevice === device}
|
||||||
|
onClick={() =>
|
||||||
|
selectPlugin({
|
||||||
|
selectedPlugin: plugin.id,
|
||||||
|
selectedApp: null,
|
||||||
|
deepLinkPayload: null,
|
||||||
|
selectedDevice: device,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
plugin={plugin}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const wrapDevicePlugins =
|
||||||
|
clients.length > 0 && device.devicePlugins.length > 1 && !device.source;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarSection
|
<SidebarSection
|
||||||
title={device.displayTitle()}
|
title={device.displayTitle()}
|
||||||
@@ -242,50 +263,29 @@ class MainSidebar2 extends PureComponent<Props, State> {
|
|||||||
level={1}
|
level={1}
|
||||||
defaultCollapsed={!canBeDefaultDevice(device)}>
|
defaultCollapsed={!canBeDefaultDevice(device)}>
|
||||||
{this.showArchivedDeviceDetails(device)}
|
{this.showArchivedDeviceDetails(device)}
|
||||||
{device.devicePlugins.length > 0 ? (
|
{wrapDevicePlugins ? (
|
||||||
<SidebarSection
|
<SidebarSection
|
||||||
level={2}
|
level={2}
|
||||||
title="Device Plugins"
|
title="Device Plugins"
|
||||||
defaultCollapsed={true}>
|
defaultCollapsed={true}>
|
||||||
{device.devicePlugins.map(pluginName => {
|
{devicePluginsItems}
|
||||||
const plugin = this.props.devicePlugins.get(pluginName)!;
|
|
||||||
return (
|
|
||||||
<PluginSidebarListItem
|
|
||||||
key={plugin.id}
|
|
||||||
isActive={
|
|
||||||
plugin.id === selectedPlugin && selectedDevice === device
|
|
||||||
}
|
|
||||||
onClick={() =>
|
|
||||||
selectPlugin({
|
|
||||||
selectedPlugin: plugin.id,
|
|
||||||
selectedApp: null,
|
|
||||||
deepLinkPayload: null,
|
|
||||||
selectedDevice: device,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
plugin={plugin}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</SidebarSection>
|
</SidebarSection>
|
||||||
) : null}
|
|
||||||
{clients.length === 0 ? (
|
|
||||||
<NoClients />
|
|
||||||
) : (
|
) : (
|
||||||
clients.map(client => (
|
<div style={{marginTop: 6}}>{devicePluginsItems}</div>
|
||||||
<PluginList
|
|
||||||
device={device}
|
|
||||||
key={client.id}
|
|
||||||
client={client}
|
|
||||||
clientPlugins={clientPlugins}
|
|
||||||
starPlugin={starPlugin}
|
|
||||||
userStarredPlugins={userStarredPlugins}
|
|
||||||
selectedPlugin={selectedPlugin}
|
|
||||||
selectedApp={selectedApp}
|
|
||||||
selectPlugin={selectPlugin}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
)}
|
)}
|
||||||
|
{clients.map(client => (
|
||||||
|
<PluginList
|
||||||
|
device={device}
|
||||||
|
key={client.id}
|
||||||
|
client={client}
|
||||||
|
clientPlugins={clientPlugins}
|
||||||
|
starPlugin={starPlugin}
|
||||||
|
userStarredPlugins={userStarredPlugins}
|
||||||
|
selectedPlugin={selectedPlugin}
|
||||||
|
selectedApp={selectedApp}
|
||||||
|
selectPlugin={selectPlugin}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</SidebarSection>
|
</SidebarSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user