From 505adf271ab49f08467560a3d13c7df0824bae75 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 22 Feb 2022 15:30:41 +0100 Subject: [PATCH] move TechDocsSearch into search components Signed-off-by: Emma Indal --- .../components/TechDocsSearch.test.tsx | 2 +- .../components/TechDocsSearch.tsx | 22 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) rename plugins/techdocs/src/{reader => search}/components/TechDocsSearch.test.tsx (99%) rename plugins/techdocs/src/{reader => search}/components/TechDocsSearch.tsx (92%) diff --git a/plugins/techdocs/src/reader/components/TechDocsSearch.test.tsx b/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx similarity index 99% rename from plugins/techdocs/src/reader/components/TechDocsSearch.test.tsx rename to plugins/techdocs/src/search/components/TechDocsSearch.test.tsx index b4233734aa..06d5ac6aac 100644 --- a/plugins/techdocs/src/reader/components/TechDocsSearch.test.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearch.test.tsx @@ -48,7 +48,7 @@ const singleResult = Promise.resolve({ ], }); -describe('', () => { +describe('', () => { it('should render techdocs search bar', async () => { const query = () => emptyResults; const querySpy = jest.fn(query); diff --git a/plugins/techdocs/src/reader/components/TechDocsSearch.tsx b/plugins/techdocs/src/search/components/TechDocsSearch.tsx similarity index 92% rename from plugins/techdocs/src/reader/components/TechDocsSearch.tsx rename to plugins/techdocs/src/search/components/TechDocsSearch.tsx index 6c0be16f4f..74e2ac554e 100644 --- a/plugins/techdocs/src/reader/components/TechDocsSearch.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearch.tsx @@ -28,7 +28,7 @@ import Autocomplete from '@material-ui/lab/Autocomplete'; import React, { ChangeEvent, useEffect, useState } from 'react'; import { useNavigate } from 'react-router'; import useDebounce from 'react-use/lib/useDebounce'; -import { DocsResultListItem } from '../../components/DocsResultListItem'; +import { TechDocsSearchResultListItem } from '../../search'; const useStyles = makeStyles({ root: { @@ -36,7 +36,12 @@ const useStyles = makeStyles({ }, }); -type TechDocsSearchProps = { +/** + * Props for {@link TechDocsSearch} + * + * @public + */ +export type TechDocsSearchProps = { entityId: EntityName; debounceTime?: number; }; @@ -55,10 +60,8 @@ type TechDocsSearchResult = { document: TechDocsDoc; }; -const TechDocsSearchBar = ({ - entityId, - debounceTime = 150, -}: TechDocsSearchProps) => { +const TechDocsSearchBar = (props: TechDocsSearchProps) => { + const { entityId, debounceTime = 150 } = props; const [open, setOpen] = useState(false); const navigate = useNavigate(); const { @@ -138,7 +141,7 @@ const TechDocsSearchBar = ({ value={null} options={options} renderOption={({ document }) => ( - { const initialState = { term: '',