From effb3b27a40931ea317b0fe2f426d6e4799563d7 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 10 Jun 2022 11:05:41 +0200 Subject: [PATCH] Further review feedback. Signed-off-by: Eric Peterson --- plugins/search-react/api-report.md | 37 +------------------ .../components/SearchBar/SearchBar.test.tsx | 8 ++-- .../src/components/SearchBar/SearchBar.tsx | 14 ++++++- .../src/components/SearchFilter/index.ts | 1 - plugins/search/api-report.md | 12 +++--- .../search/src/components/Filters/Filters.tsx | 8 ++++ .../src/components/Filters/FiltersButton.tsx | 3 ++ 7 files changed, 35 insertions(+), 48 deletions(-) diff --git a/plugins/search-react/api-report.md b/plugins/search-react/api-report.md index ce1fa53bb4..f9bb993fd6 100644 --- a/plugins/search-react/api-report.md +++ b/plugins/search-react/api-report.md @@ -27,7 +27,7 @@ export const AutocompleteFilter: ( // @public (undocumented) export const CheckboxFilter: (props: SearchFilterComponentProps) => JSX.Element; -// @public +// @public (undocumented) export const DefaultResultListItem: ( props: DefaultResultListItemProps, ) => JSX.Element; @@ -168,7 +168,7 @@ export type SearchFilterWrapperProps = SearchFilterComponentProps & { debug?: boolean; }; -// @public +// @public (undocumented) export const SearchResult: (props: SearchResultProps) => JSX.Element; // @public @@ -187,39 +187,6 @@ export type SearchResultProps = { // @public (undocumented) export const SelectFilter: (props: SearchFilterComponentProps) => JSX.Element; -// @public -export const useAsyncFilterValues: ( - fn: ((partial: string) => Promise) | undefined, - inputValue: string, - defaultValues?: string[], - debounce?: number, -) => - | { - loading: boolean; - error?: undefined; - value?: undefined; - } - | { - loading: false; - error: Error; - value?: undefined; - } - | { - loading: true; - error?: Error | undefined; - value?: string[] | undefined; - } - | { - loading: boolean; - value: string[]; - }; - -// @public -export const useDefaultFilterValue: ( - name: string, - defaultValue?: string | string[] | null | undefined, -) => void; - // @public export const useSearch: () => SearchContextValue; diff --git a/plugins/search-react/src/components/SearchBar/SearchBar.test.tsx b/plugins/search-react/src/components/SearchBar/SearchBar.test.tsx index 4e2c4d7a5c..d65278f7ec 100644 --- a/plugins/search-react/src/components/SearchBar/SearchBar.test.tsx +++ b/plugins/search-react/src/components/SearchBar/SearchBar.test.tsx @@ -317,8 +317,8 @@ describe('SearchBar', () => { expect(analyticsApiSpy.getEvents()[0]).toEqual({ action: 'search', context: { - extension: 'App', - pluginId: 'root', + extension: 'SearchBar', + pluginId: 'search', routeRef: 'unknown', searchTypes: 'software-catalog,techdocs', }, @@ -340,8 +340,8 @@ describe('SearchBar', () => { expect(analyticsApiSpy.getEvents()[1]).toEqual({ action: 'search', context: { - extension: 'App', - pluginId: 'root', + extension: 'SearchBar', + pluginId: 'search', routeRef: 'unknown', searchTypes: 'software-catalog,techdocs', }, diff --git a/plugins/search-react/src/components/SearchBar/SearchBar.tsx b/plugins/search-react/src/components/SearchBar/SearchBar.tsx index b3c8ec9fa5..d3d25455ce 100644 --- a/plugins/search-react/src/components/SearchBar/SearchBar.tsx +++ b/plugins/search-react/src/components/SearchBar/SearchBar.tsx @@ -31,7 +31,11 @@ import { import SearchIcon from '@material-ui/icons/Search'; import ClearButton from '@material-ui/icons/Clear'; -import { configApiRef, useApi } from '@backstage/core-plugin-api'; +import { + AnalyticsContext, + configApiRef, + useApi, +} from '@backstage/core-plugin-api'; import { SearchContextProvider, @@ -175,5 +179,11 @@ export const SearchBar = ({ onChange, ...props }: SearchBarProps) => { [onChange, setTerm], ); - return ; + return ( + + + + ); }; diff --git a/plugins/search-react/src/components/SearchFilter/index.ts b/plugins/search-react/src/components/SearchFilter/index.ts index e159cff93d..9f92c7c8e2 100644 --- a/plugins/search-react/src/components/SearchFilter/index.ts +++ b/plugins/search-react/src/components/SearchFilter/index.ts @@ -16,7 +16,6 @@ export { CheckboxFilter, SearchFilter, SelectFilter } from './SearchFilter'; export { AutocompleteFilter } from './SearchFilter.Autocomplete'; -export { useAsyncFilterValues, useDefaultFilterValue } from './hooks'; export type { SearchFilterComponentProps, SearchFilterWrapperProps, diff --git a/plugins/search/api-report.md b/plugins/search/api-report.md index 85d4b783e5..800fa7e7fc 100644 --- a/plugins/search/api-report.md +++ b/plugins/search/api-report.md @@ -22,13 +22,13 @@ export const DefaultResultListItem: ( props: DefaultResultListItemProps, ) => JSX.Element; -// @public (undocumented) +// @public @deprecated (undocumented) export type FilterOptions = { kind: Array; lifecycle: Array; }; -// @public (undocumented) +// @public @deprecated (undocumented) export const Filters: ({ filters, filterOptions, @@ -37,19 +37,19 @@ export const Filters: ({ updateChecked, }: FiltersProps) => JSX.Element; -// @public (undocumented) +// @public @deprecated (undocumented) export const FiltersButton: ({ numberOfSelectedFilters, handleToggleFilters, }: FiltersButtonProps) => JSX.Element; -// @public +// @public @deprecated export type FiltersButtonProps = { numberOfSelectedFilters: number; handleToggleFilters: () => void; }; -// @public +// @public @deprecated export type FiltersProps = { filters: FiltersState; filterOptions: FilterOptions; @@ -58,7 +58,7 @@ export type FiltersProps = { updateChecked: (filter: string) => void; }; -// @public (undocumented) +// @public @deprecated (undocumented) export type FiltersState = { selected: string; checked: Array; diff --git a/plugins/search/src/components/Filters/Filters.tsx b/plugins/search/src/components/Filters/Filters.tsx index 9bbe90d32f..9170961e18 100644 --- a/plugins/search/src/components/Filters/Filters.tsx +++ b/plugins/search/src/components/Filters/Filters.tsx @@ -46,6 +46,8 @@ const useStyles = makeStyles(theme => ({ /** * @public + * @deprecated This type and corresponding component will be removed in a + * future release. */ export type FiltersState = { selected: string; @@ -54,6 +56,8 @@ export type FiltersState = { /** * @public + * @deprecated This type and corresponding component will be removed in a + * future release. */ export type FilterOptions = { kind: Array; @@ -64,6 +68,8 @@ export type FilterOptions = { * Props for {@link Filters}. * * @public + * @deprecated This type and corresponding component will be removed in a + * future release. */ export type FiltersProps = { filters: FiltersState; @@ -75,6 +81,8 @@ export type FiltersProps = { /** * @public + * @deprecated This component will be removed in a future release. Use + * `SearchFilter` from `@backstage/plugin-search-react` instead. */ export const Filters = ({ filters, diff --git a/plugins/search/src/components/Filters/FiltersButton.tsx b/plugins/search/src/components/Filters/FiltersButton.tsx index 8d896bbf30..890c787689 100644 --- a/plugins/search/src/components/Filters/FiltersButton.tsx +++ b/plugins/search/src/components/Filters/FiltersButton.tsx @@ -32,6 +32,8 @@ const useStyles = makeStyles(theme => ({ * Props for {@link FiltersButton}. * * @public + * @deprecated This type and corresponding component will be removed in a + * future release. */ export type FiltersButtonProps = { numberOfSelectedFilters: number; @@ -40,6 +42,7 @@ export type FiltersButtonProps = { /** * @public + * @deprecated See `SearchFilter` in `@backstage/plugin-search-react` instead. */ export const FiltersButton = ({ numberOfSelectedFilters,