gitops-profiles: migrate to new composability API

This commit is contained in:
Patrik Oldsberg
2021-02-04 00:38:45 +01:00
parent 9530303281
commit accdfeb30b
6 changed files with 49 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-gitops-profiles': patch
---
Migrated to new composability API, exporting the plugin instance as `gitopsProfilesPlugin` and pages as `GitopsProfilesClusterListPage`, `GitopsProfilesClusterPage`, and `GitopsProfilesCreatePage`.
+2 -2
View File
@@ -15,6 +15,6 @@
*/
import { createDevApp } from '@backstage/dev-utils';
import { plugin } from '../src/plugin';
import { gitopsProfilesPlugin } from '../src/plugin';
createDevApp().registerPlugin(plugin).render();
createDevApp().registerPlugin(gitopsProfilesPlugin).render();
+7 -1
View File
@@ -14,5 +14,11 @@
* limitations under the License.
*/
export { plugin } from './plugin';
export {
gitopsProfilesPlugin,
gitopsProfilesPlugin as plugin,
GitopsProfilesClusterListPage,
GitopsProfilesClusterPage,
GitopsProfilesCreatePage,
} from './plugin';
export * from './api';
+2 -2
View File
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import { plugin } from './plugin';
import { gitopsProfilesPlugin } from './plugin';
describe('gitops-profiles', () => {
it('should export plugin', () => {
expect(plugin).toBeDefined();
expect(gitopsProfilesPlugin).toBeDefined();
});
});
+32 -2
View File
@@ -14,7 +14,11 @@
* limitations under the License.
*/
import { createPlugin, createApiFactory } from '@backstage/core';
import {
createPlugin,
createApiFactory,
createRoutableExtension,
} from '@backstage/core';
import ProfileCatalog from './components/ProfileCatalog';
import ClusterPage from './components/ClusterPage';
import ClusterList from './components/ClusterList';
@@ -25,7 +29,7 @@ import {
} from './routes';
import { gitOpsApiRef, GitOpsRestApi } from './api';
export const plugin = createPlugin({
export const gitopsProfilesPlugin = createPlugin({
id: 'gitops-profiles',
apis: [
createApiFactory(gitOpsApiRef, new GitOpsRestApi('http://localhost:3008')),
@@ -35,4 +39,30 @@ export const plugin = createPlugin({
router.addRoute(gitOpsClusterDetailsRoute, ClusterPage);
router.addRoute(gitOpsClusterCreateRoute, ProfileCatalog);
},
routes: {
listPage: gitOpsClusterListRoute,
detailsPage: gitOpsClusterDetailsRoute,
createPage: gitOpsClusterCreateRoute,
},
});
export const GitopsProfilesClusterListPage = gitopsProfilesPlugin.provide(
createRoutableExtension({
component: () => import('./components/ClusterList').then(m => m.default),
mountPoint: gitOpsClusterListRoute,
}),
);
export const GitopsProfilesClusterPage = gitopsProfilesPlugin.provide(
createRoutableExtension({
component: () => import('./components/ClusterPage').then(m => m.default),
mountPoint: gitOpsClusterDetailsRoute,
}),
);
export const GitopsProfilesCreatePage = gitopsProfilesPlugin.provide(
createRoutableExtension({
component: () => import('./components/ProfileCatalog').then(m => m.default),
mountPoint: gitOpsClusterCreateRoute,
}),
);
+1
View File
@@ -28,6 +28,7 @@ export const gitOpsClusterDetailsRoute = createRouteRef({
icon: NoIcon,
path: '/gitops-cluster/:owner/:repo',
title: 'GitOps Cluster details',
params: ['owner', 'repo'],
});
export const gitOpsClusterCreateRoute = createRouteRef({