Skip to content

Commit 28cc9a9

Browse files
committed
chore: nfs improvements
1 parent 5edece8 commit 28cc9a9

File tree

6 files changed

+52
-52
lines changed

6 files changed

+52
-52
lines changed

plugins/qeta/dev/ComponentPage.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import { Content, Page } from '@backstage/core-components';
2-
import { PostsContainer } from '@drodil/backstage-plugin-qeta-react';
3-
import { Container } from '@material-ui/core';
1+
import { EntityPostsContent } from '../src';
2+
import { EntityProvider } from '@backstage/plugin-catalog-react';
43

54
export const ComponentPage = () => {
65
return (
7-
<Page themeId="home">
8-
<Content>
9-
<Container>
10-
<PostsContainer
11-
entity="component:default/test-component"
12-
showTitle
13-
showAskButton
14-
type="question"
15-
/>
16-
</Container>
17-
</Content>
18-
</Page>
6+
<EntityProvider
7+
entity={{
8+
apiVersion: 'backstage.io/v1alpha1',
9+
kind: 'component',
10+
metadata: { name: 'test-component' },
11+
}}
12+
>
13+
<EntityPostsContent />
14+
</EntityProvider>
1915
);
2016
};

plugins/qeta/dev/index.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { createDevApp } from '@backstage/dev-utils';
22
import { QetaPage } from '../src/plugin';
3-
import {
4-
createPlugin,
5-
createRoutableExtension,
6-
} from '@backstage/core-plugin-api';
3+
import { createPlugin } from '@backstage/core-plugin-api';
74
import { qetaRouteRef } from '@drodil/backstage-plugin-qeta-react';
8-
import { entityRouteRef } from '@backstage/plugin-catalog-react';
95
import { TablePage } from './TablePage';
106
import { HomePage } from './HomePage';
117
import { TagPage } from './TagPage';
@@ -20,6 +16,7 @@ import { Box } from '@material-ui/core';
2016
import { Alert, AlertTitle } from '@material-ui/lab';
2117
import { searchPage } from './SearchPage';
2218
import { searchPlugin } from '@backstage/plugin-search';
19+
import { ComponentPage } from './ComponentPage.tsx';
2320

2421
const IntroElement = () => (
2522
<Box marginBottom={4}>
@@ -31,14 +28,6 @@ const IntroElement = () => (
3128
</Box>
3229
);
3330

34-
export const CatalogEntityPage: () => JSX.Element = catalogPlugin.provide(
35-
createRoutableExtension({
36-
name: 'CatalogEntityPage',
37-
component: () => import('./ComponentPage').then(m => m.ComponentPage),
38-
mountPoint: entityRouteRef,
39-
}),
40-
);
41-
4231
const qetaDevPlugin = createPlugin({
4332
id: 'qetaDev',
4433
routes: {
@@ -68,8 +57,8 @@ createDevApp()
6857
path: '/qeta',
6958
})
7059
.addPage({
71-
element: <CatalogEntityPage />,
72-
title: 'Component',
60+
element: <ComponentPage />,
61+
title: 'Catalog Page',
7362
path: '/catalog/default/component/test-component',
7463
})
7564
.addPage({

plugins/qeta/src/alpha.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { qetaApiRef, qetaRouteRef } from '@drodil/backstage-plugin-qeta-react';
1313
import { discoveryApiRef, fetchApiRef } from '@backstage/core-plugin-api';
1414
import { QetaClient } from '@drodil/backstage-plugin-qeta-common';
1515
import LiveHelpIcon from '@material-ui/icons/LiveHelp';
16-
import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';
16+
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
1717

1818
const qetaApi = ApiBlueprint.make({
1919
params: defineParams =>
@@ -38,22 +38,14 @@ const qetaPage = PageBlueprint.make({
3838
},
3939
});
4040

41-
const EntityPostsGridCard = EntityCardBlueprint.make({
42-
name: 'entity-posts-grid',
43-
params: {
44-
loader: async () =>
45-
import('./components/EntityCards/EntityPostsGridCard').then(m =>
46-
compatWrapper(<m.EntityPostsGridCard />),
47-
),
48-
},
49-
});
50-
51-
const EntityPostsContainerCard = EntityCardBlueprint.make({
52-
name: 'entity-posts-container',
41+
const EntityPostsContent = EntityContentBlueprint.make({
42+
name: 'entity-posts-content',
5343
params: {
44+
path: '/qeta',
45+
title: 'Q&A',
5446
loader: async () =>
55-
import('./components/EntityCards/EntityPostsContainerCard').then(m =>
56-
compatWrapper(<m.EntityPostsContainerCard />),
47+
import('./components/EntityPostsContent/EntityPostsContent.tsx').then(m =>
48+
compatWrapper(<m.EntityPostsContent />),
5749
),
5850
},
5951
});
@@ -78,13 +70,7 @@ export default createFrontendPlugin({
7870
routes: convertLegacyRouteRefs({
7971
root: qetaRouteRef,
8072
}),
81-
extensions: [
82-
qetaApi,
83-
qetaPage,
84-
EntityPostsGridCard,
85-
EntityPostsContainerCard,
86-
qetaNavItem,
87-
],
73+
extensions: [qetaApi, qetaPage, EntityPostsContent, qetaNavItem],
8874
});
8975

9076
export { qetaTranslationRef } from '@drodil/backstage-plugin-qeta-react';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { useState } from 'react';
2+
import {
3+
PostsContainer,
4+
PostsContainerProps,
5+
ViewType,
6+
} from '@drodil/backstage-plugin-qeta-react';
7+
import { Content } from '@backstage/core-components';
8+
import { stringifyEntityRef } from '@backstage/catalog-model';
9+
import { useEntity } from '@backstage/plugin-catalog-react';
10+
import { Container } from '@material-ui/core';
11+
12+
export const EntityPostsContent = (props: PostsContainerProps) => {
13+
const [view, setView] = useState<ViewType>('list');
14+
const { entity } = useEntity();
15+
return (
16+
<Content>
17+
<Container>
18+
<PostsContainer
19+
{...props}
20+
entity={props.entity ? props.entity : stringifyEntityRef(entity)}
21+
view={view}
22+
onViewChange={setView}
23+
/>
24+
</Container>
25+
</Content>
26+
);
27+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { EntityPostsContent } from './EntityPostsContent.tsx';

plugins/qeta/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './PostsTableCard';
22
export * from './EntityCards';
3+
export * from './EntityPostsContent';
34
export * from './Statistics';

0 commit comments

Comments
 (0)