From a19cffbeed6e4674dcc2acb1f1f65a97658e4188 Mon Sep 17 00:00:00 2001 From: Jonathan Sundquist Date: Mon, 14 Nov 2022 08:51:14 -0600 Subject: [PATCH 1/2] fix(search): update to only link title in search results Signed-off-by: Jonathan Sundquist --- .changeset/old-tips-cough.md | 9 ++++++ .../src/search/AdrSearchResultListItem.tsx | 20 +++++++----- .../CatalogSearchResultListItem.tsx | 20 +++++++----- .../DefaultResultListItem.tsx | 20 +++++++----- .../StackOverflowSearchResultListItem.tsx | 10 ++++-- .../TechDocsSearchResultListItem.tsx | 32 +++++++++---------- 6 files changed, 67 insertions(+), 44 deletions(-) create mode 100644 .changeset/old-tips-cough.md diff --git a/.changeset/old-tips-cough.md b/.changeset/old-tips-cough.md new file mode 100644 index 0000000000..bcf6de6a53 --- /dev/null +++ b/.changeset/old-tips-cough.md @@ -0,0 +1,9 @@ +--- +'@backstage/plugin-adr': patch +'@backstage/plugin-catalog': patch +'@backstage/plugin-search-react': patch +'@backstage/plugin-stack-overflow': patch +'@backstage/plugin-techdocs': patch +--- + +Update search links to only have header as linkable text diff --git a/plugins/adr/src/search/AdrSearchResultListItem.tsx b/plugins/adr/src/search/AdrSearchResultListItem.tsx index d76f2cca4e..f7d9bcbe57 100644 --- a/plugins/adr/src/search/AdrSearchResultListItem.tsx +++ b/plugins/adr/src/search/AdrSearchResultListItem.tsx @@ -64,20 +64,24 @@ export function AdrSearchResultListItem(props: { }; return ( - + <> + + + ) : ( - result.title + + {result.title} + ) } secondary={ @@ -116,6 +120,6 @@ export function AdrSearchResultListItem(props: { - + ); } diff --git a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx index a7307055c2..27f0698f8d 100644 --- a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx +++ b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx @@ -71,7 +71,7 @@ export function CatalogSearchResultListItem( }; return ( - + <> {props.icon && {props.icon}}
@@ -80,13 +80,17 @@ export function CatalogSearchResultListItem( primaryTypographyProps={{ variant: 'h6' }} primary={ props.highlight?.fields.title ? ( - + + + ) : ( - result.title + + {result.title} + ) } secondary={ @@ -112,6 +116,6 @@ export function CatalogSearchResultListItem(
- + ); } diff --git a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx index f4260525d6..44c83fe5d5 100644 --- a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx +++ b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx @@ -66,20 +66,24 @@ export const DefaultResultListItemComponent = ({ }; return ( - + <> {icon && {icon}} + + + ) : ( - result.title + + {result.title} + ) } secondary={ @@ -106,7 +110,7 @@ export const DefaultResultListItemComponent = ({ {secondaryAction && {secondaryAction}} - + ); }; diff --git a/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem/StackOverflowSearchResultListItem.tsx b/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem/StackOverflowSearchResultListItem.tsx index 581fe34dfb..6a2c8f5889 100644 --- a/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem/StackOverflowSearchResultListItem.tsx +++ b/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem/StackOverflowSearchResultListItem.tsx @@ -47,13 +47,17 @@ export const StackOverflowSearchResultListItem = ( }; return ( - + <> {props.icon && {props.icon}} + {_unescape(title)} + + } secondary={`Author: ${text}`} /> @@ -64,6 +68,6 @@ export const StackOverflowSearchResultListItem = ( - + ); }; diff --git a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx index 430165bf8b..6ae9f12cef 100644 --- a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx @@ -81,6 +81,15 @@ export const TechDocsSearchResultListItem = ( }); }; + const LinkWrapper = ({ children }: PropsWithChildren<{}>) => + asLink ? ( + + {children} + + ) : ( + <>{children} + ); + const TextItem = () => { const resultTitle = highlight?.fields.title ? ( {title} ) : ( - <> + {resultTitle} | {entityTitle ?? resultName} docs - + ) } secondary={ @@ -149,15 +158,6 @@ export const TechDocsSearchResultListItem = ( ); }; - const LinkWrapper = ({ children }: PropsWithChildren<{}>) => - asLink ? ( - - {children} - - ) : ( - <>{children} - ); - const ListItemWrapper = ({ children }: PropsWithChildren<{}>) => asListItem ? ( <> @@ -172,10 +172,8 @@ export const TechDocsSearchResultListItem = ( ); return ( - - - - - + + + ); }; From 81e945d052ad3083cbdd4fbc112a9283bf2ffef5 Mon Sep 17 00:00:00 2001 From: Jonathan Sundquist Date: Tue, 15 Nov 2022 09:24:28 -0600 Subject: [PATCH 2/2] move link outside of ternary Signed-off-by: Jonathan Sundquist --- .../src/search/AdrSearchResultListItem.tsx | 20 ++++++------- .../CatalogSearchResultListItem.tsx | 29 +++++++++---------- .../DefaultResultListItem.tsx | 20 ++++++------- .../TechDocsSearchResultListItem.tsx | 16 +++++----- 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/plugins/adr/src/search/AdrSearchResultListItem.tsx b/plugins/adr/src/search/AdrSearchResultListItem.tsx index f7d9bcbe57..97847ba67b 100644 --- a/plugins/adr/src/search/AdrSearchResultListItem.tsx +++ b/plugins/adr/src/search/AdrSearchResultListItem.tsx @@ -70,19 +70,17 @@ export function AdrSearchResultListItem(props: { className={classes.itemText} primaryTypographyProps={{ variant: 'h6' }} primary={ - highlight?.fields.title ? ( - + + {highlight?.fields.title ? ( - - ) : ( - - {result.title} - - ) + ) : ( + result.title + )} + } secondary={ + + {highlight?.fields.title ? ( - - ) : ( - - {result.title} - - ) + ) : ( + result.title + )} + } secondary={ - props.highlight?.fields.text ? ( + highlight?.fields.text ? ( ) : ( result.text diff --git a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx index 44c83fe5d5..830cb61780 100644 --- a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx +++ b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx @@ -72,19 +72,17 @@ export const DefaultResultListItemComponent = ({ + + {highlight?.fields.title ? ( - - ) : ( - - {result.title} - - ) + ) : ( + result.title + )} + } secondary={ {title} - ) : ( - - {resultTitle} | {entityTitle ?? resultName} docs - - ) + + {title ? ( + title + ) : ( + <> + {resultTitle} | {entityTitle ?? resultName} docs + + )} + } secondary={