Device plugin management (2/n): enable/disable, install/uninstall
Summary: *Stack summary*: this stack adds ability to manage device plugins in the same way as client plugins: install, update, uninstall, enable (star) and disable (unstar) them. *Diff summary*: implemented all plugin management actions for device plugins. Changelog: it is now possible to enable/disable and install/uninstall device plugins Reviewed By: mweststrate Differential Revision: D26337377 fbshipit-source-id: 7d1ed61a8dc5f3339e5e548c613b67bca0c27f4f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
899fcd0783
commit
4541cdc23b
@@ -62,6 +62,23 @@ type MockOptions = Partial<{
|
||||
supportedPlugins?: string[];
|
||||
}>;
|
||||
|
||||
function isPluginEnabled(
|
||||
store: Store,
|
||||
pluginClazz: PluginDefinition,
|
||||
selectedApp: string,
|
||||
) {
|
||||
return (
|
||||
(!isDevicePluginDefinition(pluginClazz) &&
|
||||
store
|
||||
.getState()
|
||||
.connections.userStarredPlugins[selectedApp]?.includes(
|
||||
pluginClazz.id,
|
||||
)) ||
|
||||
(isDevicePluginDefinition(pluginClazz) &&
|
||||
store.getState().connections.userStarredDevicePlugins.has(pluginClazz.id))
|
||||
);
|
||||
}
|
||||
|
||||
export async function createMockFlipperWithPlugin(
|
||||
pluginClazz: PluginDefinition,
|
||||
options?: MockOptions,
|
||||
@@ -89,14 +106,7 @@ export async function createMockFlipperWithPlugin(
|
||||
backgroundPlugins: options?.asBackgroundPlugin ? [pluginClazz.id] : [],
|
||||
});
|
||||
// enable the plugin
|
||||
if (
|
||||
!isDevicePluginDefinition(pluginClazz) &&
|
||||
!store
|
||||
.getState()
|
||||
.connections.userStarredPlugins[client.query.app]?.includes(
|
||||
pluginClazz.id,
|
||||
)
|
||||
) {
|
||||
if (!isPluginEnabled(store, pluginClazz, name)) {
|
||||
store.dispatch(
|
||||
starPlugin({
|
||||
plugin: pluginClazz,
|
||||
@@ -106,7 +116,7 @@ export async function createMockFlipperWithPlugin(
|
||||
}
|
||||
if (!options?.dontEnableAdditionalPlugins) {
|
||||
options?.additionalPlugins?.forEach((plugin) => {
|
||||
if (!isDevicePluginDefinition(plugin)) {
|
||||
if (!isPluginEnabled(store, plugin, name)) {
|
||||
store.dispatch(
|
||||
starPlugin({
|
||||
plugin,
|
||||
|
||||
Reference in New Issue
Block a user