Skip to content

Commit 30b6443

Browse files
feat(ai-experience): Integrate new ai-experience backend plugin (#594)
* add ai-experience backend plugin * add ai-experience common plugin * integrate backend plugin with frontend plugin * add ai learning paths * update the application to include global header and github login * fix sonarcloud issues * add links to catalog pages * update readme and fix spacing issues in the grids * add app-config.dynamic.yaml
1 parent 8a3f116 commit 30b6443

47 files changed

Lines changed: 1943 additions & 180 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

workspaces/ai-integrations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"tsc:full": "tsc --skipLibCheck true --incremental false",
1616
"build:all": "backstage-cli repo build --all",
1717
"build:api-reports": "yarn build:api-reports:only --tsc",
18-
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type --validate-release-tags",
18+
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
1919
"clean": "backstage-cli repo clean",
2020
"test": "backstage-cli repo test",
2121
"test:all": "backstage-cli repo test --coverage",

workspaces/ai-integrations/packages/app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"@material-ui/core": "^4.12.2",
4848
"@material-ui/icons": "^4.9.1",
4949
"@red-hat-developer-hub/backstage-plugin-ai-experience": "workspace:^",
50+
"@red-hat-developer-hub/backstage-plugin-global-header": "^1.4.0",
51+
"@redhat-developer/red-hat-developer-hub-theme": "^0.5.0",
5052
"react": "^18.0.2",
5153
"react-dom": "^18.0.2",
5254
"react-router": "^6.3.0",

workspaces/ai-integrations/packages/app/src/App.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { apis } from './apis';
4040
import { entityPage } from './components/catalog/EntityPage';
4141
import { searchPage } from './components/search/SearchPage';
4242
import { Root } from './components/Root';
43+
import { getThemes } from '@redhat-developer/red-hat-developer-hub-theme';
4344

4445
import {
4546
AlertDisplay,
@@ -52,6 +53,14 @@ import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
5253
import { RequirePermission } from '@backstage/plugin-permission-react';
5354
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
5455
import { AiExperiencePage } from '@red-hat-developer-hub/backstage-plugin-ai-experience';
56+
import { githubAuthApiRef } from '@backstage/core-plugin-api';
57+
58+
const githubProvider = {
59+
id: 'github-auth-provider',
60+
title: 'GitHub',
61+
message: 'Sign in using GitHub',
62+
apiRef: githubAuthApiRef,
63+
};
5564

5665
const app = createApp({
5766
apis,
@@ -72,15 +81,19 @@ const app = createApp({
7281
catalogIndex: catalogPlugin.routes.catalogIndex,
7382
});
7483
},
84+
themes: getThemes(),
7585
components: {
76-
SignInPage: props => <SignInPage {...props} auto providers={['guest']} />,
86+
SignInPage: props => (
87+
<SignInPage {...props} auto providers={['guest', githubProvider]} />
88+
),
7789
},
7890
});
7991

8092
const routes = (
8193
<FlatRoutes>
82-
<Route path="/" element={<Navigate to="catalog" />} />
94+
<Route path="/" element={<Navigate to="home" />} />
8395
<Route path="/catalog" element={<CatalogIndexPage />} />
96+
<Route path="/home" element={<AiExperiencePage />} />
8497
<Route
8598
path="/catalog/:namespace/:kind/:name"
8699
element={<CatalogEntityPage />}
@@ -111,7 +124,6 @@ const routes = (
111124
</Route>
112125
<Route path="/settings" element={<UserSettingsPage />} />
113126
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
114-
<Route path="/ai-experience" element={<AiExperiencePage />} />
115127
</FlatRoutes>
116128
);
117129

workspaces/ai-integrations/packages/app/src/components/Root/Root.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ import {
3737
SidebarSpace,
3838
useSidebarOpenState,
3939
Link,
40+
CatalogIcon,
4041
} from '@backstage/core-components';
4142
import MenuIcon from '@material-ui/icons/Menu';
4243
import SearchIcon from '@material-ui/icons/Search';
4344
import { MyGroupsSidebarItem } from '@backstage/plugin-org';
4445
import GroupIcon from '@material-ui/icons/People';
46+
import {
47+
GlobalHeaderComponent,
48+
defaultGlobalHeaderComponentsMountPoints,
49+
} from '@red-hat-developer-hub/backstage-plugin-global-header';
4550

4651
const useSidebarLogoStyles = makeStyles({
4752
root: {
@@ -73,6 +78,9 @@ const SidebarLogo = () => {
7378

7479
export const Root = ({ children }: PropsWithChildren<{}>) => (
7580
<SidebarPage>
81+
<GlobalHeaderComponent
82+
globalHeaderMountPoints={defaultGlobalHeaderComponentsMountPoints}
83+
/>
7684
<Sidebar>
7785
<SidebarLogo />
7886
<SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
@@ -81,7 +89,8 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
8189
<SidebarDivider />
8290
<SidebarGroup label="Menu" icon={<MenuIcon />}>
8391
{/* Global nav, not org-specific */}
84-
<SidebarItem icon={HomeIcon} to="catalog" text="Home" />
92+
<SidebarItem icon={HomeIcon} to="home" text="Home" />
93+
<SidebarItem icon={CatalogIcon} to="catalog" text="Catalog" />
8594
<MyGroupsSidebarItem
8695
singularTitle="My Group"
8796
pluralTitle="My Groups"

workspaces/ai-integrations/packages/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@backstage/plugin-search-backend-module-techdocs": "^0.4.0",
4646
"@backstage/plugin-search-backend-node": "^1.3.9",
4747
"@backstage/plugin-techdocs-backend": "^2.0.0",
48+
"@red-hat-developer-hub/backstage-plugin-ai-experience-backend": "workspace:^",
4849
"@red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog": "workspace:^",
4950
"app": "link:../app",
5051
"better-sqlite3": "^9.0.0",

workspaces/ai-integrations/packages/backend/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ backend.add(
7272
backend.add(catalogModuleRHDHRHOAILocationsExtensionPoint);
7373
backend.add(catalogModuleRHDHRHOAIReaderProcessor);
7474
backend.add(catalogModuleRHDHRHOAIEntityProvider);
75+
backend.add(
76+
import('@red-hat-developer-hub/backstage-plugin-ai-experience-backend'),
77+
);
78+
79+
backend.add(import('@backstage/plugin-auth-backend-module-github-provider'));
80+
7581
backend.start();
Lines changed: 16 additions & 0 deletions
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+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ai-experience
2+
3+
This plugin backend was templated using the Backstage CLI. You should replace this text with a description of your plugin backend.
4+
5+
## Installation
6+
7+
This plugin is installed via the `@red-hat-developer-hub/backstage-plugin-ai-experience-backend` package. To install it to your backend package, run the following command:
8+
9+
```bash
10+
# From your root directory
11+
yarn --cwd packages/backend add @red-hat-developer-hub/backstage-plugin-ai-experience-backend
12+
```
13+
14+
Then add the plugin to your backend in `packages/backend/src/index.ts`:
15+
16+
```ts
17+
const backend = createBackend();
18+
// ...
19+
backend.add(
20+
import('@red-hat-developer-hub/backstage-plugin-ai-experience-backend'),
21+
);
22+
```
23+
24+
## Development
25+
26+
This plugin backend can be started in a standalone mode from directly in this
27+
package with `yarn start`. It is a limited setup that is most convenient when
28+
developing the plugin backend itself.
29+
30+
If you want to run the entire project, including the frontend, run `yarn dev` from the root directory.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 { createBackend } from '@backstage/backend-defaults';
17+
import { mockServices } from '@backstage/backend-test-utils';
18+
import { catalogServiceMock } from '@backstage/plugin-catalog-node/testUtils';
19+
20+
const backend = createBackend();
21+
22+
backend.add(mockServices.auth.factory());
23+
backend.add(mockServices.httpAuth.factory());
24+
25+
// TEMPLATE NOTE:
26+
// Rather than using a real catalog you can use a mock with a fixed set of entities.
27+
backend.add(
28+
catalogServiceMock.factory({
29+
entities: [],
30+
}),
31+
);
32+
33+
backend.add(import('../src'));
34+
35+
backend.start();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@red-hat-developer-hub/backstage-plugin-ai-experience-backend",
3+
"version": "0.1.0",
4+
"license": "Apache-2.0",
5+
"private": true,
6+
"main": "src/index.ts",
7+
"types": "src/index.ts",
8+
"publishConfig": {
9+
"access": "public",
10+
"main": "dist/index.cjs.js",
11+
"types": "dist/index.d.ts"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/redhat-developer/rhdh-plugins",
16+
"directory": "workspaces/ai-integrations/plugins/ai-experience-backend"
17+
},
18+
"backstage": {
19+
"role": "backend-plugin",
20+
"pluginId": "ai-experience",
21+
"pluginPackages": [
22+
"@red-hat-developer-hub/backstage-plugin-ai-experience",
23+
"@red-hat-developer-hub/backstage-plugin-ai-experience-backend",
24+
"@red-hat-developer-hub/backstage-plugin-ai-experience-common"
25+
]
26+
},
27+
"scripts": {
28+
"start": "backstage-cli package start",
29+
"build": "backstage-cli package build",
30+
"lint": "backstage-cli package lint",
31+
"test": "backstage-cli package test",
32+
"clean": "backstage-cli package clean",
33+
"prepack": "backstage-cli package prepack",
34+
"postpack": "backstage-cli package postpack"
35+
},
36+
"dependencies": {
37+
"@backstage/backend-defaults": "^0.8.2",
38+
"@backstage/backend-plugin-api": "^1.2.1",
39+
"@backstage/catalog-client": "^1.9.1",
40+
"@backstage/errors": "^1.2.7",
41+
"@backstage/plugin-catalog-node": "^1.16.1",
42+
"@red-hat-developer-hub/backstage-plugin-ai-experience-common": "workspace:^",
43+
"express": "^4.17.1",
44+
"express-promise-router": "^4.1.0",
45+
"zod": "^3.22.4"
46+
},
47+
"devDependencies": {
48+
"@backstage/backend-test-utils": "^1.3.1",
49+
"@backstage/cli": "^0.31.0",
50+
"@types/express": "^4.17.6",
51+
"@types/supertest": "^2.0.12",
52+
"supertest": "^6.2.4"
53+
},
54+
"files": [
55+
"dist"
56+
]
57+
}

0 commit comments

Comments
 (0)