Skip to content

Commit

Permalink
feat(report-portal): add global page for report portal plugin (#1)
Browse files Browse the repository at this point in the history
- added Instances Page
- added Projects Page
- added Launches Page
- Updated Report Portal API
- Added api pagination for table
- fixed tsc and lint issues in backend plugin
- added Readme files for both plugins
- added report portal icon componet (#2)
  • Loading branch information
yashoswalyo committed Apr 29, 2024
1 parent c57d369 commit 1bf023a
Show file tree
Hide file tree
Showing 41 changed files with 5,457 additions and 4,634 deletions.
8 changes: 8 additions & 0 deletions plugins/report-portal-backend/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- yashoswalyo
- riginoommen
- deshmukhmayur
reviewers:
- yashoswalyo
- riginoommen
- deshmukhmayur
61 changes: 61 additions & 0 deletions plugins/report-portal-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,64 @@ start` in the root directory, and then navigating to [/report-portal](http://loc
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.

## Installation

- Install the plugin
```shell
yarn workspace backend add @appdev-platform/backstage-plugin-report-portal-backend
```
- Update the following files

- Create `/packages/backend/src/plugins/report-portal.ts` and add following code:

```ts
import { createRouter } from '@appdev-platform/backstage-plugin-report-portal-backend';
import { Router } from 'express';

import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({ logger: env.logger, config: env.config });
}
```

- Add following lines to `/packages/backend/src/index.ts`:

```ts
import reportPortal from './plugins/report-portal';
async function main() {
// add the files to create backend router
const reportPortalEnv = useHotMemoize(module, () =>
createEnv('report-portal'),
);
apiRouter.use('/report-portal', await reportPortal(reportPortalEnv));
}
```

- Add below configuration to `app-config.yaml`:

```yaml
reportPortal:
# under integrations you can configure-
# multiple instances of report portal
integrations:
# host address of your instance
# for e.g: report-portal.mycorp.com
- host: ${REPORT_PORTAL_HOST}
# Baser API url of your instance
# for e.g: https://report-portal.mycorp.com/api/
baseUrl: ${REPORT_PORTAL_BASE_URL}
# Get the API key from profile page of your instance
# for e.g: Bearer fae22be1-0000-0000-8392-de1635eed9f4
token: ${REPORT_PORTAL_TOKEN}
# (optional) Filter the projects by type
# Default: "INTERNAL"
filterType: 'INTERNAL'
```
1 change: 1 addition & 0 deletions plugins/report-portal-backend/app-config.janus-idp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ reportPortal:
- host: ${REPORT_PORTAL_HOST}
baseUrl: ${REPORT_PORTAL_BASE_URL}
token: ${REPORT_PORTAL_TOKEN}
filterType: ${REPORT_PORTAL_FILTER_TYPE}
6 changes: 6 additions & 0 deletions plugins/report-portal-backend/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Config {
integrations: Array<{
/**
* Host of report portal url
* @visibility frontend
*/
host: string;
/**
Expand All @@ -17,6 +18,11 @@ export interface Config {
* @visibility secret
*/
token: string;
/**
* Filter type to apply for current host
* @visibility frontend
*/
filterType: string;
}>;
};
}
10 changes: 5 additions & 5 deletions plugins/report-portal-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appdev-platform/backstage-plugin-report-portal-backend",
"version": "0.1.0",
"version": "0.1.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,7 +40,7 @@
"tsc": "tsc"
},
"dependencies": {
"@backstage/backend-common": "^0.19.8",
"@backstage/backend-common": "^0.21.0",
"@backstage/backend-plugin-api": "^0.6.6",
"@backstage/backend-plugin-manager": "npm:@janus-idp/[email protected]",
"@backstage/config": "^1.1.1",
Expand Down Expand Up @@ -70,13 +70,13 @@
"configSchema": "config.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/janus-idp/backstage-plugins",
"directory": "plugins/report-portal"
"url": "https://github.com/appdev-platform/backstage-plugins",
"directory": "plugins/report-portal-backend"
},
"keywords": [
"backstage",
"plugin"
],
"homepage": "https://janus-idp.io/",
"bugs": "https://github.com/janus-idp/backstage-plugins/issues"
"bugs": "https://github.com/appdev-platform/backstage-plugins/issues"
}
10 changes: 4 additions & 6 deletions plugins/report-portal-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getVoidLogger } from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';

import express from 'express';
import request from 'supertest';

import { createRouter } from './router';

Expand All @@ -11,6 +11,7 @@ describe('createRouter', () => {
beforeAll(async () => {
const router = await createRouter({
logger: getVoidLogger(),
config: new ConfigReader({ reportPortal: { integrations: [] } }),
});
app = express().use(router);
});
Expand All @@ -19,12 +20,9 @@ describe('createRouter', () => {
jest.resetAllMocks();
});

describe('GET /health', () => {
describe('just a test', () => {
it('returns ok', async () => {
const response = await request(app).get('/health');

expect(response.status).toEqual(200);
expect(response.body).toEqual({ status: 'ok' });
expect(app).toBeDefined();
});
});
});
2 changes: 1 addition & 1 deletion plugins/report-portal-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface RouterOptions {
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { logger, config } = options;
const { config } = options;
const hostsConfig = config.getConfigArray('reportPortal.integrations');

const router = Router();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createServiceBuilder } from '@backstage/backend-common';
import { Config, ConfigReader } from '@backstage/config';
import { ConfigReader } from '@backstage/config';

import { Logger } from 'winston';

Expand Down
2 changes: 1 addition & 1 deletion plugins/report-portal-backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"include": ["src", "dev", "migrations"],
"exclude": ["node_modules"],
"compilerOptions": {
"outDir": "../../dist-types/plugins/report-portal",
"outDir": "../../dist-types/plugins/report-portal-backend",
"rootDir": "."
}
}
8 changes: 8 additions & 0 deletions plugins/report-portal/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- yashoswalyo
- riginoommen
- deshmukhmayur
reviewers:
- yashoswalyo
- riginoommen
- deshmukhmayur
80 changes: 80 additions & 0 deletions plugins/report-portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,83 @@ Your plugin has been added to the example app in this repository, meaning you'll
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.

## Prequisite

- [report-portal-backend](../report-portal/) plugin

## Installation:

- Run the following command in your backstage project

```shell
yarn workspace app add @appdev-platform/backstage-plugin-report-portal
```

- Now import the components

- open `/packages/app/src/App.tsx` and add the following code

```js
import { ReportPortalGlobalPage } from '@appdev-platform/backstage-plugin-report-portal';

export const AppBase = () => {
// In <FlatRoutes> add the following route
<Route path="/report-portal" element={<ReportPortalGlobalPage />} />;
};
```

- open `/packages/app/src/components/Root/Root.tsx` and add the following code

```js
import AssessmentIcon from '@material-ui/icons/Assessment';
//...
//...
export const Root = ({ children }: PropsWithChildren<{}>) => (
<SidebarPage>
<!-- Add the link to route in your sidebar component -->
<SidebarItem icon={AssessmentIcon} to="report-portal" text="Report Portal" />
</SidebarPage>
)
```

- To add a card on overview tab of entity page, open `/packages/app/src/components/catalog/EntityPage.tsx` and add the following code:

```js
import { ReportPortalOverviewCard } from '@appdev-platform/backstage-plugin-report-portal';
const overviewContent = (
<Grid>
<!-- add your card on overview -->
<Grid item lg={4} md={6} xs={12}>
<ReportPortalOverviewCard variant="gridItem" />
</Grid>
</Grid>
);
```

- Add the below configuration to your `app-config.yaml` file

```yaml
reportPortal:
# under integrations you can configure-
# multiple instances of report portal
integrations:
# host address of your instance
# for e.g: report-portal.mycorp.com
- host: ${REPORT_PORTAL_HOST}
# Baser API url of your instance
# for e.g: https://report-portal.mycorp.com/api/
baseUrl: ${REPORT_PORTAL_BASE_URL}
# Get the API key from profile page of your instance
# for e.g: Bearer fae22be1-0000-0000-8392-de1635eed9f4
token: ${REPORT_PORTAL_TOKEN}
# (optional) Filter the projects by type
# Default: "INTERNAL"
filterType: 'INTERNAL'
```
4 changes: 4 additions & 0 deletions plugins/report-portal/app-config.janus-idp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ dynamicPlugins:
dynamicRoutes: []
mountPoints: []
routeBindings: []
reportPortal:
integrations:
- host: ${REPORT_PORTAL_HOST}
filterType: ${REPORT_PORTAL_FILTER_TYPE}
20 changes: 19 additions & 1 deletion plugins/report-portal/config.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export interface Config {}
export interface Config {
/**
* Configuration values for Report Portal plugin
*/
reportPortal: {
integrations: Array<{
/**
* Host of report portal url
* @visibility frontend
*/
host: string;
/**
* Type of projects to list
* @visibility frontend
*/
filterType: string;
}>;
};
}
1 change: 0 additions & 1 deletion plugins/report-portal/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createDevApp } from '@backstage/dev-utils';
import {
EntityAboutCard,
EntityHasSubcomponentsCard,
EntityLayout,
EntityLinksCard,
} from '@backstage/plugin-catalog';
import { EntityProvider } from '@backstage/plugin-catalog-react';
Expand Down
77 changes: 77 additions & 0 deletions plugins/report-portal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "@appdev-platform/backstage-plugin-report-portal",
"version": "0.1.1",
"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"
},
"backstage": {
"role": "frontend-plugin"
},
"sideEffects": false,
"scripts": {
"build": "backstage-cli package build",
"clean": "backstage-cli package clean",
"export-dynamic": "janus-cli package export-dynamic-plugin",
"lint": "backstage-cli package lint",
"postpack": "backstage-cli package postpack",
"postversion": "yarn run export-dynamic",
"prepack": "backstage-cli package prepack",
"start": "backstage-cli package start",
"test": "backstage-cli package test --passWithNoTests --coverage",
"tsc": "tsc"
},
"dependencies": {
"@backstage/catalog-model": "^1.4.4",
"@backstage/core-components": "^0.14.0",
"@backstage/core-plugin-api": "^1.9.0",
"@backstage/plugin-catalog-react": "^1.10.0",
"@backstage/theme": "^0.5.1",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
"luxon": "^3.4.4",
"react-multi-progress": "^1.3.0",
"react-use": "^17.2.4"
},
"peerDependencies": {
"react": "16.13.1 || ^17.0.0 || ^18.0.0",
"react-router-dom": "^6.22.0"
},
"devDependencies": {
"@backstage/cli": "0.25.2",
"@backstage/core-app-api": "1.11.0",
"@backstage/dev-utils": "1.0.22",
"@backstage/plugin-catalog": "^1.16.1",
"@backstage/test-utils": "1.5.0",
"@janus-idp/cli": "1.7.3",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/luxon": "^3.4.2",
"msw": "1.0.0"
},
"files": [
"dist",
"config.d.ts",
"dist-scalprum",
"app-config.janus-idp.yaml"
],
"configSchema": "config.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/appdev-platform/backstage-plugins",
"directory": "plugins/report-portal"
},
"keywords": [
"backstage",
"plugin"
],
"homepage": "https://janus-idp.io/",
"bugs": "https://github.com/appdev-platform/backstage-plugins/issues"
}
Loading

0 comments on commit 1bf023a

Please sign in to comment.