mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fix where we slice for maxResults (#104661)
This commit is contained in:
parent
ff327bee91
commit
170cb57827
2 changed files with 15 additions and 15 deletions
|
@ -164,18 +164,18 @@ describe('Package search provider', () => {
|
|||
const packageSearchProvider = createPackageSearchProvider(setupMock);
|
||||
expectObservable(
|
||||
packageSearchProvider.find(
|
||||
{ term: 'test' },
|
||||
{ term: 'test1' },
|
||||
{ aborted$: NEVER, maxResults: 1, preference: '' }
|
||||
)
|
||||
).toBe('--(a|)', {
|
||||
a: [
|
||||
{
|
||||
id: 'test-test',
|
||||
id: 'test1-test1',
|
||||
score: 80,
|
||||
title: 'test',
|
||||
title: 'test1',
|
||||
type: 'integration',
|
||||
url: {
|
||||
path: 'undefined#/detail/test-test/overview',
|
||||
path: 'undefined#/detail/test1-test1/overview',
|
||||
prependBasePath: false,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -94,19 +94,19 @@ export const createPackageSearchProvider = (core: CoreSetup): GlobalSearchResult
|
|||
coreStart: CoreStart,
|
||||
packagesResponse: GetPackagesResponse['response']
|
||||
): GlobalSearchProviderResult[] => {
|
||||
const packages = packagesResponse.slice(0, maxResults);
|
||||
return packagesResponse
|
||||
.flatMap(
|
||||
includeAllPackages
|
||||
? (pkg) => toSearchResult(pkg, coreStart.application)
|
||||
: (pkg) => {
|
||||
if (!term || !pkg.title.toLowerCase().includes(term)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return packages.flatMap(
|
||||
includeAllPackages
|
||||
? (pkg) => toSearchResult(pkg, coreStart.application)
|
||||
: (pkg) => {
|
||||
if (!term || !pkg.title.toLowerCase().includes(term)) {
|
||||
return [];
|
||||
return toSearchResult(pkg, coreStart.application);
|
||||
}
|
||||
|
||||
return toSearchResult(pkg, coreStart.application);
|
||||
}
|
||||
);
|
||||
)
|
||||
.slice(0, maxResults);
|
||||
};
|
||||
|
||||
return combineLatest([coreStart$, getPackages$()]).pipe(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue