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
@@ -9,11 +9,17 @@
|
||||
|
||||
import {Store} from '../reducers/index';
|
||||
import {Logger} from '../fb-interfaces/Logger';
|
||||
import {registerInstalledPlugins} from '../reducers/pluginManager';
|
||||
import {
|
||||
pluginFilesRemoved,
|
||||
registerInstalledPlugins,
|
||||
} from '../reducers/pluginManager';
|
||||
import {
|
||||
getInstalledPlugins,
|
||||
cleanupOldInstalledPluginVersions,
|
||||
removePlugin,
|
||||
} from 'flipper-plugin-lib';
|
||||
import {sideEffect} from '../utils/sideEffect';
|
||||
import pMap from 'p-map';
|
||||
|
||||
const maxInstalledPluginVersionsToKeep = 2;
|
||||
|
||||
@@ -28,4 +34,26 @@ export default (store: Store, _logger: Logger) => {
|
||||
window.requestIdleCallback(() => {
|
||||
refreshInstalledPlugins(store);
|
||||
});
|
||||
|
||||
sideEffect(
|
||||
store,
|
||||
{
|
||||
name: 'removeUninstalledPluginFiles',
|
||||
throttleMs: 1000,
|
||||
fireImmediately: true,
|
||||
},
|
||||
(state) => state.pluginManager.removedPlugins,
|
||||
(removedPlugins) => {
|
||||
pMap(removedPlugins, (p) => {
|
||||
removePlugin(p.name)
|
||||
.then(() => pluginFilesRemoved(p))
|
||||
.catch((e) =>
|
||||
console.error(
|
||||
`Error while removing files of uninstalled plugin ${p.title}`,
|
||||
e,
|
||||
),
|
||||
);
|
||||
}).then(() => refreshInstalledPlugins(store));
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user