From c120e220dd726466829723a073b74def8ae91f90 Mon Sep 17 00:00:00 2001 From: Victor Perera Date: Fri, 8 Oct 2021 17:31:07 -0500 Subject: [PATCH 1/9] EntityFilterType hidden and settled Signed-off-by: Victor Perera --- .../app/.changeset/spotty-mayflies-refuse.md | 5 +++++ .../EntityTypePicker/EntityTypePicker.tsx | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 packages/app/.changeset/spotty-mayflies-refuse.md diff --git a/packages/app/.changeset/spotty-mayflies-refuse.md b/packages/app/.changeset/spotty-mayflies-refuse.md new file mode 100644 index 0000000000..8f98365677 --- /dev/null +++ b/packages/app/.changeset/spotty-mayflies-refuse.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +EntityTypePicker can be hidden and initially settled like EntityKindPicker diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx index bc30bf5b17..799598b5f7 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx @@ -22,7 +22,15 @@ import { useEntityTypeFilter } from '../../hooks/useEntityTypeFilter'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; import { Select } from '@backstage/core-components'; -export const EntityTypePicker = () => { +type EntityTypeFilterProps = { + initialFilter?: string; + hidden?: boolean; +}; + +export const EntityTypePicker = ({ + hidden, + initialFilter, +}: EntityTypeFilterProps) => { const alertApi = useApi(alertApiRef); const { error, availableTypes, selectedTypes, setSelectedTypes } = useEntityTypeFilter(); @@ -34,7 +42,10 @@ export const EntityTypePicker = () => { severity: 'error', }); } - }, [error, alertApi]); + if (initialFilter) { + setSelectedTypes([initialFilter]); + } + }, [error, alertApi, initialFilter, setSelectedTypes]); if (availableTypes.length === 0 || error) return null; @@ -46,7 +57,7 @@ export const EntityTypePicker = () => { })), ]; - return ( + return !hidden ? ( - ) : null; + ); }; diff --git a/plugins/catalog-react/src/components/EntityTypePicker/index.ts b/plugins/catalog-react/src/components/EntityTypePicker/index.ts index 6e888516f3..6e3fc60546 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/index.ts +++ b/plugins/catalog-react/src/components/EntityTypePicker/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export { EntityTypePicker } from './EntityTypePicker'; +export * from './EntityTypePicker'; From 97dc10706f9a8d9f2a42c562880f9f831d16631e Mon Sep 17 00:00:00 2001 From: Victor Perera Date: Thu, 21 Oct 2021 13:50:52 -0500 Subject: [PATCH 5/9] Changes requested fixed Signed-off-by: Victor Perera --- .../src/components/EntityTypePicker/EntityTypePicker.tsx | 8 +++----- .../src/components/EntityTypePicker/index.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx index 4f5cc96463..23451ebcfe 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx @@ -22,15 +22,13 @@ import { useEntityTypeFilter } from '../../hooks/useEntityTypeFilter'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; import { Select } from '@backstage/core-components'; -export type EntityTypeFilterProps = { +type EntityTypeFilterProps = { initialFilter?: string; hidden?: boolean; }; -export const EntityTypePicker = ({ - hidden = false, - initialFilter, -}: EntityTypeFilterProps) => { +export const EntityTypePicker = (props: EntityTypeFilterProps) => { + const { hidden, initialFilter } = props; const alertApi = useApi(alertApiRef); const { error, availableTypes, selectedTypes, setSelectedTypes } = useEntityTypeFilter(); diff --git a/plugins/catalog-react/src/components/EntityTypePicker/index.ts b/plugins/catalog-react/src/components/EntityTypePicker/index.ts index 6e3fc60546..6e888516f3 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/index.ts +++ b/plugins/catalog-react/src/components/EntityTypePicker/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export * from './EntityTypePicker'; +export { EntityTypePicker } from './EntityTypePicker'; From d8396253187c0062d3d3fe88edddbf47996f5eb2 Mon Sep 17 00:00:00 2001 From: Victor Perera Date: Thu, 21 Oct 2021 14:21:03 -0500 Subject: [PATCH 6/9] Update api-report Signed-off-by: Victor Perera --- plugins/catalog-react/api-report.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 705ce3feab..e255ea9974 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -645,14 +645,7 @@ export class EntityTypeFilter implements EntityFilter { readonly value: string | string[]; } -// Warning: (ae-missing-release-tag) "EntityTypeFilterProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type EntityTypeFilterProps = { - initialFilter?: string; - hidden?: boolean; -}; - +// Warning: (ae-forgotten-export) The symbol "EntityTypeFilterProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "EntityTypePicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) From d184e50c50937f00e971b2513e35f64273d18a14 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 25 Oct 2021 10:21:17 +0200 Subject: [PATCH 7/9] chore: updating api report Signed-off-by: blam --- plugins/catalog-react/api-report.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index e255ea9974..77fa821d36 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -649,10 +649,9 @@ export class EntityTypeFilter implements EntityFilter { // Warning: (ae-missing-release-tag) "EntityTypePicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const EntityTypePicker: ({ - hidden, - initialFilter, -}: EntityTypeFilterProps) => JSX.Element | null; +export const EntityTypePicker: ( + props: EntityTypeFilterProps, +) => JSX.Element | null; // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts From 4289ac5322f5316655360352d70f845a5ff6fc13 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 25 Oct 2021 10:34:01 +0200 Subject: [PATCH 8/9] chore: export the types properly and update the api-report Signed-off-by: blam --- plugins/catalog-react/api-report.md | 9 ++++++++- .../src/components/EntityTypePicker/EntityTypePicker.tsx | 2 +- .../src/components/EntityTypePicker/index.ts | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 77fa821d36..361635c891 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -645,7 +645,14 @@ export class EntityTypeFilter implements EntityFilter { readonly value: string | string[]; } -// Warning: (ae-forgotten-export) The symbol "EntityTypeFilterProps" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "EntityTypeFilterProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type EntityTypeFilterProps = { + initialFilter?: string; + hidden?: boolean; +}; + // Warning: (ae-missing-release-tag) "EntityTypePicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx index 23451ebcfe..225193dc93 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx @@ -22,7 +22,7 @@ import { useEntityTypeFilter } from '../../hooks/useEntityTypeFilter'; import { alertApiRef, useApi } from '@backstage/core-plugin-api'; import { Select } from '@backstage/core-components'; -type EntityTypeFilterProps = { +export type EntityTypeFilterProps = { initialFilter?: string; hidden?: boolean; }; diff --git a/plugins/catalog-react/src/components/EntityTypePicker/index.ts b/plugins/catalog-react/src/components/EntityTypePicker/index.ts index 6e888516f3..1124b5c30c 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/index.ts +++ b/plugins/catalog-react/src/components/EntityTypePicker/index.ts @@ -15,3 +15,4 @@ */ export { EntityTypePicker } from './EntityTypePicker'; +export type { EntityTypeFilterProps } from './EntityTypePicker'; From bd7f1e506ca30468b64a5943d0c2bd1fa2b8a370 Mon Sep 17 00:00:00 2001 From: Victor Perera Date: Tue, 26 Oct 2021 16:43:45 -0500 Subject: [PATCH 9/9] Tests fixed Signed-off-by: Victor Perera --- .../src/components/EntityTypePicker/EntityTypePicker.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx index 232f4f250d..8eba11aeca 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.test.tsx @@ -129,7 +129,6 @@ describe('', () => {