Skip to content

Commit

Permalink
feat: implement relations plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dweber019 committed Mar 24, 2024
1 parent 7830d8d commit 2ad9622
Show file tree
Hide file tree
Showing 60 changed files with 2,105 additions and 88 deletions.
6 changes: 6 additions & 0 deletions .changeset/poor-humans-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@dweber019/backstage-plugin-relations-processor': patch
'@dweber019/backstage-plugin-relations': patch
---

Inital release of relations plugin.
36 changes: 35 additions & 1 deletion app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ scaffolder:

catalog:
rules:
- allow: [Component, System, API, Resource, Location, User, Group]
- allow: [Component, System, API, Resource, Location, Group, User]
locations:
# Local example data, file locations are relative to the backend process, typically `packages/backend`
- type: file
Expand All @@ -88,9 +88,43 @@ catalog:
- type: file
target: ../../plugins/accentuate-backend/examples/all.yaml

- type: file
target: ../../plugins/relations-processor/examples/all.yaml

spectralLinter:
openApiRulesetUrl: https://gist.githubusercontent.com/dweber019/a368819668a76363849db6378792e907/raw/backstage-spectral-linter-openapi-ruleset.yaml
asyncApiRulesetUrl: https://gist.githubusercontent.com/dweber019/a368819668a76363849db6378792e907/raw/backstage-spectral-linter-asyncapi-ruleset.yaml

accentuate:
allowedKinds: ['User', 'Group', 'Component', 'Resource', 'System', 'Domain']

