Make sure Sandy Devices Plugins are loaded in Flipper devices
Summary: This diff makes sure that devices will actually instantiate applicable sandy device plugins. Similar to how client plugins are owned by Client, device plugins are directly owned by BaseDevice, which significantly simplifies life cycle management and doesn't dispatch updates to all Redux connect components whenever something irrelevant changes. Also made sure `device.teardown()` is called. That API already existed, but wasn't used or implemented before. Updated Flipper test utils to support testing device plugins as well (both Sandy and classic ones) Reviewed By: passy, nikoant Differential Revision: D22693929 fbshipit-source-id: 73b2b8666ef7a0e748ea89360db84734d37eb5be
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1e956e1bf5
commit
489dd1521e
@@ -34,7 +34,7 @@ import {Logger} from '../fb-interfaces/Logger';
|
||||
import {PluginDefinition} from '../plugin';
|
||||
import {registerPlugins} from '../reducers/plugins';
|
||||
import PluginContainer from '../PluginContainer';
|
||||
import {getPluginKey} from '../utils/pluginUtils';
|
||||
import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils';
|
||||
import {getInstance} from '../fb-stubs/Logger';
|
||||
|
||||
type MockFlipperResult = {
|
||||
@@ -75,6 +75,7 @@ export async function createMockFlipperWithPlugin(
|
||||
type: 'REGISTER_DEVICE',
|
||||
payload: device,
|
||||
});
|
||||
device.loadDevicePlugins(store.getState().plugins.devicePlugins);
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ export async function createMockFlipperWithPlugin(
|
||||
null, // create a stub connection to avoid this plugin to be archived?
|
||||
logger,
|
||||
store,
|
||||
[pluginClazz.id],
|
||||
isDevicePluginDefinition(pluginClazz) ? [] : [pluginClazz.id],
|
||||
device,
|
||||
);
|
||||
|
||||
@@ -125,10 +126,7 @@ export async function createMockFlipperWithPlugin(
|
||||
case 'getPlugins':
|
||||
// assuming this plugin supports all plugins for now
|
||||
return {
|
||||
plugins: [
|
||||
...store.getState().plugins.clientPlugins.keys(),
|
||||
...store.getState().plugins.devicePlugins.keys(),
|
||||
],
|
||||
plugins: [...store.getState().plugins.clientPlugins.keys()],
|
||||
};
|
||||
case 'getBackgroundPlugins':
|
||||
return {plugins: []};
|
||||
@@ -142,6 +140,7 @@ export async function createMockFlipperWithPlugin(
|
||||
|
||||
// enable the plugin
|
||||
if (
|
||||
!isDevicePluginDefinition(pluginClazz) &&
|
||||
!store
|
||||
.getState()
|
||||
.connections.userStarredPlugins[client.query.app]?.includes(
|
||||
|
||||
Reference in New Issue
Block a user