Add a FossaPage that shows the license compliance status of all components in the catalog

Signed-off-by: Dominik Henneke <dominik.henneke@sda-se.com>
This commit is contained in:
Dominik Henneke
2021-04-19 19:58:47 +02:00
parent 94da209767
commit 40d1e11cf3
20 changed files with 1350 additions and 250 deletions
+70 -4
View File
@@ -14,14 +14,19 @@
* limitations under the License.
*/
import { Entity } from '@backstage/catalog-model';
import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model';
import { Content, Header, Page } from '@backstage/core';
import { createDevApp } from '@backstage/dev-utils';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import {
CatalogApi,
catalogApiRef,
EntityProvider,
} from '@backstage/plugin-catalog-react';
import { Grid } from '@material-ui/core';
import React from 'react';
import { EntityFossaCard } from '../src';
import { FossaApi, fossaApiRef } from '../src/api';
import { EntityFossaCard, fossaPlugin } from '../src';
import { FindingSummary, FossaApi, fossaApiRef } from '../src/api';
import { FossaPage } from '../src/components/FossaPage';
import { FOSSA_PROJECT_NAME_ANNOTATION } from '../src/components/useProjectName';
const entity = (name?: string) =>
@@ -34,9 +39,16 @@ const entity = (name?: string) =>
},
name: name,
},
relations: [
{
type: RELATION_OWNED_BY,
target: { kind: 'Group', namespace: 'default', name },
},
],
} as Entity);
createDevApp()
.registerPlugin(fossaPlugin)
.registerApi({
api: fossaApiRef,
deps: {},
@@ -81,8 +93,58 @@ createDevApp()
return undefined;
}
},
getFindingSummaries: async () => {
await new Promise(r => setTimeout(r, 1000));
return new Map<string, FindingSummary>([
[
'zero-deps',
{
timestamp: '2000-01-01T00:00:00Z',
projectUrl: '',
projectDefaultBranch: 'master',
issueCount: 0,
dependencyCount: 0,
},
],
[
'issues',
{
timestamp: '2001-01-01T00:00:00Z',
projectUrl: '',
projectDefaultBranch: 'develop',
issueCount: 10,
dependencyCount: 15,
},
],
[
'no-issues',
{
timestamp: '2002-01-01T00:00:00Z',
projectUrl: '',
projectDefaultBranch: 'master',
issueCount: 0,
dependencyCount: 5,
},
],
]);
},
} as FossaApi),
})
.registerApi({
api: catalogApiRef,
deps: {},
factory: () =>
(({
getEntities: async () => {
await new Promise(r => setTimeout(r, 1000));
return {
items: [entity('zero-deps'), entity('issues'), entity('no-issues')],
};
},
} as Partial<CatalogApi>) as any),
})
.addPage({
title: 'Entity Content',
element: (
@@ -130,4 +192,8 @@ createDevApp()
</Page>
),
})
.addPage({
title: 'Catalog Overview',
element: <FossaPage />,
})
.render();