-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dynamic-home-page): add plugin scaffold
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
- Loading branch information
1 parent
c81e0bd
commit 31bc3ed
Showing
20 changed files
with
788 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workspaces/dynamic-home-page/plugins/dynamic-home-page/.eslintrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
13 changes: 13 additions & 0 deletions
13
workspaces/dynamic-home-page/plugins/dynamic-home-page/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# dynamic-home-page | ||
|
||
Welcome to the dynamic-home-page plugin! | ||
|
||
_This plugin was created through the Backstage CLI_ | ||
|
||
## Getting started | ||
|
||
Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/dynamic-home-page](http://localhost:3000/dynamic-home-page). | ||
|
||
You can also serve the plugin in isolation by running `yarn start` in the plugin directory. | ||
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. | ||
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory. |
25 changes: 25 additions & 0 deletions
25
workspaces/dynamic-home-page/plugins/dynamic-home-page/api-report.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## API Report File for "@red-hat-developer-hub/backstage-plugin-dynamic-home-page" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
/// <reference types="react" /> | ||
|
||
import { BackstagePlugin } from '@backstage/core-plugin-api'; | ||
import { JSX as JSX_2 } from 'react'; | ||
import { RouteRef } from '@backstage/core-plugin-api'; | ||
|
||
// @public (undocumented) | ||
export const DynamicHomePagePage: () => JSX_2.Element; | ||
|
||
// @public (undocumented) | ||
export const dynamicHomePagePlugin: BackstagePlugin< | ||
{ | ||
root: RouteRef<undefined>; | ||
}, | ||
{}, | ||
{} | ||
>; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
``` |
27 changes: 27 additions & 0 deletions
27
workspaces/dynamic-home-page/plugins/dynamic-home-page/dev/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React from 'react'; | ||
import { createDevApp } from '@backstage/dev-utils'; | ||
import { dynamicHomePagePlugin, DynamicHomePagePage } from '../src/plugin'; | ||
|
||
createDevApp() | ||
.registerPlugin(dynamicHomePagePlugin) | ||
.addPage({ | ||
element: <DynamicHomePagePage />, | ||
title: 'Root Page', | ||
path: '/dynamic-home-page', | ||
}) | ||
.render(); |
61 changes: 61 additions & 0 deletions
61
workspaces/dynamic-home-page/plugins/dynamic-home-page/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "@red-hat-developer-hub/backstage-plugin-dynamic-home-page", | ||
"version": "0.1.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.esm.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/redhat-developer/rhdh-plugins", | ||
"directory": "workspaces/dynamic-home-page/plugins/dynamic-home-page" | ||
}, | ||
"backstage": { | ||
"role": "frontend-plugin", | ||
"pluginId": "dynamic-home-page", | ||
"pluginPackages": [ | ||
"@red-hat-developer-hub/backstage-plugin-dynamic-home-page" | ||
] | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"start": "backstage-cli package start", | ||
"build": "backstage-cli package build", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"clean": "backstage-cli package clean", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack" | ||
}, | ||
"dependencies": { | ||
"@backstage/core-components": "^0.15.1", | ||
"@backstage/core-plugin-api": "^1.10.0", | ||
"@backstage/theme": "^0.6.0", | ||
"@material-ui/core": "^4.9.13", | ||
"@material-ui/icons": "^4.9.1", | ||
"@material-ui/lab": "^4.0.0-alpha.61", | ||
"react-use": "^17.2.4" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.28.0", | ||
"@backstage/core-app-api": "^1.15.1", | ||
"@backstage/dev-utils": "^1.1.2", | ||
"@backstage/test-utils": "^1.7.0", | ||
"@testing-library/jest-dom": "^6.0.0", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/user-event": "^14.0.0", | ||
"msw": "^1.0.0", | ||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
...-page/plugins/dynamic-home-page/src/components/ExampleComponent/ExampleComponent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React from 'react'; | ||
import { ExampleComponent } from './ExampleComponent'; | ||
import { rest } from 'msw'; | ||
import { setupServer } from 'msw/node'; | ||
import { screen } from '@testing-library/react'; | ||
import { registerMswTestHooks, renderInTestApp } from '@backstage/test-utils'; | ||
|
||
describe('ExampleComponent', () => { | ||
const server = setupServer(); | ||
// Enable sane handlers for network requests | ||
registerMswTestHooks(server); | ||
|
||
// setup mock response | ||
beforeEach(() => { | ||
server.use( | ||
rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({}))), | ||
); | ||
}); | ||
|
||
it('should render', async () => { | ||
await renderInTestApp(<ExampleComponent />); | ||
expect( | ||
screen.getByText('Welcome to dynamic-home-page!'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
...-home-page/plugins/dynamic-home-page/src/components/ExampleComponent/ExampleComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React from 'react'; | ||
import { Typography, Grid } from '@material-ui/core'; | ||
import { | ||
InfoCard, | ||
Header, | ||
Page, | ||
Content, | ||
ContentHeader, | ||
HeaderLabel, | ||
SupportButton, | ||
} from '@backstage/core-components'; | ||
import { ExampleFetchComponent } from '../ExampleFetchComponent'; | ||
|
||
export const ExampleComponent = () => ( | ||
<Page themeId="tool"> | ||
<Header title="Welcome to dynamic-home-page!" subtitle="Optional subtitle"> | ||
<HeaderLabel label="Owner" value="Team X" /> | ||
<HeaderLabel label="Lifecycle" value="Alpha" /> | ||
</Header> | ||
<Content> | ||
<ContentHeader title="Plugin title"> | ||
<SupportButton>A description of your plugin goes here.</SupportButton> | ||
</ContentHeader> | ||
<Grid container spacing={3} direction="column"> | ||
<Grid item> | ||
<InfoCard title="Information card"> | ||
<Typography variant="body1"> | ||
All content should be wrapped in a card like this. | ||
</Typography> | ||
</InfoCard> | ||
</Grid> | ||
<Grid item> | ||
<ExampleFetchComponent /> | ||
</Grid> | ||
</Grid> | ||
</Content> | ||
</Page> | ||
); |
16 changes: 16 additions & 0 deletions
16
...aces/dynamic-home-page/plugins/dynamic-home-page/src/components/ExampleComponent/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { ExampleComponent } from './ExampleComponent'; |
34 changes: 34 additions & 0 deletions
34
...ins/dynamic-home-page/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { ExampleFetchComponent } from './ExampleFetchComponent'; | ||
|
||
describe('ExampleFetchComponent', () => { | ||
it('renders the user table', async () => { | ||
render(<ExampleFetchComponent />); | ||
|
||
// Wait for the table to render | ||
const table = await screen.findByRole('table'); | ||
const nationality = screen.getAllByText('GB'); | ||
// Assert that the table contains the expected user data | ||
expect(table).toBeInTheDocument(); | ||
expect(screen.getByAltText('Carolyn')).toBeInTheDocument(); | ||
expect(screen.getByText('Carolyn Moore')).toBeInTheDocument(); | ||
expect(screen.getByText('carolyn.moore@example.com')).toBeInTheDocument(); | ||
expect(nationality[0]).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.