From 98489ad55d9d03bd54c462d9bb5b8f7e9c832940 Mon Sep 17 00:00:00 2001 From: Manabu Mccloskey Date: Mon, 6 Mar 2023 13:55:14 -0800 Subject: [PATCH] restrcuture plugin --- packages/app/src/App.tsx | 2 -- .../app/src/components/catalog/EntityPage.tsx | 5 ++++ plugins/workflows/dev/index.tsx | 24 +++++++++--------- .../ExampleComponent.test.tsx | 0 .../ExampleComponent.tsx | 6 ++--- .../FetchTFState.tsx} | 2 +- .../components/BlueprintComponent/index.ts | 1 + .../terraform.ts | 0 .../src/components/ExampleComponent/index.ts | 1 - .../ExampleFetchComponent.test.tsx | 25 ------------------- .../components/ExampleFetchComponent/index.ts | 1 - plugins/workflows/src/index.ts | 2 +- plugins/workflows/src/plugin.ts | 12 ++++----- plugins/workflows/src/routes.ts | 2 +- 14 files changed, 30 insertions(+), 53 deletions(-) rename plugins/workflows/src/components/{ExampleComponent => BlueprintComponent}/ExampleComponent.test.tsx (100%) rename plugins/workflows/src/components/{ExampleComponent => BlueprintComponent}/ExampleComponent.tsx (91%) rename plugins/workflows/src/components/{ExampleFetchComponent/ExampleFetchComponent.tsx => BlueprintComponent/FetchTFState.tsx} (97%) create mode 100644 plugins/workflows/src/components/BlueprintComponent/index.ts rename plugins/workflows/src/components/{ExampleFetchComponent => BlueprintComponent}/terraform.ts (100%) delete mode 100644 plugins/workflows/src/components/ExampleComponent/index.ts delete mode 100644 plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx delete mode 100644 plugins/workflows/src/components/ExampleFetchComponent/index.ts diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index e561310..056402f 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -33,7 +33,6 @@ import { AppRouter, FlatRoutes } from '@backstage/core-app-api'; import { CatalogGraphPage } from '@backstage/plugin-catalog-graph'; import { RequirePermission } from '@backstage/plugin-permission-react'; import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha'; -import { WorkflowsPage } from '@internal/plugin-workflows'; const app = createApp({ apis, @@ -92,7 +91,6 @@ const routes = ( } /> } /> - } /> ); diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 80c2aa8..f7e3765 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -58,6 +58,8 @@ import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib'; import { EntityKubernetesContent } from '@backstage/plugin-kubernetes'; +import {EntityWorkflowsContent} from '@internal/plugin-workflows' + const techdocsContent = ( @@ -347,6 +349,9 @@ const systemPage = ( + + + ); diff --git a/plugins/workflows/dev/index.tsx b/plugins/workflows/dev/index.tsx index b6cd8ed..bdf809b 100644 --- a/plugins/workflows/dev/index.tsx +++ b/plugins/workflows/dev/index.tsx @@ -1,12 +1,12 @@ -import React from 'react'; -import { createDevApp } from '@backstage/dev-utils'; -import { workflowsPlugin, WorkflowsPage } from '../src/plugin'; - -createDevApp() - .registerPlugin(workflowsPlugin) - .addPage({ - element: , - title: 'Root Page', - path: '/workflows' - }) - .render(); +// import React from 'react'; +// import { createDevApp } from '@backstage/dev-utils'; +// import { workflowsPlugin, EntityWorkflowsContent } from '../src/plugin'; +// +// createDevApp() +// .registerPlugin(workflowsPlugin) +// .addPage({ +// element: , +// title: 'Root Page', +// path: '/workflows' +// }) +// .render(); diff --git a/plugins/workflows/src/components/ExampleComponent/ExampleComponent.test.tsx b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx similarity index 100% rename from plugins/workflows/src/components/ExampleComponent/ExampleComponent.test.tsx rename to plugins/workflows/src/components/BlueprintComponent/ExampleComponent.test.tsx diff --git a/plugins/workflows/src/components/ExampleComponent/ExampleComponent.tsx b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx similarity index 91% rename from plugins/workflows/src/components/ExampleComponent/ExampleComponent.tsx rename to plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx index 1321b87..ceb9ebf 100644 --- a/plugins/workflows/src/components/ExampleComponent/ExampleComponent.tsx +++ b/plugins/workflows/src/components/BlueprintComponent/ExampleComponent.tsx @@ -12,9 +12,9 @@ import { HeaderLabel, SupportButton, } from '@backstage/core-components'; -import { ExampleFetchComponent } from '../ExampleFetchComponent'; +import {FetchTFState} from "./FetchTFState"; -export const ExampleComponent = () => ( +export const BlueprintsComponent = () => (
@@ -42,7 +42,7 @@ export const ExampleComponent = () => ( - + diff --git a/plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx similarity index 97% rename from plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx rename to plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx index 693d619..9ed123b 100644 --- a/plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx +++ b/plugins/workflows/src/components/BlueprintComponent/FetchTFState.tsx @@ -52,7 +52,7 @@ export const TFTable = (props: TFTableProps) => { ); } -export const ExampleFetchComponent = () => { +export const FetchTFState = () => { const tfdata = tfstate as TFState const resources = tfdata.resources.map(value => { diff --git a/plugins/workflows/src/components/BlueprintComponent/index.ts b/plugins/workflows/src/components/BlueprintComponent/index.ts new file mode 100644 index 0000000..21a7bb5 --- /dev/null +++ b/plugins/workflows/src/components/BlueprintComponent/index.ts @@ -0,0 +1 @@ +export { BlueprintsComponent } from './ExampleComponent'; diff --git a/plugins/workflows/src/components/ExampleFetchComponent/terraform.ts b/plugins/workflows/src/components/BlueprintComponent/terraform.ts similarity index 100% rename from plugins/workflows/src/components/ExampleFetchComponent/terraform.ts rename to plugins/workflows/src/components/BlueprintComponent/terraform.ts diff --git a/plugins/workflows/src/components/ExampleComponent/index.ts b/plugins/workflows/src/components/ExampleComponent/index.ts deleted file mode 100644 index 8b84375..0000000 --- a/plugins/workflows/src/components/ExampleComponent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ExampleComponent } from './ExampleComponent'; diff --git a/plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx deleted file mode 100644 index a553ecd..0000000 --- a/plugins/workflows/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import { ExampleFetchComponent } from './ExampleFetchComponent'; -import { rest } from 'msw'; -import { setupServer } from 'msw/node'; -import { setupRequestMockHandlers } from '@backstage/test-utils'; - -describe('ExampleFetchComponent', () => { - const server = setupServer(); - // Enable sane handlers for network requests - setupRequestMockHandlers(server); - - // setup mock response - beforeEach(() => { - server.use( - rest.get('https://randomuser.me/*', (_, res, ctx) => - res(ctx.status(200), ctx.delay(2000), ctx.json({})), - ), - ); - }); - it('should render', async () => { - await render(); - expect(await screen.findByTestId('progress')).toBeInTheDocument(); - }); -}); diff --git a/plugins/workflows/src/components/ExampleFetchComponent/index.ts b/plugins/workflows/src/components/ExampleFetchComponent/index.ts deleted file mode 100644 index 41a43e8..0000000 --- a/plugins/workflows/src/components/ExampleFetchComponent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ExampleFetchComponent } from './ExampleFetchComponent'; diff --git a/plugins/workflows/src/index.ts b/plugins/workflows/src/index.ts index 1f093e7..cca6659 100644 --- a/plugins/workflows/src/index.ts +++ b/plugins/workflows/src/index.ts @@ -1 +1 @@ -export { workflowsPlugin, WorkflowsPage } from './plugin'; +export { workflowsPlugin, EntityWorkflowsContent } from './plugin'; diff --git a/plugins/workflows/src/plugin.ts b/plugins/workflows/src/plugin.ts index 7a2fba3..13a9b55 100644 --- a/plugins/workflows/src/plugin.ts +++ b/plugins/workflows/src/plugin.ts @@ -1,19 +1,19 @@ import { createPlugin, createRoutableExtension } from '@backstage/core-plugin-api'; -import { rootRouteRef } from './routes'; +import { rootCatalogWorkflowsRouteRef } from './routes'; export const workflowsPlugin = createPlugin({ id: 'workflows', routes: { - root: rootRouteRef, + entityContent: rootCatalogWorkflowsRouteRef, }, }); -export const WorkflowsPage = workflowsPlugin.provide( +export const EntityWorkflowsContent = workflowsPlugin.provide( createRoutableExtension({ - name: 'WorkflowsPage', + name: 'EntityWorkflowsContent', component: () => - import('./components/ExampleComponent').then(m => m.ExampleComponent), - mountPoint: rootRouteRef, + import('./components/BlueprintComponent').then(m => m.BlueprintsComponent), + mountPoint: rootCatalogWorkflowsRouteRef, }), ); diff --git a/plugins/workflows/src/routes.ts b/plugins/workflows/src/routes.ts index 85716d2..65d7b7a 100644 --- a/plugins/workflows/src/routes.ts +++ b/plugins/workflows/src/routes.ts @@ -1,5 +1,5 @@ import { createRouteRef } from '@backstage/core-plugin-api'; -export const rootRouteRef = createRouteRef({ +export const rootCatalogWorkflowsRouteRef = createRouteRef({ id: 'workflows', });