relationsProcessor:
relations:
- sourceKind: component
sourceType:
targetKinds:
- user
attribute: applicationOwner
multi: false
pairs:
- incoming: applicationOwnerOf
outgoing: applicationOwnerBy
- incoming: ownerOf
outgoing: ownedBy
- sourceKind: group
targetKinds:
- user
attribute: productOwner
multi: false
pairs:
- incoming: productOwnerOf
outgoing: productOwnerBy
- sourceKind: resource
targetKinds:
- user
- group
attribute: supporter
multi: true
pairs:
- incoming: supporterOf
outgoing: supportedBy
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@dweber019/backstage-plugin-api-docs-module-wsdl": "^0.0.5",
"@dweber019/backstage-plugin-api-docs-spectral-linter": "^0.2.11",
"@dweber019/backstage-plugin-endoflife": "^0.0.3",
"@dweber019/backstage-plugin-relations": "0.0.0",
"@dweber019/backstage-plugin-tips": "^0.0.8",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { Root } from './components/Root';
import { AlertDisplay, OAuthRequestDialog } from '@backstage/core-components';
import { createApp } from '@backstage/app-defaults';
import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
import { RelationsCatalogGraphPage } from '@dweber019/backstage-plugin-relations';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
import { AccentuatePage } from '@dweber019/backstage-plugin-accentuate';
Expand Down Expand Up @@ -103,7 +103,7 @@ const routes = (
{searchPage}
</Route>
<Route path="/settings" element={<UserSettingsPage />} />
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
<Route path="/catalog-graph" element={<RelationsCatalogGraphPage />} />
<Route path="/accentuate" element={<AccentuatePage />} />
</FlatRoutes>
);
Expand Down
36 changes: 30 additions & 6 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ import {
isEndOfLifeAvailable,
} from '@dweber019/backstage-plugin-endoflife';
import { EntityTipsDialog } from '@dweber019/backstage-plugin-tips';
import {
EntityRelationsCard,
EntityRelationsCatalogGraphCard,
} from '@dweber019/backstage-plugin-relations';
import { relationLabels } from './relationLabels';
import {
EntityAccentuateInfo,
isAccentuateEnabled,
Expand Down Expand Up @@ -135,13 +140,16 @@ const overviewContent = (
<EntityAboutCard variant="gridItem" />
</Grid>
<Grid item md={6} xs={12}>
<EntityCatalogGraphCard variant="gridItem" height={400} />
<EntityRelationsCatalogGraphCard variant="gridItem" height={400} />
</Grid>

<Grid item md={4} xs={12}>
<Grid item md={6} xs={12}>
<EntityLinksCard />
</Grid>
<Grid item md={8} xs={12}>
<Grid item md={6} xs={12}>
<EntityRelationsCard />
</Grid>
<Grid item md={6} xs={12}>
<EntityHasSubcomponentsCard variant="gridItem" />
</Grid>
</Grid>
Expand Down Expand Up @@ -270,7 +278,7 @@ const apiPage = (
<EntityAboutCard />
</Grid>
<Grid item md={6} xs={12}>
<EntityCatalogGraphCard variant="gridItem" height={400} />
<EntityRelationsCatalogGraphCard variant="gridItem" height={400} />
</Grid>
<Grid item md={4} xs={12}>
<EntityLinksCard />
Expand Down Expand Up @@ -315,6 +323,16 @@ const userPage = (
<Grid item xs={12} md={6}>
<EntityOwnershipCard variant="gridItem" />
</Grid>
<Grid item md={6} xs={12}>
<EntityRelationsCatalogGraphCard
variant="gridItem"
height={400}
unidirectional={false}
/>
</Grid>
<Grid item md={6} xs={12}>
<EntityRelationsCard relations={relationLabels} />
</Grid>
</Grid>
</EntityLayout.Route>
</EntityLayout>
Expand All @@ -331,6 +349,12 @@ const groupPage = (
<Grid item xs={12} md={6}>
<EntityOwnershipCard variant="gridItem" />
</Grid>
<Grid item md={6} xs={12}>
<EntityRelationsCatalogGraphCard variant="gridItem" height={400} />
</Grid>
<Grid item md={6} xs={12}>
<EntityRelationsCard />
</Grid>
<Grid item xs={12} md={6}>
<EntityMembersListCard />
</Grid>
Expand All @@ -351,7 +375,7 @@ const systemPage = (
<EntityAboutCard variant="gridItem" />
</Grid>
<Grid item md={6} xs={12}>
<EntityCatalogGraphCard variant="gridItem" height={400} />
<EntityRelationsCatalogGraphCard variant="gridItem" height={400} />
</Grid>
<Grid item md={4} xs={12}>
<EntityLinksCard />
Expand Down Expand Up @@ -398,7 +422,7 @@ const domainPage = (
<EntityAboutCard variant="gridItem" />
</Grid>
<Grid item md={6} xs={12}>
<EntityCatalogGraphCard variant="gridItem" height={400} />
<EntityRelationsCatalogGraphCard variant="gridItem" height={400} />
</Grid>
<Grid item md={6}>
<EntityHasSystemsCard variant="gridItem" />
Expand Down
26 changes: 26 additions & 0 deletions packages/app/src/components/catalog/relationLabels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const relationLabels = [
{
name: 'applicationOwnerOf',
label: 'Application owner of',
},
{
name: 'applicationOwnerBy',
label: 'Application owner',
},
{
name: 'productOwnerOf',
label: 'Product owner of',
},
{
name: 'productOwnerBy',
label: 'Product owner',
},
{
name: 'supporterOf',
label: 'Supporter of',
},
{
name: 'supporterBy',
label: 'Supporter',
},
];
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@dweber019/backstage-plugin-accentuate-backend": "^0.0.0",
"@dweber019/backstage-plugin-api-docs-module-wsdl-backend": "^0.0.7",
"@dweber019/backstage-plugin-endoflife-backend": "^0.0.2",
"@dweber019/backstage-plugin-relations-backend": "0.0.0",
"app": "link:../app",
"better-sqlite3": "^9.0.0",
"dockerode": "^3.3.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/plugins/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import { RelationEntitiesProcessor } from '@dweber019/backstage-plugin-relations-backend';
import { AccentuateEntitiesProcessor } from '@dweber019/backstage-plugin-accentuate-backend';

export default async function createPlugin(
Expand All @@ -28,6 +29,7 @@ export default async function createPlugin(
builder.addProcessor(
await AccentuateEntitiesProcessor.fromEnv(envAccentuate),
);
builder.addProcessor(RelationEntitiesProcessor.fromConfig(env));
const { processingEngine, router } = await builder.build();
await processingEngine.start();
return router;
Expand Down
4 changes: 2 additions & 2 deletions plugins/accentuate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"@backstage/cli": "^0.26.1",
"@backstage/dev-utils": "^1.0.29",
"@backstage/test-utils": "^1.5.2",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/lodash": "^4.17.0",
"@types/node": "*",
Expand Down
5 changes: 3 additions & 2 deletions plugins/api-docs-module-wsdl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"@backstage/dev-utils": "^1.0.29",
"@backstage/plugin-api-docs": "^0.11.2",
"@backstage/test-utils": "^1.5.2",
"@testing-library/jest-dom": "^5.16.4",
"@types/react": "^16.13.1 || ^17.0.0"
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0"
},
"files": [
"dist"
Expand Down
4 changes: 2 additions & 2 deletions plugins/api-docs-spectral-linter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"@backstage/cli": "^0.26.1",
"@backstage/dev-utils": "^1.0.29",
"@backstage/test-utils": "^1.5.2",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/node": "*",
"cross-fetch": "^3.1.5",
Expand Down
4 changes: 2 additions & 2 deletions plugins/endoflife/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"@backstage/dev-utils": "^1.0.29",
"@backstage/integration": "^1.9.1",
"@backstage/test-utils": "^1.5.2",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/luxon": "^3.4.0",
"@types/node": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/relations-backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Loading

0 comments on commit 2ad9622

Please sign in to comment.