diff --git a/.changeset/cyan-lions-float.md b/.changeset/cyan-lions-float.md
new file mode 100644
index 0000000000..f5fa064b71
--- /dev/null
+++ b/.changeset/cyan-lions-float.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-graphiql': patch
+---
+
+Finalized composability API migration, now exporting the plugin as `graphiqlPlugin`.
diff --git a/.changeset/silent-readers-worry.md b/.changeset/silent-readers-worry.md
new file mode 100644
index 0000000000..866485ecc0
--- /dev/null
+++ b/.changeset/silent-readers-worry.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-sonarqube': patch
+---
+
+Migrate to new composability API, exporting the plugin as `sonarQubePlugin` and card as `EntitySonarQubeCard`.
diff --git a/.changeset/stale-zebras-warn.md b/.changeset/stale-zebras-warn.md
new file mode 100644
index 0000000000..33b53d3f75
--- /dev/null
+++ b/.changeset/stale-zebras-warn.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-welcome': patch
+---
+
+Migrated to new composability API, exporting the plugin as `welcomePlugin` and the page as `WelcomePage`.
diff --git a/plugins/graphiql/dev/index.tsx b/plugins/graphiql/dev/index.tsx
index b93995a5dc..918695e0e0 100644
--- a/plugins/graphiql/dev/index.tsx
+++ b/plugins/graphiql/dev/index.tsx
@@ -14,12 +14,18 @@
* limitations under the License.
*/
+import React from 'react';
import { createDevApp } from '@backstage/dev-utils';
import { githubAuthApiRef, errorApiRef } from '@backstage/core';
-import { plugin, GraphQLEndpoints, graphQlBrowseApiRef } from '../src';
+import {
+ graphiqlPlugin,
+ GraphQLEndpoints,
+ graphQlBrowseApiRef,
+ GraphiQLPage,
+} from '../src';
createDevApp()
- .registerPlugin(plugin)
+ .registerPlugin(graphiqlPlugin)
.registerApi({
api: graphQlBrowseApiRef,
deps: {
@@ -47,4 +53,8 @@ createDevApp()
]);
},
})
+ .addPage({
+ title: 'GraphiQL',
+ element: ,
+ })
.render();
diff --git a/plugins/graphiql/src/index.ts b/plugins/graphiql/src/index.ts
index 4b1da14079..ed64779eba 100644
--- a/plugins/graphiql/src/index.ts
+++ b/plugins/graphiql/src/index.ts
@@ -14,7 +14,11 @@
* limitations under the License.
*/
-export { plugin, GraphiQLPage } from './plugin';
+export {
+ graphiqlPlugin,
+ graphiqlPlugin as plugin,
+ GraphiQLPage,
+} from './plugin';
export { GraphiQLPage as Router } from './components';
export * from './lib/api';
export * from './route-refs';
diff --git a/plugins/graphiql/src/plugin.test.ts b/plugins/graphiql/src/plugin.test.ts
index 0841d3e071..3683c0be0a 100644
--- a/plugins/graphiql/src/plugin.test.ts
+++ b/plugins/graphiql/src/plugin.test.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { plugin } from './plugin';
+import { graphiqlPlugin } from './plugin';
describe('graphiql', () => {
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(graphiqlPlugin).toBeDefined();
});
});
diff --git a/plugins/graphiql/src/plugin.ts b/plugins/graphiql/src/plugin.ts
index 87f750b132..42969999d9 100644
--- a/plugins/graphiql/src/plugin.ts
+++ b/plugins/graphiql/src/plugin.ts
@@ -22,7 +22,7 @@ import {
import { graphQlBrowseApiRef, GraphQLEndpoints } from './lib/api';
import { graphiQLRouteRef } from './route-refs';
-export const plugin = createPlugin({
+export const graphiqlPlugin = createPlugin({
id: 'graphiql',
apis: [
// GitLab is used as an example endpoint, but most will want to plug in
@@ -40,7 +40,7 @@ export const plugin = createPlugin({
],
});
-export const GraphiQLPage = plugin.provide(
+export const GraphiQLPage = graphiqlPlugin.provide(
createRoutableExtension({
component: () => import('./components').then(m => m.GraphiQLPage),
mountPoint: graphiQLRouteRef,
diff --git a/plugins/sonarqube/dev/index.tsx b/plugins/sonarqube/dev/index.tsx
index 5e8aedd577..2dd9236547 100644
--- a/plugins/sonarqube/dev/index.tsx
+++ b/plugins/sonarqube/dev/index.tsx
@@ -15,21 +15,61 @@
*/
import { Entity } from '@backstage/catalog-model';
-import {
- Content,
- createPlugin,
- createRouteRef,
- Header,
- Page,
-} from '@backstage/core';
-import { createDevApp } from '@backstage/dev-utils';
+import { Content, Header, Page } from '@backstage/core';
+import { createDevApp, EntityGridItem } from '@backstage/dev-utils';
import { Grid } from '@material-ui/core';
import React from 'react';
-import { SonarQubeCard } from '../src';
+import { EntitySonarQubeCard, sonarQubePlugin } from '../src';
import { FindingSummary, SonarQubeApi, sonarQubeApiRef } from '../src/api';
import { SONARQUBE_PROJECT_KEY_ANNOTATION } from '../src/components/useProjectKey';
+const entity = (name?: string) =>
+ ({
+ apiVersion: 'backstage.io/v1alpha1',
+ kind: 'Component',
+ metadata: {
+ annotations: {
+ [SONARQUBE_PROJECT_KEY_ANNOTATION]: name,
+ },
+ name: name,
+ },
+ } as Entity);
+
createDevApp()
+ .registerPlugin(sonarQubePlugin)
+ .addPage({
+ title: 'Cards',
+ element: (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ),
+ })
.registerApi({
api: sonarQubeApiRef,
deps: {},
@@ -114,58 +154,4 @@ createDevApp()
},
} as SonarQubeApi),
})
- .registerPlugin(
- createPlugin({
- id: 'defectdojo-demo',
- register({ router }) {
- const entity = (name?: string) =>
- ({
- apiVersion: 'backstage.io/v1alpha1',
- kind: 'Component',
- metadata: {
- annotations: {
- [SONARQUBE_PROJECT_KEY_ANNOTATION]: name,
- },
- name: name,
- },
- } as Entity);
-
- const ExamplePage = () => (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-
- router.addRoute(
- createRouteRef({ path: '/', title: 'SonarQube' }),
- ExamplePage,
- );
- },
- }),
- )
.render();
diff --git a/plugins/sonarqube/package.json b/plugins/sonarqube/package.json
index b6701f9849..c286dd9dac 100644
--- a/plugins/sonarqube/package.json
+++ b/plugins/sonarqube/package.json
@@ -33,6 +33,7 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.7.0",
+ "@backstage/plugin-catalog-react": "^0.0.1",
"@backstage/core": "^0.5.0",
"@backstage/theme": "^0.2.2",
"@material-ui/core": "^4.11.0",
diff --git a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx
index c5e295a22b..5577048fa9 100644
--- a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx
+++ b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx
@@ -22,6 +22,7 @@ import {
Progress,
useApi,
} from '@backstage/core';
+import { useEntity } from '@backstage/plugin-catalog-react';
import { Chip, Grid } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import BugReport from '@material-ui/icons/BugReport';
@@ -69,10 +70,10 @@ const useStyles = makeStyles(theme => ({
},
}));
-interface DuplicationRating {
+type DuplicationRating = {
greaterThan: number;
rating: '1.0' | '2.0' | '3.0' | '4.0' | '5.0';
-}
+};
const defaultDuplicationRatings: DuplicationRating[] = [
{ greaterThan: 0, rating: '1.0' },
@@ -83,14 +84,14 @@ const defaultDuplicationRatings: DuplicationRating[] = [
];
export const SonarQubeCard = ({
- entity,
variant = 'gridItem',
duplicationRatings = defaultDuplicationRatings,
}: {
- entity: Entity;
+ entity?: Entity;
variant?: string;
duplicationRatings?: DuplicationRating[];
}) => {
+ const { entity } = useEntity();
const sonarQubeApi = useApi(sonarQubeApiRef);
const projectTitle = useProjectKey(entity);
diff --git a/plugins/sonarqube/src/index.ts b/plugins/sonarqube/src/index.ts
index f09aeb1038..8fae151929 100644
--- a/plugins/sonarqube/src/index.ts
+++ b/plugins/sonarqube/src/index.ts
@@ -15,4 +15,8 @@
*/
export * from './components';
-export { plugin } from './plugin';
+export {
+ sonarQubePlugin,
+ sonarQubePlugin as plugin,
+ EntitySonarQubeCard,
+} from './plugin';
diff --git a/plugins/sonarqube/src/plugin.test.ts b/plugins/sonarqube/src/plugin.test.ts
index 32730b64c3..246f8b297e 100644
--- a/plugins/sonarqube/src/plugin.test.ts
+++ b/plugins/sonarqube/src/plugin.test.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { plugin } from './plugin';
+import { sonarQubePlugin } from './plugin';
describe('sonarqube', () => {
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(sonarQubePlugin).toBeDefined();
});
});
diff --git a/plugins/sonarqube/src/plugin.ts b/plugins/sonarqube/src/plugin.ts
index f8b8cafc5c..3f58b24abf 100644
--- a/plugins/sonarqube/src/plugin.ts
+++ b/plugins/sonarqube/src/plugin.ts
@@ -17,12 +17,13 @@
import {
configApiRef,
createApiFactory,
+ createComponentExtension,
createPlugin,
discoveryApiRef,
} from '@backstage/core';
import { sonarQubeApiRef, SonarQubeClient } from './api';
-export const plugin = createPlugin({
+export const sonarQubePlugin = createPlugin({
id: 'sonarqube',
apis: [
createApiFactory({
@@ -36,3 +37,12 @@ export const plugin = createPlugin({
}),
],
});
+
+export const EntitySonarQubeCard = sonarQubePlugin.provide(
+ createComponentExtension({
+ component: {
+ lazy: () =>
+ import('./components/SonarQubeCard').then(m => m.SonarQubeCard),
+ },
+ }),
+);
diff --git a/plugins/welcome/dev/index.tsx b/plugins/welcome/dev/index.tsx
index 812a5585d4..b237812f97 100644
--- a/plugins/welcome/dev/index.tsx
+++ b/plugins/welcome/dev/index.tsx
@@ -15,6 +15,6 @@
*/
import { createDevApp } from '@backstage/dev-utils';
-import { plugin } from '../src/plugin';
+import { welcomePlugin } from '../src/plugin';
-createDevApp().registerPlugin(plugin).render();
+createDevApp().registerPlugin(welcomePlugin).render();
diff --git a/plugins/welcome/src/index.ts b/plugins/welcome/src/index.ts
index 3a0a0fe2d3..cccc6bacf3 100644
--- a/plugins/welcome/src/index.ts
+++ b/plugins/welcome/src/index.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export { plugin } from './plugin';
+export { welcomePlugin, welcomePlugin as plugin, WelcomePage } from './plugin';
diff --git a/plugins/welcome/src/plugin.test.ts b/plugins/welcome/src/plugin.test.ts
index d60c73ec68..381ea80f38 100644
--- a/plugins/welcome/src/plugin.test.ts
+++ b/plugins/welcome/src/plugin.test.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { plugin } from './plugin';
+import { welcomePlugin } from './plugin';
describe('welcome', () => {
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(welcomePlugin).toBeDefined();
});
});
diff --git a/plugins/welcome/src/plugin.ts b/plugins/welcome/src/plugin.ts
index 754f708110..f950b93874 100644
--- a/plugins/welcome/src/plugin.ts
+++ b/plugins/welcome/src/plugin.ts
@@ -14,18 +14,28 @@
* limitations under the License.
*/
-import { createPlugin, createRouteRef } from '@backstage/core';
-import WelcomePage from './components/WelcomePage';
+import {
+ createPlugin,
+ createRoutableExtension,
+ createRouteRef,
+} from '@backstage/core';
+import WelcomePageComponent from './components/WelcomePage';
export const rootRouteRef = createRouteRef({
- path: '/welcome',
title: 'Welcome',
});
-export const plugin = createPlugin({
+export const welcomePlugin = createPlugin({
id: 'welcome',
register({ router, featureFlags }) {
- router.addRoute(rootRouteRef, WelcomePage);
+ router.addRoute(rootRouteRef, WelcomePageComponent);
featureFlags.register('enable-welcome-box');
},
});
+
+export const WelcomePage = welcomePlugin.provide(
+ createRoutableExtension({
+ component: () => import('./components/WelcomePage').then(m => m.default),
+ mountPoint: rootRouteRef,
+ }),
+);