Implement in-context search bar for tech docs. (#6651)
* Implement in-context search bar for tech docs * Add in-context search functionality to tech docs * Use the existing backend search functionality with tech docs specific filters * Use material-ui autocomplete to display 10 first search results * Add tests Signed-off-by: Jussi Hallila <jussi@hallila.com> * Remove context and replace it with `withSearch` prop. Signed-off-by: Jussi Hallila <jussi@hallila.com> * Bump search-common devp to latest Signed-off-by: Jussi Hallila <jussi@hallila.com> * Rename types file to not conflict with hardcoded types.d.ts. Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
@@ -16,12 +16,13 @@
|
||||
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model';
|
||||
import { IndexableDocument, DocumentCollator } from '@backstage/search-common';
|
||||
import { DocumentCollator } from '@backstage/search-common';
|
||||
import fetch from 'cross-fetch';
|
||||
import unescape from 'lodash/unescape';
|
||||
import { Logger } from 'winston';
|
||||
import pLimit from 'p-limit';
|
||||
import { CatalogApi, CatalogClient } from '@backstage/catalog-client';
|
||||
import { TechDocsDocument } from '@backstage/techdocs-common';
|
||||
|
||||
interface MkSearchIndexDoc {
|
||||
title: string;
|
||||
@@ -29,14 +30,6 @@ interface MkSearchIndexDoc {
|
||||
location: string;
|
||||
}
|
||||
|
||||
export interface TechDocsDocument extends IndexableDocument {
|
||||
kind: string;
|
||||
namespace: string;
|
||||
name: string;
|
||||
lifecycle: string;
|
||||
owner: string;
|
||||
}
|
||||
|
||||
export class DefaultTechDocsCollator implements DocumentCollator {
|
||||
protected discovery: PluginEndpointDiscovery;
|
||||
protected locationTemplate: string;
|
||||
@@ -108,6 +101,7 @@ export class DefaultTechDocsCollator implements DocumentCollator {
|
||||
...entityInfo,
|
||||
path: doc.location,
|
||||
}),
|
||||
path: doc.location,
|
||||
...entityInfo,
|
||||
componentType: entity.spec?.type?.toString() || 'other',
|
||||
lifecycle: (entity.spec?.lifecycle as string) || '',
|
||||
|
||||
@@ -14,4 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { DefaultTechDocsCollator } from './DefaultTechDocsCollator';
|
||||
export type { TechDocsDocument } from './DefaultTechDocsCollator';
|
||||
|
||||
/**
|
||||
* @deprecated Use directly from @backstage/techdocs-common
|
||||
*/
|
||||
export type { TechDocsDocument } from '@backstage/techdocs-common';
|
||||
|
||||
Reference in New Issue
Block a user