From 542b83963197d39c10d5ffffc213ee217022be30 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 22 Feb 2022 15:28:41 +0100 Subject: [PATCH] change naming of DocsResultListItem -> TechDocsSearchResultListItem to follow pattern Signed-off-by: Emma Indal --- .../app/src/components/search/SearchPage.tsx | 4 +- .../app/src/components/search/SearchPage.tsx | 4 +- .../components/DocsResultListItem/index.ts | 17 --------- .../TechDocsSearchResultListItem.test.tsx} | 15 +++++--- .../TechDocsSearchResultListItem.tsx} | 37 +++++++++++++++---- 5 files changed, 43 insertions(+), 34 deletions(-) delete mode 100644 plugins/techdocs/src/components/DocsResultListItem/index.ts rename plugins/techdocs/src/{components/DocsResultListItem/DocsResultListItem.test.tsx => search/components/TechDocsSearchResultListItem.test.tsx} (84%) rename plugins/techdocs/src/{components/DocsResultListItem/DocsResultListItem.tsx => search/components/TechDocsSearchResultListItem.tsx} (78%) diff --git a/packages/app/src/components/search/SearchPage.tsx b/packages/app/src/components/search/SearchPage.tsx index fe759c9799..65da72d91c 100644 --- a/packages/app/src/components/search/SearchPage.tsx +++ b/packages/app/src/components/search/SearchPage.tsx @@ -38,7 +38,7 @@ import { SearchType, useSearch, } from '@backstage/plugin-search'; -import { DocsResultListItem } from '@backstage/plugin-techdocs'; +import { TechDocsSearchResultListItem } from '@backstage/plugin-techdocs'; import { Grid, List, makeStyles, Paper, Theme } from '@material-ui/core'; import React, { useContext } from 'react'; @@ -143,7 +143,7 @@ const SearchPage = () => { ); case 'techdocs': return ( - diff --git a/packages/create-app/templates/default-app/packages/app/src/components/search/SearchPage.tsx b/packages/create-app/templates/default-app/packages/app/src/components/search/SearchPage.tsx index 469a230ecd..cd4603ecd3 100644 --- a/packages/create-app/templates/default-app/packages/app/src/components/search/SearchPage.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/components/search/SearchPage.tsx @@ -6,7 +6,7 @@ import { catalogApiRef, CATALOG_FILTER_EXISTS, } from '@backstage/plugin-catalog-react'; -import { DocsResultListItem } from '@backstage/plugin-techdocs'; +import { TechDocsSearchResultListItem } from '@backstage/plugin-techdocs'; import { SearchBar, @@ -123,7 +123,7 @@ const SearchPage = () => { ); case 'techdocs': return ( - diff --git a/plugins/techdocs/src/components/DocsResultListItem/index.ts b/plugins/techdocs/src/components/DocsResultListItem/index.ts deleted file mode 100644 index 4e1e511ea1..0000000000 --- a/plugins/techdocs/src/components/DocsResultListItem/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2021 The Backstage Authors - * - * Licensed 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 { DocsResultListItem } from './DocsResultListItem'; diff --git a/plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.test.tsx b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.test.tsx similarity index 84% rename from plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.test.tsx rename to plugins/techdocs/src/search/components/TechDocsSearchResultListItem.test.tsx index 807914c5ad..7ebdd6c340 100644 --- a/plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.test.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.test.tsx @@ -16,7 +16,7 @@ import React from 'react'; import { render } from '@testing-library/react'; -import { DocsResultListItem } from './DocsResultListItem'; +import { TechDocsSearchResultListItem } from './TechDocsSearchResultListItem'; // Using canvas to render text.. jest.mock('react-text-truncate', () => { @@ -44,9 +44,11 @@ const validResultWithTitle = { lifecycle: 'production', }; -describe('DocsResultListItem test', () => { +describe('TechDocsSearchResultListItem test', () => { it('should render search doc passed in', async () => { - const { findByText } = render(); + const { findByText } = render( + , + ); expect( await findByText('Documentation | Backstage docs'), @@ -60,7 +62,10 @@ describe('DocsResultListItem test', () => { it('should use title if defined', async () => { const { findByText } = render( - , + , ); expect(await findByText('Count Dookumentation')).toBeInTheDocument(); @@ -73,7 +78,7 @@ describe('DocsResultListItem test', () => { it('should use entity title if defined', async () => { const { findByText } = render( - , + , ); expect( diff --git a/plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.tsx b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx similarity index 78% rename from plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.tsx rename to plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx index 03cf011c32..152fa2e3d3 100644 --- a/plugins/techdocs/src/components/DocsResultListItem/DocsResultListItem.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx @@ -29,19 +29,34 @@ const useStyles = makeStyles({ }, }); -export const DocsResultListItem = ({ - result, - lineClamp = 5, - asListItem = true, - asLink = true, - title, -}: { +/** + * Props for {@link TechDocsSearchResultListItem}. + * + * @public + */ +export type TechDocsSearchResultListItemProps = { result: any; lineClamp?: number; asListItem?: boolean; asLink?: boolean; title?: string; -}) => { +}; + +/** + * Component which renders documentation and related metadata. + * + * @public + */ +export const TechDocsSearchResultListItem = ( + props: TechDocsSearchResultListItemProps, +) => { + const { + result, + lineClamp = 5, + asListItem = true, + asLink = true, + title, + } = props; const classes = useStyles(); const TextItem = () => ( ); }; + +/** + * @public + * @deprecated use {@link TechDocsSearchResultListItem} instead + */ +export const DocsResultListItem = TechDocsSearchResultListItem;