Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workspaces/cost-management/.changeset/nfs-frontend-alpha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/plugin-cost-management': minor
---

Add a New Frontend System `/alpha` export so the plugin loads in RHDH 2.1, with Optimizations and Cost Management sidebar pages. Legacy PluginRoot exports are unchanged.
9 changes: 7 additions & 2 deletions workspaces/cost-management/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
Run all commands from `workspaces/cost-management/` (the workspace root).

- Install: `yarn install`
- Dev (full app + backend, slow): `yarn start`
- Dev (NFS app + full backend, RBAC): `yarn start`
- Dev (legacy app + full backend): `yarn start:legacy`
- Dev (plugin hot-reload, fast): `yarn start:dev`
- Dev (frontend plugin only): `yarn start:fe-plugin`
- Dev (NFS frontend plugin only): `yarn start:fe-plugin`
- Dev (legacy frontend plugin only): `yarn start:fe-plugin:legacy`
- Dev (backend plugin only): `yarn start:be-plugin`
- Build all: `yarn build:all`
- Test all (with coverage): `yarn test:all`
Expand All @@ -33,6 +35,9 @@ workspaces/cost-management/
│ └── cost-management-common/ # Shared types, API clients, permissions
│ └── src/generated/ # Auto-generated OpenAPI types — do not hand-edit
├── packages/ # Dev environment shell only (app + backend wiring)
│ ├── app/ # NFS frontend (`yarn start`)
│ ├── app-legacy/ # Legacy frontend (`yarn start:legacy`)
│ └── backend/ # Full backend with RBAC
├── docs/
│ ├── rbac.md # Full RBAC permission reference
│ └── dynamic-plugin.md # Dynamic plugin installation guide
Expand Down
17 changes: 17 additions & 0 deletions workspaces/cost-management/docs/dynamic-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,20 @@ The procedure involves the following steps:
> proxy. SSO tokens are obtained internally via OAuth2 `client_credentials`
> grant and never exposed to the browser. RBAC filtering is enforced
> server-side before data is returned. See [rbac.md](./rbac.md) for details.

5. **RHDH 2.1 (New Frontend System):** enable the same OCI packages. Do **not** require `dynamicRoutes` / `importName`. Pages are discovered from the plugin `/alpha` export. Optional operator overrides:

```yaml
app:
extensions:
- page:cost-management:
config:
title: Optimizations
path: /cost-management/optimizations
- page:cost-management/openshift:
config:
title: Cost Management
path: /cost-management/openshift
```

