Sort plugins by name

Summary: Sort plugins in sidebar by name (or ID as fallback).

Reviewed By: passy

Differential Revision: D13621422

fbshipit-source-id: dd264bde64409a2cd81caa0b41af81bf614f9e62
This commit is contained in:
Daniel Büchele
2019-01-10 03:48:19 -08:00
committed by Facebook Github Bot
parent 384529e97f
commit cc0615c7d9

View File

@@ -226,6 +226,9 @@ class MainSidebar extends PureComponent<MainSidebarProps> {
)
.sort((a, b) => (a.query.app || '').localeCompare(b.query.app));
const byPluginNameOrId = (a, b) =>
(a.title || a.id) > (b.title || b.id) ? 1 : -1;
return (
<Sidebar
position="left"
@@ -266,6 +269,7 @@ class MainSidebar extends PureComponent<MainSidebarProps> {
{selectedDevice &&
Array.from(this.props.devicePlugins.values())
.filter(plugin => plugin.supportsDevice(selectedDevice))
.sort(byPluginNameOrId)
.map((plugin: Class<FlipperDevicePlugin<>>) => (
<PluginSidebarListItem
key={plugin.id}
@@ -297,6 +301,7 @@ class MainSidebar extends PureComponent<MainSidebarProps> {
(p: Class<FlipperPlugin<>>) =>
client.plugins.indexOf(p.id) > -1,
)
.sort(byPluginNameOrId)
.map((plugin: Class<FlipperPlugin<>>) => (
<PluginSidebarListItem
key={plugin.id}