Skip to content

Commit cb8d3cf

Browse files
feat(fab): add application listener and provider test plugins
Signed-off-by: Christoph Jerolimov <[email protected]>
1 parent 1d9415f commit cb8d3cf

31 files changed

+2400
-138
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-application-listener-test': patch
3+
'@red-hat-developer-hub/backstage-plugin-application-provider-test': patch
4+
---
5+
6+
Release the initial version of this test-plugin.

workspaces/global-floating-action-button/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dev": "yarn workspaces foreach -A --include backend --include app --parallel -v -i run start",
1212
"build:all": "backstage-cli repo build --all",
1313
"build:api-reports": "yarn build:api-reports:only --tsc",
14-
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type --validate-release-tags",
14+
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
1515
"clean": "backstage-cli repo clean",
1616
"test": "backstage-cli repo test",
1717
"test:all": "backstage-cli repo test --coverage",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# application-listener-test
2+
3+
Welcome to the application-listener-test plugin!
4+
5+
_This plugin was created through the Backstage CLI_
6+
7+
## Getting started
8+
9+
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 [/application-listener-test](http://localhost:3000/application-listener-test).
10+
11+
You can also serve the plugin in isolation by running `yarn start` in the plugin directory.
12+
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
13+
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# test global-header components. this isn't implemented yet!
2+
dynamicPlugins:
3+
frontend:
4+
red-hat-developer-hub.backstage-plugin-application-listener-test:
5+
mountPoints:
6+
- mountPoint: application/listener
7+
importName: LocationListener
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import React from 'react';
17+
18+
import { createDevApp } from '@backstage/dev-utils';
19+
20+
import { applicationListenerTestPlugin, LocationListener } from '../src/plugin';
21+
22+
createDevApp()
23+
.registerPlugin(applicationListenerTestPlugin)
24+
.addPage({
25+
element: <LocationListener />,
26+
title: 'Page 1',
27+
path: '/page-1',
28+
})
29+
.addPage({
30+
element: <LocationListener />,
31+
title: 'Page 2',
32+
path: '/page-2',
33+
})
34+
.render();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Knip report
2+
3+
## Unused dependencies (1)
4+
5+
| Name | Location | Severity |
6+
| :------------------------- | :----------- | :------- |
7+
| @backstage/core-components | package.json | error |
8+
9+
## Unused devDependencies (5)
10+
11+
| Name | Location | Severity |
12+
| :-------------------------- | :----------- | :------- |
13+
| @testing-library/user-event | package.json | error |
14+
| @backstage/core-app-api | package.json | error |
15+
| @testing-library/react | package.json | error |
16+
| @backstage/test-utils | package.json | error |
17+
| msw | package.json | error |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@red-hat-developer-hub/backstage-plugin-application-listener-test",
3+
"version": "0.0.0",
4+
"main": "src/index.ts",
5+
"types": "src/index.ts",
6+
"license": "Apache-2.0",
7+
"publishConfig": {
8+
"access": "public",
9+
"main": "dist/index.esm.js",
10+
"types": "dist/index.d.ts"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/redhat-developer/rhdh-plugins",
15+
"directory": "workspaces/global-floating-action-button/plugins/application-listener-test"
16+
},
17+
"backstage": {
18+
"role": "frontend-plugin",
19+
"pluginId": "application-listener-test",
20+
"pluginPackages": [
21+
"@red-hat-developer-hub/backstage-plugin-application-listener-test"
22+
]
23+
},
24+
"sideEffects": false,
25+
"scripts": {
26+
"start": "backstage-cli package start",
27+
"build": "backstage-cli package build && yarn export-dynamic",
28+
"lint": "backstage-cli package lint",
29+
"test": "backstage-cli package test",
30+
"clean": "backstage-cli package clean && rm -rf dist-scalprum",
31+
"prepack": "backstage-cli package prepack && yarn export-dynamic",
32+
"postpack": "backstage-cli package postpack",
33+
"export-dynamic": "janus-cli package export-dynamic-plugin --in-place"
34+
},
35+
"dependencies": {
36+
"@backstage/core-components": "^0.15.1",
37+
"@backstage/core-plugin-api": "^1.10.0"
38+
},
39+
"peerDependencies": {
40+
"react": "16.13.1 || ^17.0.0 || ^18.0.0",
41+
"react-router-dom": "^6.0.0"
42+
},
43+
"devDependencies": {
44+
"@backstage/cli": "^0.28.0",
45+
"@backstage/core-app-api": "^1.15.1",
46+
"@backstage/dev-utils": "^1.1.2",
47+
"@backstage/test-utils": "^1.7.0",
48+
"@janus-idp/cli": "^2.0.0",
49+
"@testing-library/jest-dom": "^6.0.0",
50+
"@testing-library/react": "^14.0.0",
51+
"@testing-library/user-event": "^14.0.0",
52+
"msw": "^1.0.0",
53+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
54+
},
55+
"files": [
56+
"app-config.dynamic.yaml",
57+
"dist",
58+
"dist-scalprum"
59+
]
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## API Report File for "@red-hat-developer-hub/backstage-plugin-application-listener-test"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
import { BackstagePlugin } from '@backstage/core-plugin-api';
7+
8+
// @public (undocumented)
9+
export const applicationListenerTestPlugin: BackstagePlugin<{}, {}, {}>;
10+
11+
// @public (undocumented)
12+
export const LocationListener: () => null;
13+
14+
// (No @packageDocumentation comment for this package)
15+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { useLocation } from 'react-router-dom';
18+
19+
export const LocationListener = () => {
20+
const loc = useLocation();
21+
// eslint-disable-next-line no-console
22+
console.log('LocationListener', loc);
23+
return null;
24+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
export * from './plugin';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import { applicationListenerTestPlugin } from './plugin';
17+
18+
describe('application-listener-test', () => {
19+
it('should export plugin', () => {
20+
expect(applicationListenerTestPlugin).toBeDefined();
21+
});
22+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {
18+
createComponentExtension,
19+
createPlugin,
20+
} from '@backstage/core-plugin-api';
21+
22+
/**
23+
* @public
24+
*/
25+
export const applicationListenerTestPlugin = createPlugin({
26+
id: 'application-listener-test',
27+
});
28+
29+
/**
30+
* @public
31+
*/
32+
export const LocationListener = applicationListenerTestPlugin.provide(
33+
createComponentExtension({
34+
name: 'LocationListener',
35+
component: {
36+
lazy: () =>
37+
import('./components/LocationListener').then(m => m.LocationListener),
38+
},
39+
}),
40+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import '@testing-library/jest-dom';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# application-provider-test
2+
3+
Welcome to the application-provider-test plugin!
4+
5+
_This plugin was created through the Backstage CLI_
6+
7+
## Getting started
8+
9+
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 [/application-provider-test](http://localhost:3000/application-provider-test).
10+
11+
You can also serve the plugin in isolation by running `yarn start` in the plugin directory.
12+
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
13+
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# test global-header components. this isn't implemented yet!
2+
dynamicPlugins:
3+
frontend:
4+
red-hat-developer-hub.backstage-plugin-application-provider-test:
5+
dynamicRoutes:
6+
- path: /countpage
7+
importName: CountPage
8+
mountPoints:
9+
- mountPoint: application/provider
10+
importName: CountProvider
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import React from 'react';
17+
18+
import { Page, Content, Header } from '@backstage/core-components';
19+
import { createDevApp } from '@backstage/dev-utils';
20+
21+
import Grid from '@mui/material/Grid';
22+
23+
import {
24+
applicationProviderTestPlugin,
25+
CountPage,
26+
CountProvider,
27+
CountCard,
28+
} from '../src/plugin';
29+
30+
createDevApp()
31+
.registerPlugin(applicationProviderTestPlugin)
32+
.addPage({
33+
element: (
34+
<CountProvider>
35+
<CountPage />
36+
</CountProvider>
37+
),
38+
title: 'CountPage',
39+
path: '/count-page',
40+
})
41+
.addPage({
42+
element: (
43+
<CountProvider>
44+
<Page themeId="home">
45+
<Header title="CountProvider" />
46+
<Content>
47+
<Grid container spacing={2}>
48+
<Grid item>
49+
<CountCard />
50+
</Grid>
51+
<Grid item>
52+
<CountCard />
53+
</Grid>
54+
</Grid>
55+
</Content>
56+
</Page>
57+
</CountProvider>
58+
),
59+
title: 'CountProvider',
60+
path: '/count-provider',
61+
})
62+
.render();

0 commit comments

Comments
 (0)