Sandy-based plugin auto-update UI
Summary: New UX/UI for plugin auto-updates based on Sandy: - disabled plugins auto-updated silently without any notifications as there is no active state for them so there is nothing to loose. - enabled plugins can have some state and user can actually work with them, so we cannot reload them automatically. Instead, we show notification in the top of the plugin container asking user to reload the plugin when she is ready. - if the auto-updated plugin failed to reload - show error notification. - for non-sandy we continue using notifications as before. Reviewed By: mweststrate Differential Revision: D25530384 fbshipit-source-id: de3d0565ef0b930c9343b9e0ed07a4acb51885be
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5383017299
commit
bd01b58566
@@ -9,12 +9,19 @@
|
||||
|
||||
import {Store} from '../reducers/index';
|
||||
import {Logger} from '../fb-interfaces/Logger';
|
||||
import {registerInstalledPlugins} from '../reducers/pluginManager';
|
||||
import {
|
||||
pluginActivationHandled,
|
||||
registerInstalledPlugins,
|
||||
} from '../reducers/pluginManager';
|
||||
import {
|
||||
getInstalledPlugins,
|
||||
cleanupOldInstalledPluginVersions,
|
||||
removePlugins,
|
||||
} from 'flipper-plugin-lib';
|
||||
import {sideEffect} from '../utils/sideEffect';
|
||||
import {requirePlugin} from './plugins';
|
||||
import {registerPluginUpdate} from '../reducers/connections';
|
||||
import {showErrorNotification} from '../utils/notifications';
|
||||
|
||||
const maxInstalledPluginVersionsToKeep = 2;
|
||||
|
||||
@@ -32,4 +39,35 @@ export default (store: Store, _logger: Logger) => {
|
||||
window.requestIdleCallback(() => {
|
||||
refreshInstalledPlugins(store);
|
||||
});
|
||||
|
||||
sideEffect(
|
||||
store,
|
||||
{name: 'handlePluginActivation', throttleMs: 1000, fireImmediately: true},
|
||||
(state) => state.pluginManager.pluginActivationQueue,
|
||||
(queue, store) => {
|
||||
for (const request of queue) {
|
||||
try {
|
||||
const plugin = requirePlugin(request.plugin);
|
||||
const enablePlugin = request.enable;
|
||||
store.dispatch(
|
||||
registerPluginUpdate({
|
||||
plugin,
|
||||
enablePlugin,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`Failed to activate plugin ${request.plugin.title} v${request.plugin.version}`,
|
||||
err,
|
||||
);
|
||||
if (request.notifyIfFailed) {
|
||||
showErrorNotification(
|
||||
`Failed to load plugin "${request.plugin.title}" v${request.plugin.version}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
store.dispatch(pluginActivationHandled(queue.length));
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user