feat(catalog, app): new api 4 plugins integration
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -29,5 +29,4 @@ export const buildRouteRef = createRouteRef({
|
||||
|
||||
export const plugin = createPlugin({
|
||||
id: 'github-actions',
|
||||
register() {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user