-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
globalSearch
x-pack plugin (#66293)
* add skeleton for global_search plugin * base implementation of the server-side service * add utils tests * add server-side mocks * move take_in_array to common folder * implements base of client-side plugin * add tests for server-side service * fix server plugin tests * implement `navigateToUrl` core API * extract processResults for the client-side * fetch server results from the client side * factorize process_results * fix plugin start params * move things around * move all server types to single file * fix types imports * add basic FTR tests * add client-side service tests * add tests for addNavigate * add getDefaultPreference & tests * use optional for RequestHandlerContext * add registerRoutes test * add base test for context * resolve TODO * common nits/doc * common nits/doc on public * update CODEOWNERS * add import for declare statement * add license check on the server-side * add license check on the client-side * eslint * address some review comments * use properly typed errors for obs * add integration tests for the find endpoint * fix unit tests * use licensing start contract * translate the error message * fix eslint rule for test_utils * fix test_utils imports * remove NavigableGlobalSearchResult, use `application.navigateToUrl` instead. * use coreProvider plugin in FTR tests * nits * fix service start params * fix service start params, bis * I really need to fix this typecheck oom error * add README, update missing jsdoc * nits on doc
- Loading branch information
1 parent
3d2c3f1
commit c5546f4
Showing
81 changed files
with
3,294 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export type Serializable = | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| SerializableArray | ||
| SerializableRecord; | ||
|
||
// we need interfaces instead of types here to allow cyclic references | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface SerializableArray extends Array<Serializable> {} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface SerializableRecord extends Record<string, Serializable> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Kibana GlobalSearch plugin | ||
|
||
The GlobalSearch plugin provides an easy way to search for various objects, such as applications | ||
or dashboards from the Kibana instance, from both server and client-side plugins | ||
|
||
## Consuming the globalSearch API | ||
|
||
```ts | ||
startDeps.globalSearch.find('some term').subscribe({ | ||
next: ({ results }) => { | ||
addNewResultsToList(results); | ||
}, | ||
error: () => {}, | ||
complete: () => { | ||
showAsyncSearchIndicator(false); | ||
} | ||
}); | ||
``` | ||
|
||
## Registering custom result providers | ||
|
||
The GlobalSearch API allows to extend provided results by registering your own provider. | ||
|
||
```ts | ||
setupDeps.globalSearch.registerResultProvider({ | ||
id: 'my_provider', | ||
find: (term, options, context) => { | ||
const resultPromise = myService.search(term, context.core.savedObjects.client); | ||
return from(resultPromise).pipe(takeUntil(options.aborted$); | ||
}, | ||
}); | ||
``` | ||
## Known limitations | ||
### Client-side registered providers | ||
Results from providers registered from the client-side `registerResultProvider` API will | ||
not be available when performing a search from the server-side. For this reason, prefer | ||
registering providers using the server-side API when possible. | ||
Refer to the [RFC](rfcs/text/0011_global_search.md#result_provider_registration) for more details | ||
### Search completion cause | ||
There is currently no way to identify `globalSearch.find` observable completion cause: | ||
searches completing because all providers returned all their results and searches | ||
completing because the consumer aborted the search using the `aborted$` option or because | ||
the internal timout period has been reaches will both complete the same way. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { GlobalSearchFindError } from './errors'; | ||
|
||
describe('GlobalSearchFindError', () => { | ||
describe('#invalidLicense', () => { | ||
it('create an error with the correct `type`', () => { | ||
const error = GlobalSearchFindError.invalidLicense('foobar'); | ||
expect(error.message).toBe('foobar'); | ||
expect(error.type).toBe('invalid-license'); | ||
}); | ||
|
||
it('can be identified via instanceof', () => { | ||
const error = GlobalSearchFindError.invalidLicense('foo'); | ||
expect(error instanceof GlobalSearchFindError).toBe(true); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.