The sidebar shows two items (**Optimizations** and **Cost Management**). Nested `menuItems.parent` is not available on NFS ([RHDH-specific gaps](https://github.com/redhat-developer/rhdh/blob/main/docs/dynamic-plugins/migrating-config-to-new-frontend-system.md#rhdh-specific-gaps)). Enable NFS on the backend with `APP_CONFIG_app_packageName=app-next` and `ENABLE_STANDARD_MODULE_FEDERATION=true` ([config migration](https://github.com/redhat-developer/rhdh/blob/main/docs/dynamic-plugins/migrating-config-to-new-frontend-system.md)).
4 changes: 3 additions & 1 deletion workspaces/cost-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"node": "22 || 24"
},
"scripts": {
"start": "concurrently -c auto -n \"fe,be\" -p \"{name}:{pid}\" \"yarn start-app\" \"yarn start-backend\"",
"start": "backstage-cli repo start",
"start:legacy": "backstage-cli repo start packages/app-legacy packages/backend",
"start-app": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"start:fe-plugin": "yarn workspace @red-hat-developer-hub/plugin-cost-management start",
"start:fe-plugin:legacy": "yarn workspace @red-hat-developer-hub/plugin-cost-management start:legacy",
"start:be-plugin": "yarn workspace @red-hat-developer-hub/plugin-cost-management-backend start",
"start:dev": "concurrently -c auto -n \"fe,be\" -p \"{name}:{pid}\" \"yarn start:fe-plugin\" \"yarn start:be-plugin\"",
"tsc": "tsc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
89 changes: 89 additions & 0 deletions workspaces/cost-management/packages/app-legacy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "app-legacy",
"version": "0.0.5",
"private": true,
"bundled": true,
"backstage": {
"role": "frontend"
},
"repository": {
"type": "git",
"url": "https://github.com/redhat-developer/rhdh-plugins",
"directory": "workspaces/cost-management/packages/app-legacy"
},
"scripts": {
"start": "backstage-cli package start",
"build": "backstage-cli package build",
"clean": "backstage-cli package clean",
"test": "backstage-cli package test",
"lint": "backstage-cli package lint"
},
"dependencies": {
"@backstage-community/plugin-rbac": "1.55.2",
"@backstage-community/plugin-tech-radar": "^0.7.4",
"@backstage/app-defaults": "^1.7.11",
"@backstage/catalog-model": "^1.10.0",
"@backstage/cli": "^0.36.5",
"@backstage/core-app-api": "^1.20.4",
"@backstage/core-components": "^0.18.13",
"@backstage/core-plugin-api": "^1.12.9",
"@backstage/integration-react": "^1.2.21",
"@backstage/plugin-api-docs": "^0.14.4",
"@backstage/plugin-catalog": "^2.0.8",
"@backstage/plugin-catalog-common": "^1.1.10",
"@backstage/plugin-catalog-graph": "^0.6.7",
"@backstage/plugin-catalog-import": "^0.13.17",
"@backstage/plugin-catalog-react": "^3.2.2",
"@backstage/plugin-org": "^0.7.8",
"@backstage/plugin-permission-react": "^0.5.4",
"@backstage/plugin-scaffolder": "^1.38.2",
"@backstage/plugin-search": "^1.7.7",
"@backstage/plugin-search-react": "^1.11.7",
"@backstage/plugin-techdocs": "^1.18.0",
"@backstage/plugin-techdocs-module-addons-contrib": "^1.1.39",
"@backstage/plugin-techdocs-react": "^1.3.14",
"@backstage/plugin-user-settings": "^0.9.6",
"@backstage/theme": "^0.7.3",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@patternfly/patternfly": "^6.3.0",
"@red-hat-developer-hub/backstage-plugin-theme": "^0.14.0",
"@red-hat-developer-hub/plugin-cost-management": "workspace:^",
"history": "^5.0.0",
"react": "^18.0.2",
"react-dom": "^18.0.2",
"react-router": "^6.30.2",
"react-router-dom": "^6.30.2",
"react-use": "^17.2.4"
},
"devDependencies": {
"@backstage/test-utils": "^1.7.21",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.16.1",
"@mui/material": "^5.16.1",
"@playwright/test": "1.61.1",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/react": "^18",
"@types/react-dom": "*",
"cross-env": "^7.0.0"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"files": [
"dist"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Backstage is an open source framework for building developer portals"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link
rel="manifest"
href="<%= publicPath %>/manifest.json"
crossorigin="use-credentials"
/>
<link rel="icon" href="<%= publicPath %>/favicon.ico" />
<link rel="shortcut icon" href="<%= publicPath %>/favicon.ico" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="<%= publicPath %>/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="<%= publicPath %>/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="<%= publicPath %>/favicon-16x16.png"
/>
<link
rel="mask-icon"
href="<%= publicPath %>/safari-pinned-tab.svg"
color="#5bbad5"
/>
<title><%= config.getOptionalString('app.title') ?? 'Backstage' %></title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `yarn start`.
To create a production bundle, use `yarn build`.
-->
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Backstage",
"name": "Backstage",
"icons": [
{
"src": "favicon.ico",
"sizes": "48x48",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions workspaces/cost-management/packages/app-legacy/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Red Hat, Inc.
*
* 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 { render, waitFor } from '@testing-library/react';
import App from './App';

describe('App', () => {
it('should render', async () => {
process.env = {
NODE_ENV: 'test',
APP_CONFIG: [
{
data: {
app: { title: 'Test' },
backend: { baseUrl: 'http://localhost:7007' },
techdocs: {
storageUrl: 'http://localhost:7007/api/techdocs/static/docs',
},
},
context: 'test',
},
] as any,
};

const rendered = render(<App />);

await waitFor(() => {
expect(rendered.baseElement).toBeInTheDocument();
});
});
});
Loading
Loading