From 2dc4818541f83cabb855d3d160e6691fff1a2f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20N=C3=A4sman?= Date: Tue, 7 Jun 2022 16:30:04 +0200 Subject: [PATCH] apply review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders Näsman --- .changeset/famous-walls-visit.md | 6 +- .changeset/red-apes-tell.md | 19 +-- .changeset/strange-flies-march.md | 5 + plugins/search-react/api-report.md | 7 - .../DefaultResultListItem.tsx | 2 - .../components/SearchResult/SearchResult.tsx | 2 - .../SearchTracker/SearchTracker.tsx | 2 - plugins/search-react/src/components/index.ts | 1 - plugins/search/api-report.md | 2 +- .../src/components/SearchBar/SearchBar.tsx | 121 ++---------------- .../components/SearchFilter/SearchFilter.tsx | 12 +- .../SearchResultPager/SearchResultPager.tsx | 2 +- scripts/api-extractor.ts | 1 + 13 files changed, 32 insertions(+), 150 deletions(-) create mode 100644 .changeset/strange-flies-march.md diff --git a/.changeset/famous-walls-visit.md b/.changeset/famous-walls-visit.md index 8fcaed4ab0..b57702a392 100644 --- a/.changeset/famous-walls-visit.md +++ b/.changeset/famous-walls-visit.md @@ -1,6 +1,6 @@ --- -'@backstage/plugin-search': minor -'@backstage/plugin-search-react': minor +'@backstage/plugin-search': patch +'@backstage/plugin-search-react': patch --- -Components ``, `` (including ``), `` (including `.Checkbox`, `.Select`, and `.Autocomplete` static prop components), ``, ``, and `` are now exported from `@backstage/plugin-search-react`. They are now deprecated in `@backstage/plugin-search` and will be removed in a future release. +Components ``, `` (including ``), `` (including `.Checkbox`, `.Select`, and `.Autocomplete` static prop components), ``, and `` are now exported from `@backstage/plugin-search-react`. They are now deprecated in `@backstage/plugin-search` and will be removed in a future release. diff --git a/.changeset/red-apes-tell.md b/.changeset/red-apes-tell.md index 61c4a5077e..ee0ace6a4c 100644 --- a/.changeset/red-apes-tell.md +++ b/.changeset/red-apes-tell.md @@ -8,17 +8,10 @@ To upgrade your App, update the following in `packages/app/src/components/search ```diff import { -- SearchBar -- SearchFilter -- SearchResult -SearchType, -- DefaultResultListItem -} from `@backstage/plugin-search`; -import { -+ DefaultResultListItem -+ SearchBar -+ SearchFilter -+ SearchResult -useSearch, -} from `@backstage/plugin-search-react`; + DefaultResultListItem + SearchBar + SearchFilter + SearchResult +- } from `@backstage/plugin-search`; ++ } from `@backstage/plugin-search-react`; ``` diff --git a/.changeset/strange-flies-march.md b/.changeset/strange-flies-march.md new file mode 100644 index 0000000000..70a15b41d9 --- /dev/null +++ b/.changeset/strange-flies-march.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search': minor +--- + +The pre-alpha ``, ``, `etc...` components have been removed. In the unlikely event you were still using/referencing them, please update to using their non-`*Next` equivalents from either `@backstage/plugin-search-react` or `@backstage/plugin-search`. diff --git a/plugins/search-react/api-report.md b/plugins/search-react/api-report.md index 93ed657d85..ce1fa53bb4 100644 --- a/plugins/search-react/api-report.md +++ b/plugins/search-react/api-report.md @@ -187,13 +187,6 @@ export type SearchResultProps = { // @public (undocumented) export const SelectFilter: (props: SearchFilterComponentProps) => JSX.Element; -// @public -export const TrackSearch: ({ - children, -}: { - children: React_2.ReactChild; -}) => JSX.Element; - // @public export const useAsyncFilterValues: ( fn: ((partial: string) => Promise) | undefined, diff --git a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx index 48f12213e4..ff6f3d7fe1 100644 --- a/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx +++ b/plugins/search-react/src/components/DefaultResultListItem/DefaultResultListItem.tsx @@ -101,8 +101,6 @@ export const DefaultResultListItemComponent = ({ }; /** - * A higher order function providing AnalyticsContext to the DefaultResultListItemComponent. - * * @public */ const HigherOrderDefaultResultListItem = ( diff --git a/plugins/search-react/src/components/SearchResult/SearchResult.tsx b/plugins/search-react/src/components/SearchResult/SearchResult.tsx index 54024d546a..46a2dde305 100644 --- a/plugins/search-react/src/components/SearchResult/SearchResult.tsx +++ b/plugins/search-react/src/components/SearchResult/SearchResult.tsx @@ -65,8 +65,6 @@ export const SearchResultComponent = ({ children }: SearchResultProps) => { }; /** - * A higher order function providing AnalyticsContext to the SearchResultComponent. - * * @public */ const HigherOrderSearchResult = (props: SearchResultProps) => { diff --git a/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx b/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx index 8ca7373298..f900e45d45 100644 --- a/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx +++ b/plugins/search-react/src/components/SearchTracker/SearchTracker.tsx @@ -20,8 +20,6 @@ import { useSearch } from '../../context'; /** * Capture search event on term change. - * - * @public */ export const TrackSearch = ({ children }: { children: React.ReactChild }) => { const analytics = useAnalytics(); diff --git a/plugins/search-react/src/components/index.ts b/plugins/search-react/src/components/index.ts index 155a4c3b12..263ca4ad59 100644 --- a/plugins/search-react/src/components/index.ts +++ b/plugins/search-react/src/components/index.ts @@ -19,5 +19,4 @@ export * from './SearchFilter'; export * from './SearchResult'; export * from './SearchResultPager'; export * from './SearchBar'; -export * from './SearchTracker'; export * from './DefaultResultListItem'; diff --git a/plugins/search/api-report.md b/plugins/search/api-report.md index 9e418dd08e..85d4b783e5 100644 --- a/plugins/search/api-report.md +++ b/plugins/search/api-report.md @@ -99,7 +99,7 @@ export const SearchBarBase: ({ inputProps: defaultInputProps, endAdornment: defaultEndAdornment, ...props -}: SearchBarBaseProps) => JSX.Element; +}: SearchBarBaseProps_2) => JSX.Element; // @public @deprecated export type SearchBarBaseProps = Omit & { diff --git a/plugins/search/src/components/SearchBar/SearchBar.tsx b/plugins/search/src/components/SearchBar/SearchBar.tsx index 587478ed46..a854869976 100644 --- a/plugins/search/src/components/SearchBar/SearchBar.tsx +++ b/plugins/search/src/components/SearchBar/SearchBar.tsx @@ -14,36 +14,20 @@ * limitations under the License. */ -import React, { - ChangeEvent, - KeyboardEvent, - useState, - useEffect, - useCallback, -} from 'react'; -import useDebounce from 'react-use/lib/useDebounce'; -import { configApiRef, useApi } from '@backstage/core-plugin-api'; -import { - InputBase, - InputBaseProps, - InputAdornment, - IconButton, -} from '@material-ui/core'; -import SearchIcon from '@material-ui/icons/Search'; -import ClearButton from '@material-ui/icons/Clear'; +import React, { useCallback } from 'react'; + +import { InputBaseProps } from '@material-ui/core'; import { - SearchContextProvider, + SearchBarBase as RealSearchBarBase, useSearch, - useSearchContextCheck, - TrackSearch, } from '@backstage/plugin-search-react'; /** * Props for {@link SearchBarBase}. * * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export type SearchBarBaseProps = Omit & { debounceTime?: number; @@ -59,102 +43,15 @@ export type SearchBarBaseProps = Omit & { * Recommended if you don't use Search Provider or Search Context. * * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ -export const SearchBarBase = ({ - onChange, - onKeyDown, - onSubmit, - debounceTime = 200, - clearButton = true, - fullWidth = true, - value: defaultValue, - inputProps: defaultInputProps = {}, - endAdornment: defaultEndAdornment, - ...props -}: SearchBarBaseProps) => { - const configApi = useApi(configApiRef); - const [value, setValue] = useState(defaultValue as string); - const hasSearchContext = useSearchContextCheck(); - - useEffect(() => { - setValue(prevValue => - prevValue !== defaultValue ? (defaultValue as string) : prevValue, - ); - }, [defaultValue]); - - useDebounce(() => onChange(value), debounceTime, [value]); - - const handleChange = useCallback( - (e: ChangeEvent) => { - setValue(e.target.value); - }, - [setValue], - ); - - const handleKeyDown = useCallback( - (e: KeyboardEvent) => { - if (onKeyDown) onKeyDown(e); - if (onSubmit && e.key === 'Enter') { - onSubmit(); - } - }, - [onKeyDown, onSubmit], - ); - - const handleClear = useCallback(() => { - onChange(''); - }, [onChange]); - - const placeholder = `Search in ${ - configApi.getOptionalString('app.title') || 'Backstage' - }`; - - const startAdornment = ( - - - - - - ); - - const endAdornment = ( - - - - - - ); - - const searchBar = ( - - - - ); - - return hasSearchContext ? ( - searchBar - ) : ( - {searchBar} - ); -}; +export const SearchBarBase = RealSearchBarBase; /** * Props for {@link SearchBar}. * * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export type SearchBarProps = Partial; @@ -162,7 +59,7 @@ export type SearchBarProps = Partial; * Recommended search bar when you use the Search Provider or Search Context. * * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export const SearchBar = ({ onChange, ...props }: SearchBarProps) => { const { term, setTerm } = useSearch(); diff --git a/plugins/search/src/components/SearchFilter/SearchFilter.tsx b/plugins/search/src/components/SearchFilter/SearchFilter.tsx index e7982ca5c4..e58bbd5c14 100644 --- a/plugins/search/src/components/SearchFilter/SearchFilter.tsx +++ b/plugins/search/src/components/SearchFilter/SearchFilter.tsx @@ -25,7 +25,7 @@ import { /** * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export type SearchFilterComponentProps = { className?: string; @@ -48,7 +48,7 @@ export type SearchFilterComponentProps = { /** * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export type SearchFilterWrapperProps = SearchFilterComponentProps & { component: (props: SearchFilterComponentProps) => ReactElement; @@ -57,7 +57,7 @@ export type SearchFilterWrapperProps = SearchFilterComponentProps & { /** * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ const SearchFilter = ({ component: Element, @@ -65,7 +65,7 @@ const SearchFilter = ({ }: SearchFilterWrapperProps) => ; /** - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ SearchFilter.Checkbox = ( props: Omit & @@ -73,7 +73,7 @@ SearchFilter.Checkbox = ( ) => ; /** - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ SearchFilter.Select = ( props: Omit & @@ -86,7 +86,7 @@ SearchFilter.Select = ( * which returns values may be provided instead. * * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ SearchFilter.Autocomplete = (props: SearchAutocompleteFilterProps) => ( diff --git a/plugins/search/src/components/SearchResultPager/SearchResultPager.tsx b/plugins/search/src/components/SearchResultPager/SearchResultPager.tsx index f99b6cf29f..287e485dd1 100644 --- a/plugins/search/src/components/SearchResultPager/SearchResultPager.tsx +++ b/plugins/search/src/components/SearchResultPager/SearchResultPager.tsx @@ -31,7 +31,7 @@ const useStyles = makeStyles(theme => ({ /** * @public - * @deprecated Moved to `@backstage/plugin-search-react`. + * @deprecated Import from `@backstage/plugin-search-react` instead. */ export const SearchResultPager = () => { const { fetchNextPage, fetchPreviousPage } = useSearch(); diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 15e43fb02d..619dafabd4 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -256,6 +256,7 @@ const NO_WARNING_PACKAGES = [ 'plugins/scaffolder-backend-module-rails', 'plugins/scaffolder-backend-module-yeoman', 'plugins/scaffolder-common', + 'plugins/search', 'plugins/search-backend', 'plugins/search-backend-node', 'plugins/search-backend-module-elasticsearch',