Add UI to select plugins

Summary: Adds UI to the select the plugin to export. It lists the plugins which has currently some data in the redux store and it also lists those plugins which has implemented `exportPersistedState` function, as it might happen that the redux store may not have the data for a plugin but it will still export the data by calling `exportPersistedState`, which will ping the mobile client to get the data at point while we export the flipper trace.

Reviewed By: jknoxville

Differential Revision: D16468408

fbshipit-source-id: 452a7caf7199dd2b8df330bbb10d0a90008e92ec
This commit is contained in:
Pritesh Nandgaonkar
2019-07-26 10:46:23 -07:00
committed by Facebook Github Bot
parent aa470a9aef
commit e7198040ea
11 changed files with 513 additions and 33 deletions

View File

@@ -45,7 +45,26 @@ export function getPersistedState<PersistedState>(
return persistedState;
}
export function getActivePluginNames(plugins: PluginsState): Array<string> {
export function getActivePersistentPlugins(
pluginsState: PluginStatesState,
plugins: PluginsState,
): Array<string> {
const pluginsMap: Map<
string,
Class<FlipperDevicePlugin<> | FlipperPlugin<>>,
> = pluginsClassMap(plugins);
return getPersistentPlugins(plugins).filter(plugin => {
const pluginClass = pluginsMap.get(plugin);
const keys = Object.keys(pluginsState).map(key => key.split('#').pop());
return (
(pluginClass && pluginClass.exportPersistedState != undefined) ||
plugin == 'DeviceLogs' ||
keys.includes(plugin)
);
});
}
export function getPersistentPlugins(plugins: PluginsState): Array<string> {
const pluginsMap: Map<
string,
Class<FlipperDevicePlugin<> | FlipperPlugin<>>,
@@ -65,5 +84,16 @@ export function getActivePluginNames(plugins: PluginsState): Array<string> {
pluginsMap.delete(plugin[0].name);
}
});
return [...pluginsMap.keys()];
const activePlugins = [...pluginsMap.keys()];
return activePlugins.filter(plugin => {
const pluginClass = pluginsMap.get(plugin);
return (
plugin == 'DeviceLogs' ||
(pluginClass &&
(pluginClass.defaultPersistedState != undefined ||
pluginClass.exportPersistedState != undefined))
);
});
}