Skip to content

Commit

Permalink
add npm standalone demo application
Browse files Browse the repository at this point in the history
Signed-off-by: Karthik Jeeyar <[email protected]>
  • Loading branch information
karthikjeeyar committed Oct 11, 2024
1 parent 7e643d4 commit 0bc51fe
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions workspaces/npm/.changeset/fast-windows-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-npm': patch
---

add standalone demo application
41 changes: 38 additions & 3 deletions workspaces/npm/plugins/npm/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,48 @@
*/
import React from 'react';
import { createDevApp } from '@backstage/dev-utils';
import { npmPlugin } from '../src/plugin';
import { npmPlugin, NpmReleases } from '../src/plugin';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import { NpmInfoCard } from '../src/components/NpmInfoCard';
import { Content, Header, Page } from '@backstage/core-components';
import { Grid } from '@material-ui/core';

const mockEntity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Component',
metadata: {
name: 'backstage-plugin-catalog',
annotations: {
'npm/package': '@backstage/plugin-catalog',
},
},
spec: {
type: 'website',
lifecycle: 'production',
owner: 'guests',
},
};
createDevApp()
.registerPlugin(npmPlugin)
.addPage({
element: <div />,
title: 'Root Page',
element: (
<Page themeId="tool">
<Header title="Npm demo application" subtitle="standalone app" />
<Content>
<EntityProvider entity={mockEntity}>
<Grid container>
<Grid item xs={8}>
<NpmReleases />
</Grid>
<Grid item xs={4}>
<NpmInfoCard />
</Grid>
</Grid>
</EntityProvider>
</Content>
</Page>
),
title: 'Npm',
path: '/npm',
})
.render();
17 changes: 16 additions & 1 deletion workspaces/npm/plugins/npm/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createPlugin } from '@backstage/core-plugin-api';
import {
createPlugin,
createRoutableExtension,
} from '@backstage/core-plugin-api';

import { rootRouteRef } from './routes';

Expand All @@ -28,3 +31,15 @@ export const npmPlugin = createPlugin({
root: rootRouteRef,
},
});

/** @public */
export const NpmReleases = npmPlugin.provide(
createRoutableExtension({
name: 'NpmReleasesTable',
component: () =>
import('./components/NpmReleaseTableCard').then(
m => m.NpmReleaseTableCard,
),
mountPoint: rootRouteRef,
}),
);

0 comments on commit 0bc51fe

Please sign in to comment.