feat(catalog, app): new api 4 plugins integration

This commit is contained in:
Ivan Shmidt
2020-08-31 14:30:01 +02:00
parent e76d33e97d
commit 43ac2c0af7
23 changed files with 492 additions and 686 deletions
+25 -12
View File
@@ -19,16 +19,29 @@ import { Routes, Route } from 'react-router';
import { rootRouteRef, buildRouteRef } from './plugin';
import { WorkflowRunDetails } from './components/WorkflowRunDetails';
import { WorkflowRunsTable } from './components/WorkflowRunsTable';
import { GITHUB_ACTIONS_ANNOTATION } from './components/useProjectName';
import { WarningPanel } from '@backstage/core';
export const GitHubActionsPlugin = ({ entity }: { entity: Entity }) => (
<Routes>
<Route
path={`/${rootRouteRef.path}`}
element={<WorkflowRunsTable entity={entity} />}
/>
<Route
path={`/${buildRouteRef.path}`}
element={<WorkflowRunDetails entity={entity} />}
/>
</Routes>
);
const isPluginApplicableToEntity = (entity: Entity) =>
Boolean(entity?.metadata?.annotations?.[GITHUB_ACTIONS_ANNOTATION]) &&
entity?.metadata?.annotations?.[GITHUB_ACTIONS_ANNOTATION] !== '';
export const GitHubActionsPage = ({ entity }: { entity: Entity }) =>
!isPluginApplicableToEntity(entity) ? (
<WarningPanel title=" GitHubActions plugin:">
`entity.metadata.annotations['
{GITHUB_ACTIONS_ANNOTATION}']` key is missing on the entity.{' '}
</WarningPanel>
) : (
<Routes>
<Route
path={`/${rootRouteRef.path}`}
element={<WorkflowRunsTable entity={entity} />}
/>
<Route
path={`/${buildRouteRef.path}`}
element={<WorkflowRunDetails entity={entity} />}
/>
)
</Routes>
);
+1 -1
View File
@@ -17,5 +17,5 @@
export { plugin } from './plugin';
export * from './api';
export { Widget } from './components/Widget';
export { GitHubActionsPlugin } from './Router';
export { GitHubActionsPage } from './Router';
export { GITHUB_ACTIONS_ANNOTATION } from './components/useProjectName';
-1
View File
@@ -29,5 +29,4 @@ export const buildRouteRef = createRouteRef({
export const plugin = createPlugin({
id: 'github-actions',
register() {},
});