Fix the plugin display logic to show enabled and device plugins
Summary: Changed the plugin display logic in SupportForm to show plugins which are enabled(includes device plugins) and plugins which has `exportPersistedState` defined. Reviewed By: mweststrate Differential Revision: D19643857 fbshipit-source-id: 7a4a5882507c06c6b6f9c481ee2c5c36ecc32ac6
This commit is contained in:
committed by
Facebook Github Bot
parent
de1d116806
commit
c51797d194
@@ -191,10 +191,9 @@ export default (store: Store, logger: Logger) => {
|
|||||||
setSelectedPlugins(
|
setSelectedPlugins(
|
||||||
defaultSelectedPluginsForGroup(
|
defaultSelectedPluginsForGroup(
|
||||||
grp,
|
grp,
|
||||||
store.getState().pluginStates,
|
|
||||||
store.getState().pluginMessageQueue,
|
|
||||||
store.getState().plugins,
|
store.getState().plugins,
|
||||||
selectedClient,
|
selectedClient,
|
||||||
|
store.getState().connections.userStarredPlugins,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,17 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Groups} from '../../reducers/supportForm';
|
import {Groups} from '../../reducers/supportForm';
|
||||||
import {State as PluginStatesState} from '../../reducers/pluginStates';
|
|
||||||
import {State as PluginMessageQueueState} from '../../reducers/pluginMessageQueue';
|
|
||||||
import {State as PluginState} from '../../reducers/plugins';
|
import {State as PluginState} from '../../reducers/plugins';
|
||||||
import Client from '../../Client';
|
import Client from '../../Client';
|
||||||
|
|
||||||
export function defaultSelectedPluginsForGroup(
|
export function defaultSelectedPluginsForGroup(
|
||||||
_grp: Groups,
|
_grp: Groups,
|
||||||
_pluginStates: PluginStatesState,
|
|
||||||
_pluginMessageQueue: PluginMessageQueueState,
|
|
||||||
_plugins: PluginState,
|
_plugins: PluginState,
|
||||||
_selectedClient: Client | undefined,
|
_selectedClient: Client | undefined,
|
||||||
|
_userStarredPlugins: {[client: string]: Array<string>},
|
||||||
): Array<string> {
|
): Array<string> {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {State as PluginStatesState} from '../reducers/pluginStates';
|
|||||||
import {State as PluginsState} from '../reducers/plugins';
|
import {State as PluginsState} from '../reducers/plugins';
|
||||||
import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
||||||
import {PluginDefinition} from '../dispatcher/plugins';
|
import {PluginDefinition} from '../dispatcher/plugins';
|
||||||
import {deconstructPluginKey} from './clientUtils';
|
import {deconstructPluginKey, deconstructClientId} from './clientUtils';
|
||||||
|
|
||||||
type Client = import('../Client').default;
|
type Client = import('../Client').default;
|
||||||
|
|
||||||
@@ -64,6 +64,68 @@ export function getPersistedState<PersistedState>(
|
|||||||
return persistedState;
|
return persistedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param starredPlugin starredPlugin is the dictionary of client and its enabled plugin
|
||||||
|
* @param client Optional paramater indicating the selected client.
|
||||||
|
* @param plugins Plugins from the state which has the mapping to Plugin's Class.
|
||||||
|
|
||||||
|
* Returns plugins which are enabled or which has exportPersistedState function defined for the passed client.
|
||||||
|
* Note all device plugins are enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function getEnabledOrExportPersistedStatePlugins(
|
||||||
|
starredPlugin: {
|
||||||
|
[client: string]: string[];
|
||||||
|
},
|
||||||
|
client: Client,
|
||||||
|
plugins: PluginsState,
|
||||||
|
): Array<{id: string; label: string}> {
|
||||||
|
const appName = deconstructClientId(client.id).app;
|
||||||
|
const pluginsMap: Map<
|
||||||
|
string,
|
||||||
|
typeof FlipperDevicePlugin | typeof FlipperPlugin
|
||||||
|
> = pluginsClassMap(plugins);
|
||||||
|
// Enabled Plugins with no exportPersistedState function defined
|
||||||
|
const enabledPlugins = starredPlugin[appName]
|
||||||
|
? starredPlugin[appName]
|
||||||
|
.map(pluginName => pluginsMap.get(pluginName)!)
|
||||||
|
.filter(plugin => {
|
||||||
|
return !plugin.exportPersistedState;
|
||||||
|
})
|
||||||
|
.sort(sortPluginsByName)
|
||||||
|
.map(plugin => {
|
||||||
|
return {id: plugin.id, label: getPluginTitle(plugin)};
|
||||||
|
})
|
||||||
|
: [];
|
||||||
|
// Device Plugins
|
||||||
|
const devicePlugins = Array.from(plugins.devicePlugins.keys())
|
||||||
|
.filter(plugin => {
|
||||||
|
return client.plugins.includes(plugin);
|
||||||
|
})
|
||||||
|
.map(plugin => {
|
||||||
|
return {
|
||||||
|
id: plugin,
|
||||||
|
label: getPluginTitle(plugins.devicePlugins.get(plugin)!),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// Plugins which have defined exportPersistedState.
|
||||||
|
const exportPersistedStatePlugins = client.plugins
|
||||||
|
.filter(name => {
|
||||||
|
return pluginsMap.get(name)?.exportPersistedState != null;
|
||||||
|
})
|
||||||
|
.map(name => {
|
||||||
|
const plugin = pluginsMap.get(name)!;
|
||||||
|
return {id: plugin.id, label: getPluginTitle(plugin)};
|
||||||
|
});
|
||||||
|
return [
|
||||||
|
...devicePlugins,
|
||||||
|
...enabledPlugins,
|
||||||
|
...exportPersistedStatePlugins,
|
||||||
|
{id: 'DeviceLogs', label: 'Logs'},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param pluginsState PluginsState of the Redux Store.
|
* @param pluginsState PluginsState of the Redux Store.
|
||||||
|
|||||||
Reference in New Issue
Block a user