Skip to content

Commit 38c34f9

Browse files
committed
fix: move catalog api to dev/index
this is so that it will not be created when using qeta plugin as such. closes #16
1 parent 389e1eb commit 38c34f9

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

plugins/qeta/dev/index.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
import React from 'react';
22
import { createDevApp } from '@backstage/dev-utils';
3-
import { QetaPage, qetaPlugin } from '../src/plugin';
3+
import { QetaPage } from '../src/plugin';
4+
import {
5+
AnyApiFactory,
6+
createApiFactory,
7+
createPlugin,
8+
discoveryApiRef,
9+
fetchApiRef,
10+
} from '@backstage/core-plugin-api';
11+
import { rootRouteRef } from '../src/routes';
12+
import { catalogApiRef } from '@backstage/plugin-catalog-react';
13+
import { CatalogClient } from '@backstage/catalog-client';
14+
15+
const apiFactories: AnyApiFactory[] = [
16+
createApiFactory({
17+
api: catalogApiRef,
18+
deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },
19+
factory: ({ discoveryApi, fetchApi }) =>
20+
new CatalogClient({ discoveryApi, fetchApi }),
21+
}),
22+
];
23+
24+
const qetaDevPlugin = createPlugin({
25+
id: 'qetaDev',
26+
routes: {
27+
root: rootRouteRef,
28+
},
29+
apis: apiFactories,
30+
});
431

532
createDevApp()
6-
.registerPlugin(qetaPlugin)
33+
.registerPlugin(qetaDevPlugin)
734
.addPage({
835
element: <QetaPage />,
936
title: 'Root Page',

plugins/qeta/src/plugin.ts

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
AnyApiFactory,
32
configApiRef,
43
createApiFactory,
54
createPlugin,
@@ -9,36 +8,20 @@ import {
98

109
import { rootRouteRef } from './routes';
1110
import { qetaApiRef, QetaClient } from './api';
12-
// import { catalogApiRef } from '@backstage/plugin-catalog-react';
13-
// import { CatalogClient } from '@backstage/catalog-client';
14-
15-
const apiFactories: AnyApiFactory[] = [
16-
createApiFactory({
17-
api: qetaApiRef,
18-
deps: { configApi: configApiRef, fetchApi: fetchApiRef },
19-
factory: ({ configApi, fetchApi }) =>
20-
new QetaClient({ configApi, fetchApi }),
21-
}),
22-
];
23-
24-
// TODO: Figure way to only add catalog api in local development
25-
// If this is enabled and used by a real backstage app, it will
26-
// die horribly with an error.
27-
/* const catalogApi = createApiFactory({
28-
api: catalogApiRef,
29-
deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },
30-
factory: ({ discoveryApi, fetchApi }) =>
31-
new CatalogClient({ discoveryApi, fetchApi }),
32-
});
33-
apiFactories.push(catalogApi);
34-
*/
3511

3612
export const qetaPlugin = createPlugin({
3713
id: 'qeta',
3814
routes: {
3915
root: rootRouteRef,
4016
},
41-
apis: apiFactories,
17+
apis: [
18+
createApiFactory({
19+
api: qetaApiRef,
20+
deps: { configApi: configApiRef, fetchApi: fetchApiRef },
21+
factory: ({ configApi, fetchApi }) =>
22+
new QetaClient({ configApi, fetchApi }),
23+
}),
24+
],
4225
});
4326

4427
export const QetaPage = qetaPlugin.provide(

0 commit comments

Comments
 (0)