Fix search by query in Plugin Manager
Summary: I accidently broke search by query in a previous diff, so fixing it here Reviewed By: passy Differential Revision: D23842187 fbshipit-source-id: 9fcc7a46048ff99e1bf26c8a70ef0240b38018cb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e7fdd8332d
commit
dfbf66408a
@@ -345,7 +345,7 @@ function useNPMSearch(
|
|||||||
(async () => {
|
(async () => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
const updatablePlugins = await reportPlatformFailures(
|
const updatablePlugins = await reportPlatformFailures(
|
||||||
getUpdatablePlugins(),
|
getUpdatablePlugins(query),
|
||||||
`${TAG}:queryIndex`,
|
`${TAG}:queryIndex`,
|
||||||
);
|
);
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import getPluginDetails from './getPluginDetails';
|
|||||||
import {getPluginInstallationDir} from './pluginInstaller';
|
import {getPluginInstallationDir} from './pluginInstaller';
|
||||||
import pmap from 'p-map';
|
import pmap from 'p-map';
|
||||||
import {notNull} from './typeUtils';
|
import {notNull} from './typeUtils';
|
||||||
|
const npmApi = new NpmApi();
|
||||||
|
|
||||||
export type UpdateResult =
|
export type UpdateResult =
|
||||||
| {kind: 'not-installed'; version: string}
|
| {kind: 'not-installed'; version: string}
|
||||||
@@ -30,8 +31,9 @@ export type UpdatablePlugin = {
|
|||||||
|
|
||||||
export type UpdatablePluginDetails = PluginDetails & UpdatablePlugin;
|
export type UpdatablePluginDetails = PluginDetails & UpdatablePlugin;
|
||||||
|
|
||||||
export async function getUpdatablePlugins(): Promise<UpdatablePluginDetails[]> {
|
export async function getUpdatablePlugins(
|
||||||
const npmApi = new NpmApi();
|
query?: string,
|
||||||
|
): Promise<UpdatablePluginDetails[]> {
|
||||||
const installedPlugins = await getInstalledPlugins();
|
const installedPlugins = await getInstalledPlugins();
|
||||||
const npmHostedPlugins = new Map<string, NpmPackageDescriptor>(
|
const npmHostedPlugins = new Map<string, NpmPackageDescriptor>(
|
||||||
(await getNpmHostedPlugins()).map((p) => [p.name, p]),
|
(await getNpmHostedPlugins()).map((p) => [p.name, p]),
|
||||||
@@ -119,5 +121,12 @@ export async function getUpdatablePlugins(): Promise<UpdatablePluginDetails[]> {
|
|||||||
...annotatedNotInstalledPlugins
|
...annotatedNotInstalledPlugins
|
||||||
.filter(notNull)
|
.filter(notNull)
|
||||||
.sort((p1, p2) => p1.name.localeCompare(p2.name)),
|
.sort((p1, p2) => p1.name.localeCompare(p2.name)),
|
||||||
];
|
].filter(
|
||||||
|
(p) =>
|
||||||
|
!query ||
|
||||||
|
p.name.includes(query) ||
|
||||||
|
p.id.includes(query) ||
|
||||||
|
p.description?.includes(query) ||
|
||||||
|
p.title?.includes(query),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user