Uninstall plugins from sidebar
Summary: Added UI for uninstalling plugins from sidebar. To avoid confusion between "disable" and "uninstall" and to reduce possibility of errors when plugins uninstalled accidentally by misclicks, I made it only possible to uninstall plugins after they are disabled. So for enabled plugins two steps are required for uninstalling. Reviewed By: mweststrate Differential Revision: D25454117 fbshipit-source-id: 28e67dc1ff2d39ad67e6d2770302a996affd9723
This commit is contained in:
committed by
Facebook GitHub Bot
parent
97d37abbb2
commit
df03ccbeab
@@ -82,6 +82,9 @@ export function rootReducer(
|
||||
} else {
|
||||
return updateClientPlugin(state, plugin, enablePlugin);
|
||||
}
|
||||
} else if (action.type === 'UNINSTALL_PLUGIN' && state) {
|
||||
const plugin = action.payload;
|
||||
return uninstallPlugin(state, plugin);
|
||||
}
|
||||
|
||||
// otherwise
|
||||
@@ -173,6 +176,24 @@ function updateClientPlugin(
|
||||
});
|
||||
}
|
||||
|
||||
function uninstallPlugin(state: StoreState, plugin: PluginDefinition) {
|
||||
const clients = state.connections.clients;
|
||||
return produce(state, (draft) => {
|
||||
clients.forEach((client) => {
|
||||
stopPlugin(client, plugin.id);
|
||||
const pluginKey = getPluginKey(
|
||||
client.id,
|
||||
{serial: client.query.device_id},
|
||||
plugin.id,
|
||||
);
|
||||
delete draft.pluginMessageQueue[pluginKey];
|
||||
});
|
||||
cleanupPluginStates(draft.pluginStates, plugin.id);
|
||||
draft.plugins.clientPlugins.delete(plugin.id);
|
||||
draft.pluginManager.removedPlugins.push(plugin.details);
|
||||
});
|
||||
}
|
||||
|
||||
function updateDevicePlugin(state: StoreState, plugin: DevicePluginDefinition) {
|
||||
const devices = state.connections.devices;
|
||||
return produce(state, (draft) => {
|
||||
|
||||
Reference in New Issue
Block a user