diff --git a/.changeset/shiny-falcons-marry.md b/.changeset/shiny-falcons-marry.md
new file mode 100644
index 0000000000..4dda68d693
--- /dev/null
+++ b/.changeset/shiny-falcons-marry.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-newrelic': patch
+---
+
+Migrate to new composability API, exporting the plugin instance as `newRelicPlugin`, and the root page as `NewRelicPage`.
diff --git a/.changeset/shy-maps-guess.md b/.changeset/shy-maps-guess.md
new file mode 100644
index 0000000000..2a50d3d461
--- /dev/null
+++ b/.changeset/shy-maps-guess.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-kubernetes': patch
+---
+
+Migrate to new composability API, exporting the plugin instance as `kubernetesPlugin` and entity content as `EntityKubernetesContent`.
diff --git a/.changeset/sixty-lemons-agree.md b/.changeset/sixty-lemons-agree.md
new file mode 100644
index 0000000000..7fc438b433
--- /dev/null
+++ b/.changeset/sixty-lemons-agree.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-kafka': patch
+---
+
+Migrate to new composability API, exporting the plugin instance as `kafkaPlugin`, entity content as `EntityKafkaContent`, and entity conditional as `isKafkaAvailable`.
diff --git a/plugins/kafka/dev/index.tsx b/plugins/kafka/dev/index.tsx
index 264d6f801f..5506d47026 100644
--- a/plugins/kafka/dev/index.tsx
+++ b/plugins/kafka/dev/index.tsx
@@ -14,6 +14,6 @@
* limitations under the License.
*/
import { createDevApp } from '@backstage/dev-utils';
-import { plugin } from '../src/plugin';
+import { kafkaPlugin } from '../src/plugin';
-createDevApp().registerPlugin(plugin).render();
+createDevApp().registerPlugin(kafkaPlugin).render();
diff --git a/plugins/kafka/src/Router.tsx b/plugins/kafka/src/Router.tsx
index b445f8f408..13503fefe8 100644
--- a/plugins/kafka/src/Router.tsx
+++ b/plugins/kafka/src/Router.tsx
@@ -17,7 +17,7 @@
import { Entity } from '@backstage/catalog-model';
import React from 'react';
import { Route, Routes } from 'react-router';
-
+import { useEntity } from '@backstage/plugin-catalog-react';
import { rootCatalogKafkaRouteRef } from './plugin';
import { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants';
import { KafkaTopicsForConsumer } from './components/ConsumerGroupOffsets/ConsumerGroupOffsets';
@@ -26,10 +26,23 @@ import { MissingAnnotationEmptyState } from '@backstage/core';
export const isPluginApplicableToEntity = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION]);
-export const Router = ({ entity }: { entity: Entity }) => {
- return !isPluginApplicableToEntity(entity) ? (
-
- ) : (
+type Props = {
+ /** @deprecated The entity is now grabbed from context instead */
+ entity?: Entity;
+};
+
+export const Router = (_props: Props) => {
+ const { entity } = useEntity();
+
+ if (!isPluginApplicableToEntity(entity)) {
+ return (
+
+ );
+ }
+
+ return (
{
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(kafkaPlugin).toBeDefined();
});
});
diff --git a/plugins/kafka/src/plugin.ts b/plugins/kafka/src/plugin.ts
index 878a7f56e9..832099a30c 100644
--- a/plugins/kafka/src/plugin.ts
+++ b/plugins/kafka/src/plugin.ts
@@ -16,6 +16,7 @@
import {
createApiFactory,
createPlugin,
+ createRoutableExtension,
createRouteRef,
discoveryApiRef,
} from '@backstage/core';
@@ -27,7 +28,7 @@ export const rootCatalogKafkaRouteRef = createRouteRef({
title: 'Kafka',
});
-export const plugin = createPlugin({
+export const kafkaPlugin = createPlugin({
id: 'kafka',
apis: [
createApiFactory({
@@ -36,4 +37,14 @@ export const plugin = createPlugin({
factory: ({ discoveryApi }) => new KafkaBackendClient({ discoveryApi }),
}),
],
+ routes: {
+ entityContent: rootCatalogKafkaRouteRef,
+ },
});
+
+export const EntityKafkaContent = kafkaPlugin.provide(
+ createRoutableExtension({
+ component: () => import('./Router').then(m => m.Router),
+ mountPoint: rootCatalogKafkaRouteRef,
+ }),
+);
diff --git a/plugins/kubernetes/dev/index.tsx b/plugins/kubernetes/dev/index.tsx
index f352fb9c34..de93d21348 100644
--- a/plugins/kubernetes/dev/index.tsx
+++ b/plugins/kubernetes/dev/index.tsx
@@ -14,6 +14,6 @@
* limitations under the License.
*/
import { createDevApp } from '@backstage/dev-utils';
-import { plugin } from '../src';
+import { kubernetesPlugin } from '../src';
-createDevApp().registerPlugin(plugin).render();
+createDevApp().registerPlugin(kubernetesPlugin).render();
diff --git a/plugins/kubernetes/package.json b/plugins/kubernetes/package.json
index 8598aec233..9013fa9395 100644
--- a/plugins/kubernetes/package.json
+++ b/plugins/kubernetes/package.json
@@ -32,6 +32,7 @@
},
"dependencies": {
"@backstage/catalog-model": "^0.7.1",
+ "@backstage/plugin-catalog-react": "^0.0.2",
"@backstage/config": "^0.1.2",
"@backstage/core": "^0.6.0",
"@backstage/plugin-kubernetes-backend": "^0.2.6",
diff --git a/plugins/kubernetes/src/Router.tsx b/plugins/kubernetes/src/Router.tsx
index 20a4c04285..36851b3c46 100644
--- a/plugins/kubernetes/src/Router.tsx
+++ b/plugins/kubernetes/src/Router.tsx
@@ -16,15 +16,22 @@
import React from 'react';
import { Entity } from '@backstage/catalog-model';
+import { useEntity } from '@backstage/plugin-catalog-react';
import { Route, Routes } from 'react-router-dom';
-
import { rootCatalogKubernetesRouteRef } from './plugin';
import { KubernetesContent } from './components/KubernetesContent';
import { MissingAnnotationEmptyState } from '@backstage/core';
const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
-export const Router = ({ entity }: { entity: Entity }) => {
+type Props = {
+ /** @deprecated The entity is now grabbed from context instead */
+ entity?: Entity;
+};
+
+export const Router = (_props: Props) => {
+ const { entity } = useEntity();
+
const kubernetesAnnotationValue =
entity.metadata.annotations?.[KUBERNETES_ANNOTATION];
diff --git a/plugins/kubernetes/src/index.ts b/plugins/kubernetes/src/index.ts
index 8b5969666c..eca6b068f1 100644
--- a/plugins/kubernetes/src/index.ts
+++ b/plugins/kubernetes/src/index.ts
@@ -13,5 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-export { plugin } from './plugin';
+export {
+ kubernetesPlugin,
+ kubernetesPlugin as plugin,
+ EntityKubernetesContent,
+} from './plugin';
export { Router } from './Router';
diff --git a/plugins/kubernetes/src/plugin.test.ts b/plugins/kubernetes/src/plugin.test.ts
index 20c50a813a..f176b7f451 100644
--- a/plugins/kubernetes/src/plugin.test.ts
+++ b/plugins/kubernetes/src/plugin.test.ts
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { plugin } from './plugin';
+import { kubernetesPlugin } from './plugin';
describe('kubernetes', () => {
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(kubernetesPlugin).toBeDefined();
});
});
diff --git a/plugins/kubernetes/src/plugin.ts b/plugins/kubernetes/src/plugin.ts
index cff9e1468b..af29df3dcc 100644
--- a/plugins/kubernetes/src/plugin.ts
+++ b/plugins/kubernetes/src/plugin.ts
@@ -19,6 +19,7 @@ import {
createRouteRef,
discoveryApiRef,
googleAuthApiRef,
+ createRoutableExtension,
} from '@backstage/core';
import { KubernetesBackendClient } from './api/KubernetesBackendClient';
import { kubernetesApiRef } from './api/types';
@@ -30,7 +31,7 @@ export const rootCatalogKubernetesRouteRef = createRouteRef({
title: 'Kubernetes',
});
-export const plugin = createPlugin({
+export const kubernetesPlugin = createPlugin({
id: 'kubernetes',
apis: [
createApiFactory({
@@ -47,4 +48,14 @@ export const plugin = createPlugin({
},
}),
],
+ routes: {
+ entityContent: rootCatalogKubernetesRouteRef,
+ },
});
+
+export const EntityKubernetesContent = kubernetesPlugin.provide(
+ createRoutableExtension({
+ component: () => import('./Router').then(m => m.Router),
+ mountPoint: rootCatalogKubernetesRouteRef,
+ }),
+);
diff --git a/plugins/newrelic/dev/index.tsx b/plugins/newrelic/dev/index.tsx
index 812a5585d4..9ca421f94a 100644
--- a/plugins/newrelic/dev/index.tsx
+++ b/plugins/newrelic/dev/index.tsx
@@ -15,6 +15,6 @@
*/
import { createDevApp } from '@backstage/dev-utils';
-import { plugin } from '../src/plugin';
+import { newRelicPlugin } from '../src/plugin';
-createDevApp().registerPlugin(plugin).render();
+createDevApp().registerPlugin(newRelicPlugin).render();
diff --git a/plugins/newrelic/src/index.ts b/plugins/newrelic/src/index.ts
index 3a0a0fe2d3..aa4e990d6c 100644
--- a/plugins/newrelic/src/index.ts
+++ b/plugins/newrelic/src/index.ts
@@ -14,4 +14,8 @@
* limitations under the License.
*/
-export { plugin } from './plugin';
+export {
+ newRelicPlugin,
+ newRelicPlugin as plugin,
+ NewRelicPage,
+} from './plugin';
diff --git a/plugins/newrelic/src/plugin.test.ts b/plugins/newrelic/src/plugin.test.ts
index 17429a95e0..f2e8fde924 100644
--- a/plugins/newrelic/src/plugin.test.ts
+++ b/plugins/newrelic/src/plugin.test.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { plugin } from './plugin';
+import { newRelicPlugin } from './plugin';
describe('newrelic', () => {
it('should export plugin', () => {
- expect(plugin).toBeDefined();
+ expect(newRelicPlugin).toBeDefined();
});
});
diff --git a/plugins/newrelic/src/plugin.ts b/plugins/newrelic/src/plugin.ts
index 5f5ba88617..d89aa813e9 100644
--- a/plugins/newrelic/src/plugin.ts
+++ b/plugins/newrelic/src/plugin.ts
@@ -19,6 +19,7 @@ import {
createPlugin,
createRouteRef,
discoveryApiRef,
+ createRoutableExtension,
} from '@backstage/core';
import { NewRelicClient, newRelicApiRef } from './api';
import NewRelicComponent from './components/NewRelicComponent';
@@ -28,7 +29,7 @@ export const rootRouteRef = createRouteRef({
title: 'newrelic',
});
-export const plugin = createPlugin({
+export const newRelicPlugin = createPlugin({
id: 'newrelic',
apis: [
createApiFactory({
@@ -40,4 +41,15 @@ export const plugin = createPlugin({
register({ router }) {
router.addRoute(rootRouteRef, NewRelicComponent);
},
+ routes: {
+ root: rootRouteRef,
+ },
});
+
+export const NewRelicPage = newRelicPlugin.provide(
+ createRoutableExtension({
+ component: () =>
+ import('./components/NewRelicComponent').then(m => m.default),
+ mountPoint: rootRouteRef,
+ }),
+);