diff --git a/.changeset/giant-phones-exercise.md b/.changeset/giant-phones-exercise.md
new file mode 100644
index 0000000000..b190c2e7f0
--- /dev/null
+++ b/.changeset/giant-phones-exercise.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-fossa': patch
+---
+
+Add `entitiesFilter` option to `FossaPage` to filter entities displayed in the table.
diff --git a/plugins/fossa/api-report.md b/plugins/fossa/api-report.md
index 50e382d3d4..da9d057db4 100644
--- a/plugins/fossa/api-report.md
+++ b/plugins/fossa/api-report.md
@@ -18,10 +18,11 @@ export const EntityFossaCard: ({
variant?: InfoCardVariants | undefined;
}) => JSX.Element;
+// Warning: (ae-forgotten-export) The symbol "FossaPageProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "FossaPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export const FossaPage: () => JSX.Element;
+export const FossaPage: ({ entitiesFilter }: FossaPageProps) => JSX.Element;
// Warning: (ae-missing-release-tag) "fossaPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
diff --git a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx
index 78c8b7bb40..778f5ee9c6 100644
--- a/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx
+++ b/plugins/fossa/src/components/FossaPage/FossaPage.test.tsx
@@ -142,4 +142,38 @@ describe('', () => {
expect(getByText(/0 Issues/i)).toBeInTheDocument();
expect(getByText(/10 Issues/i)).toBeInTheDocument();
});
+
+ it('has configurable entity filter', async () => {
+ const entity: Entity = {
+ apiVersion: 'v1',
+ kind: 'API',
+ metadata: {
+ name: 'my-name-0',
+ annotations: {
+ 'fossa.io/project-name': 'my-name-0',
+ },
+ },
+ };
+
+ fossaApi.getFindingSummaries.mockResolvedValue(new Map());
+ catalogApi.getEntities.mockResolvedValue({ items: [entity] });
+
+ const { getByText } = await renderInTestApp(
+
+
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
+
+ expect(catalogApi.getEntities).toBeCalledWith(
+ expect.objectContaining({
+ filter: { kind: 'API' },
+ }),
+ );
+ expect(getByText(/my-name-0/i)).toBeInTheDocument();
+ });
});
diff --git a/plugins/fossa/src/components/FossaPage/FossaPage.tsx b/plugins/fossa/src/components/FossaPage/FossaPage.tsx
index 3e16085968..fbdaf85717 100644
--- a/plugins/fossa/src/components/FossaPage/FossaPage.tsx
+++ b/plugins/fossa/src/components/FossaPage/FossaPage.tsx
@@ -30,8 +30,8 @@ import { Tooltip } from '@material-ui/core';
import { Skeleton } from '@material-ui/lab';
import { DateTime } from 'luxon';
import * as React from 'react';
-import { useMemo } from 'react';
-import { useAsync } from 'react-use';
+import { useMemo, useState } from 'react';
+import { useAsync, useDeepCompareEffect } from 'react-use';
import { FindingSummary, fossaApiRef } from '../../api';
import { getProjectName } from '../getProjectName';
@@ -166,14 +166,25 @@ const filters: TableFilter[] = [
{ column: 'Branch', type: 'select' },
];
-export const FossaPage = () => {
+export type FossaPageProps = {
+ entitiesFilter?:
+ | Record[]
+ | Record
+ | undefined;
+};
+
+export const FossaPage = ({
+ entitiesFilter = { kind: 'Component' },
+}: FossaPageProps) => {
const catalogApi = useApi(catalogApiRef);
const fossaApi = useApi(fossaApiRef);
+ const [filter, setFilter] = useState(entitiesFilter);
+ useDeepCompareEffect(() => setFilter(entitiesFilter), [entitiesFilter]);
// Get a list of all relevant entities
const { value: entities, loading: entitiesLoading } = useAsync(() => {
return catalogApi.getEntities({
- filter: { kind: 'Component' },
+ filter,
fields: [
'kind',
'metadata.namespace',
@@ -182,7 +193,7 @@ export const FossaPage = () => {
'relations',
],
});
- });
+ }, [filter]);
// get the project names of all entities. the idx of both lists match.
const projectNames = useMemo(