From 475f1926528c43b29fed62e13d84e33d98a63496 Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Mon, 24 Jan 2022 16:27:12 +0100 Subject: [PATCH 001/199] Replace deprecated component on docs page Signed-off-by: Eoghan McIlwaine --- docs/plugins/integrating-plugin-into-software-catalog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/integrating-plugin-into-software-catalog.md b/docs/plugins/integrating-plugin-into-software-catalog.md index 71430e25a0..97efa56ac3 100644 --- a/docs/plugins/integrating-plugin-into-software-catalog.md +++ b/docs/plugins/integrating-plugin-into-software-catalog.md @@ -107,7 +107,7 @@ const systemPage = ( - + {/* Adding a new tab to the system view */} From e7dd277232d2417e687b003c6a1e204a9e32dead Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Mon, 24 Jan 2022 16:29:24 +0100 Subject: [PATCH 002/199] Remove EntitySystemDiagramCard code Signed-off-by: Eoghan McIlwaine --- plugins/catalog/src/index.ts | 1 - plugins/catalog/src/plugin.ts | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/plugins/catalog/src/index.ts b/plugins/catalog/src/index.ts index 57dd911b2d..abe34c29b9 100644 --- a/plugins/catalog/src/index.ts +++ b/plugins/catalog/src/index.ts @@ -49,7 +49,6 @@ export { EntityHasSubcomponentsCard, EntityHasSystemsCard, EntityLinksCard, - EntitySystemDiagramCard, RelatedEntitiesCard, } from './plugin'; diff --git a/plugins/catalog/src/plugin.ts b/plugins/catalog/src/plugin.ts index 5a94cd2a09..2e4ebe9570 100644 --- a/plugins/catalog/src/plugin.ts +++ b/plugins/catalog/src/plugin.ts @@ -177,20 +177,6 @@ export const EntityDependsOnResourcesCard = catalogPlugin.provide( }), ); -/** - * @deprecated This component is replaced by EntityCatalogGraphCard which is imported from `@backstage/plugin-catalog-graph`. This component will be removed in an - * upcoming release - */ -export const EntitySystemDiagramCard = catalogPlugin.provide( - createComponentExtension({ - name: 'EntitySystemDiagramCard', - component: { - lazy: () => - import('./components/SystemDiagramCard').then(m => m.SystemDiagramCard), - }, - }), -); - export const RelatedEntitiesCard = catalogPlugin.provide( createComponentExtension({ name: 'RelatedEntitiesCard', From cbe4ab0d204149ac4e6d0019d0a931c81d6b6412 Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Mon, 24 Jan 2022 16:33:21 +0100 Subject: [PATCH 003/199] Remove EntitySystemDiagramCard from api report Signed-off-by: Eoghan McIlwaine --- plugins/catalog/api-report.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index ad391b594f..bc29d9ee14 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -388,12 +388,6 @@ export const EntitySwitch: { }) => null; }; -// Warning: (ae-forgotten-export) The symbol "SystemDiagramCard" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "EntitySystemDiagramCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public @deprecated (undocumented) -export const EntitySystemDiagramCard: SystemDiagramCard; - // Warning: (ae-missing-release-tag) "FilterContainer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) From 37092662cb39757d1ad0c1c7aa1c0d24096e3689 Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Mon, 24 Jan 2022 16:56:35 +0100 Subject: [PATCH 004/199] Add changeset for the code removal Signed-off-by: Eoghan McIlwaine --- .changeset/pink-onions-ring.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pink-onions-ring.md diff --git a/.changeset/pink-onions-ring.md b/.changeset/pink-onions-ring.md new file mode 100644 index 0000000000..c7131721f5 --- /dev/null +++ b/.changeset/pink-onions-ring.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': minor +--- + +**BREAKING** Completely removed the `EntitySystemDiagramCard` component which was previously deprecated. `EntityCatalogGraphCard` should be used instead, as references to `EntitySystemDiagramCard` will now break. From 76b74230bb9869228885db503a7f6caf9e21fb40 Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Mon, 24 Jan 2022 18:34:28 +0100 Subject: [PATCH 005/199] Updated changeset after review comment Signed-off-by: Eoghan McIlwaine --- .changeset/pink-onions-ring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pink-onions-ring.md b/.changeset/pink-onions-ring.md index c7131721f5..9ab8f1ae11 100644 --- a/.changeset/pink-onions-ring.md +++ b/.changeset/pink-onions-ring.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog': minor --- -**BREAKING** Completely removed the `EntitySystemDiagramCard` component which was previously deprecated. `EntityCatalogGraphCard` should be used instead, as references to `EntitySystemDiagramCard` will now break. +**BREAKING** Completely removed the `EntitySystemDiagramCard` component which was deprecated in a previous release. Any remaining references to this component are now broken and should be replaced with `EntityCatalogGraphCard`, which can be imported from package `@backstage/plugin-catalog-graph`. \ No newline at end of file From 973229906208d9c0e9bbb03c9ee83edecc211fab Mon Sep 17 00:00:00 2001 From: Eoghan McIlwaine Date: Tue, 25 Jan 2022 09:58:13 +0100 Subject: [PATCH 006/199] Run prettier on changeset Signed-off-by: Eoghan McIlwaine --- .changeset/pink-onions-ring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pink-onions-ring.md b/.changeset/pink-onions-ring.md index 9ab8f1ae11..2b81ad4b43 100644 --- a/.changeset/pink-onions-ring.md +++ b/.changeset/pink-onions-ring.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog': minor --- -**BREAKING** Completely removed the `EntitySystemDiagramCard` component which was deprecated in a previous release. Any remaining references to this component are now broken and should be replaced with `EntityCatalogGraphCard`, which can be imported from package `@backstage/plugin-catalog-graph`. \ No newline at end of file +**BREAKING** Completely removed the `EntitySystemDiagramCard` component which was deprecated in a previous release. Any remaining references to this component are now broken and should be replaced with `EntityCatalogGraphCard`, which can be imported from package `@backstage/plugin-catalog-graph`. From 811c710a21d65eef0ec0b10eba61b21edf8b8722 Mon Sep 17 00:00:00 2001 From: Jussi Hallila Date: Thu, 3 Feb 2022 12:15:12 +0100 Subject: [PATCH 007/199] Fix tech docs inline search on Postgres Fix bug where tech docs collator stores search indices with wrong entity ref casing. Make the collator to conform legacyPathCasing configuration option. Signed-off-by: Jussi Hallila --- .changeset/hip-carrots-suffer.md | 5 +++++ .../techdocs-backend/src/search/DefaultTechDocsCollator.ts | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .changeset/hip-carrots-suffer.md diff --git a/.changeset/hip-carrots-suffer.md b/.changeset/hip-carrots-suffer.md new file mode 100644 index 0000000000..3823cf982f --- /dev/null +++ b/.changeset/hip-carrots-suffer.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Fix bug where tech docs collator stores search indices with wrong entity ref casing. Make the collator to conform legacyPathCasing configuration option. diff --git a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts index 5149fe6c09..987e8c6b15 100644 --- a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts +++ b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts @@ -145,9 +145,7 @@ export class DefaultTechDocsCollator implements DocumentCollator { path: doc.location, }), path: doc.location, - kind: entity.kind, - namespace: entity.metadata.namespace || 'default', - name: entity.metadata.name, + ...entityInfo, entityTitle: entity.metadata.title, componentType: entity.spec?.type?.toString() || 'other', lifecycle: (entity.spec?.lifecycle as string) || '', From d1eff621051b27472d0cecf3ae9a93f2829b4be5 Mon Sep 17 00:00:00 2001 From: Jussi Hallila Date: Thu, 3 Feb 2022 12:21:54 +0100 Subject: [PATCH 008/199] Fix tests. Signed-off-by: Jussi Hallila --- .../src/search/DefaultTechDocsCollator.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.test.ts b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.test.ts index 7e7545ea1f..e81fc1e7a9 100644 --- a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.test.ts +++ b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.test.ts @@ -198,8 +198,8 @@ describe('DefaultTechDocsCollator', () => { componentType: entity!.spec!.type, lifecycle: entity!.spec!.lifecycle, owner: '', - kind: entity.kind, - name: entity.metadata.name, + kind: entity.kind.toLocaleLowerCase('en-US'), + name: entity.metadata.name.toLocaleLowerCase('en-US'), authorization: { resourceRef: `component:default/${entity.metadata.name}`, }, From d408d210c21b1e638ed16af30b343276035b4d9b Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 4 Feb 2022 14:17:36 +0100 Subject: [PATCH 009/199] Remove duplicated SearchContextProvider Signed-off-by: Vincenzo Scamporlino --- packages/app/src/components/Root/Root.tsx | 9 ++------- packages/core-app-api/src/apis/system/ApiProvider.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/app/src/components/Root/Root.tsx b/packages/app/src/components/Root/Root.tsx index 57f1fa536f..2441ace27b 100644 --- a/packages/app/src/components/Root/Root.tsx +++ b/packages/app/src/components/Root/Root.tsx @@ -34,10 +34,7 @@ import { Settings as SidebarSettings, UserSettingsSignInAvatar, } from '@backstage/plugin-user-settings'; -import { - SidebarSearchModal, - SearchContextProvider, -} from '@backstage/plugin-search'; +import { SidebarSearchModal } from '@backstage/plugin-search'; import { Shortcuts } from '@backstage/plugin-shortcuts'; import { Sidebar, @@ -89,9 +86,7 @@ export const Root = ({ children }: PropsWithChildren<{}>) => ( } to="/search"> - - - + }> diff --git a/packages/core-app-api/src/apis/system/ApiProvider.tsx b/packages/core-app-api/src/apis/system/ApiProvider.tsx index c75f883a51..f1ebf38d71 100644 --- a/packages/core-app-api/src/apis/system/ApiProvider.tsx +++ b/packages/core-app-api/src/apis/system/ApiProvider.tsx @@ -14,7 +14,12 @@ * limitations under the License. */ -import React, { useContext, ReactNode, PropsWithChildren } from 'react'; +import React, { + useContext, + ReactNode, + PropsWithChildren, + useEffect, +} from 'react'; import PropTypes from 'prop-types'; import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiAggregator } from './ApiAggregator'; From 4a4ab7c6034837a59b9781e9f0592c68715d6d4d Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 4 Feb 2022 14:22:29 +0100 Subject: [PATCH 010/199] Invoke search only when SearchModal is visible Signed-off-by: Vincenzo Scamporlino --- .../src/apis/system/ApiProvider.tsx | 7 +-- .../src/components/SearchBar/SearchBar.tsx | 17 ++++--- .../SearchModal/SearchModal.test.tsx | 32 +++++++++++--- .../components/SearchModal/SearchModal.tsx | 44 ++++++++++++------- .../SidebarSearchModal/SidebarSearchModal.tsx | 22 +++++++--- 5 files changed, 81 insertions(+), 41 deletions(-) diff --git a/packages/core-app-api/src/apis/system/ApiProvider.tsx b/packages/core-app-api/src/apis/system/ApiProvider.tsx index f1ebf38d71..c75f883a51 100644 --- a/packages/core-app-api/src/apis/system/ApiProvider.tsx +++ b/packages/core-app-api/src/apis/system/ApiProvider.tsx @@ -14,12 +14,7 @@ * limitations under the License. */ -import React, { - useContext, - ReactNode, - PropsWithChildren, - useEffect, -} from 'react'; +import React, { useContext, ReactNode, PropsWithChildren } from 'react'; import PropTypes from 'prop-types'; import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiAggregator } from './ApiAggregator'; diff --git a/plugins/search/src/components/SearchBar/SearchBar.tsx b/plugins/search/src/components/SearchBar/SearchBar.tsx index 2ddec22294..a203d27c93 100644 --- a/plugins/search/src/components/SearchBar/SearchBar.tsx +++ b/plugins/search/src/components/SearchBar/SearchBar.tsx @@ -169,13 +169,16 @@ export type SearchBarProps = Partial; export const SearchBar = ({ onChange, ...props }: SearchBarProps) => { const { term, setTerm } = useSearch(); - const handleChange = (newValue: string) => { - if (onChange) { - onChange(newValue); - } else { - setTerm(newValue); - } - }; + const handleChange = useCallback( + (newValue: string) => { + if (onChange) { + onChange(newValue); + } else { + setTerm(newValue); + } + }, + [onChange, setTerm], + ); return ; }; diff --git a/plugins/search/src/components/SearchModal/SearchModal.test.tsx b/plugins/search/src/components/SearchModal/SearchModal.test.tsx index b59be710de..d3b2a825e2 100644 --- a/plugins/search/src/components/SearchModal/SearchModal.test.tsx +++ b/plugins/search/src/components/SearchModal/SearchModal.test.tsx @@ -24,7 +24,6 @@ import { rootRouteRef } from '../../plugin'; import { searchApiRef } from '../../apis'; import { SearchModal } from './SearchModal'; -import { SearchContextProvider } from '../SearchContext'; describe('SearchModal', () => { const query = jest.fn().mockResolvedValue({ results: [] }); @@ -34,14 +33,16 @@ describe('SearchModal', () => { [searchApiRef, { query }], ); + beforeEach(() => { + query.mockClear(); + }); + const toggleModal = jest.fn(); it('Should render the Modal correctly', async () => { await renderInTestApp( - - - + , { mountedRoutes: { @@ -51,14 +52,13 @@ describe('SearchModal', () => { ); expect(screen.getByRole('dialog')).toBeInTheDocument(); + expect(query).toHaveBeenCalledTimes(1); }); it('Calls toggleModal handler', async () => { await renderInTestApp( - - - + , { mountedRoutes: { @@ -66,7 +66,25 @@ describe('SearchModal', () => { }, }, ); + + expect(query).toHaveBeenCalledTimes(1); userEvent.keyboard('{esc}'); expect(toggleModal).toHaveBeenCalledTimes(1); }); + + it('should render SearchModal hiding its content', async () => { + const { getByTestId } = await renderInTestApp( + + , + { + mountedRoutes: { + '/search': rootRouteRef, + }, + }, + ); + + expect(getByTestId('search-bar-next')).toBeInTheDocument(); + expect(getByTestId('search-bar-next')).not.toBeVisible(); + }); }); diff --git a/plugins/search/src/components/SearchModal/SearchModal.tsx b/plugins/search/src/components/SearchModal/SearchModal.tsx index 1f0a879f96..ce3f51dac3 100644 --- a/plugins/search/src/components/SearchModal/SearchModal.tsx +++ b/plugins/search/src/components/SearchModal/SearchModal.tsx @@ -39,6 +39,7 @@ import { rootRouteRef } from '../../plugin'; export interface SearchModalProps { open?: boolean; + hidden?: boolean; toggleModal: () => void; } @@ -57,7 +58,7 @@ const useStyles = makeStyles(theme => ({ viewResultsLink: { verticalAlign: '0.5em' }, })); -export const Modal = ({ open = true, toggleModal }: SearchModalProps) => { +export const Modal = ({ toggleModal }: SearchModalProps) => { const getSearchLink = useRouteRef(rootRouteRef); const classes = useStyles(); @@ -75,16 +76,7 @@ export const Modal = ({ open = true, toggleModal }: SearchModalProps) => { }; return ( - + <> @@ -139,14 +131,34 @@ export const Modal = ({ open = true, toggleModal }: SearchModalProps) => { - + ); }; -export const SearchModal = ({ open = true, toggleModal }: SearchModalProps) => { +export const SearchModal = ({ + open = true, + hidden, + toggleModal, +}: SearchModalProps) => { + const classes = useStyles(); + return ( - - - + ); }; diff --git a/plugins/search/src/components/SidebarSearchModal/SidebarSearchModal.tsx b/plugins/search/src/components/SidebarSearchModal/SidebarSearchModal.tsx index b8f20de67d..077ad1016e 100644 --- a/plugins/search/src/components/SidebarSearchModal/SidebarSearchModal.tsx +++ b/plugins/search/src/components/SidebarSearchModal/SidebarSearchModal.tsx @@ -13,30 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react'; +import React, { useCallback, useState } from 'react'; import SearchIcon from '@material-ui/icons/Search'; import { SidebarItem } from '@backstage/core-components'; import { IconComponent } from '@backstage/core-plugin-api'; import { SearchModal } from '../SearchModal'; -import { useSearch } from '../SearchContext'; export type SidebarSearchModalProps = { icon?: IconComponent; }; export const SidebarSearchModal = (props: SidebarSearchModalProps) => { - const { open, toggleModal } = useSearch(); + const [state, setState] = useState({ hidden: true, opened: false }); const Icon = props.icon ? props.icon : SearchIcon; + const handleToggleModal = useCallback( + () => + setState(previousState => ({ + opened: true, + hidden: !previousState.hidden, + })), + [], + ); + return ( <> +