Check if plugin status before opening
Summary: This diff takes care of current plugin status when handling deeplinks. It checks: 1. if the plugin failed to load 2. if the plugin is behind GK 3. if the plugin is installable from bundle 4. if the plugin is installable from marketplace Reviewed By: passy Differential Revision: D29875483 fbshipit-source-id: 8dac1aab63822f43a0d002b10efa5b4a756fce41
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2cb21f2a06
commit
bf65da0e72
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import type {PluginDefinition} from '../plugin';
|
||||
import type {State} from '../reducers';
|
||||
import type {State, Store} from '../reducers';
|
||||
import type {State as PluginsState} from '../reducers/plugins';
|
||||
import type BaseDevice from '../server/devices/BaseDevice';
|
||||
import type Client from '../Client';
|
||||
@@ -401,3 +401,39 @@ export function computeActivePluginList({
|
||||
}
|
||||
return pluginList;
|
||||
}
|
||||
|
||||
export function getPluginStatus(
|
||||
store: Store,
|
||||
id: string,
|
||||
): [
|
||||
state:
|
||||
| 'ready'
|
||||
| 'unknown'
|
||||
| 'failed'
|
||||
| 'gatekeeped'
|
||||
| 'bundle_installable'
|
||||
| 'marketplace_installable',
|
||||
reason?: string,
|
||||
] {
|
||||
const state: PluginsState = store.getState().plugins;
|
||||
if (state.devicePlugins.has(id) || state.clientPlugins.has(id)) {
|
||||
return ['ready'];
|
||||
}
|
||||
const gateKeepedDetails = state.gatekeepedPlugins.find((d) => d.id === id);
|
||||
if (gateKeepedDetails) {
|
||||
return ['gatekeeped', gateKeepedDetails.gatekeeper];
|
||||
}
|
||||
const failedPluginEntry = state.failedPlugins.find(
|
||||
([details]) => details.id === id,
|
||||
);
|
||||
if (failedPluginEntry) {
|
||||
return ['failed', failedPluginEntry[1]];
|
||||
}
|
||||
if (state.bundledPlugins.has(id)) {
|
||||
return ['bundle_installable'];
|
||||
}
|
||||
if (state.marketplacePlugins.find((d) => d.id === id)) {
|
||||
return ['marketplace_installable'];
|
||||
}
|
||||
return ['unknown'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user