forked from janus-idp/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(report-portal): Added global page for report portal plugin
- 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 Signed-off-by: Yash Oswal <[email protected]>
- Loading branch information
1 parent
b1887b3
commit bcc54f2
Showing
32 changed files
with
5,212 additions
and
4,791 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
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
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
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; | ||
}>; | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "@appdev-platform/backstage-plugin-report-portal", | ||
"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" | ||
}, | ||
"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", | ||
"moment": "^2.30.1", | ||
"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", | ||
"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/janus-idp/backstage-plugins", | ||
"directory": "plugins/report-portal" | ||
}, | ||
"keywords": [ | ||
"backstage", | ||
"plugin" | ||
], | ||
"homepage": "https://janus-idp.io/", | ||
"bugs": "https://github.com/janus-idp/backstage-plugins/issues" | ||
} |
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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import { ApiRef, createApiRef } from '@backstage/core-plugin-api'; | ||
|
||
import { LaunchDetailsResp, ProjectDetails } from './types'; | ||
import { LaunchDetailsResp, ProjectDetails, ProjectListResp } from './types'; | ||
|
||
/** @public */ | ||
export const reportPortalApiRef: ApiRef<ReportPortalApi> = createApiRef({ | ||
id: 'plugin.report-portal', | ||
}); | ||
|
||
export type ReportPortalApi = { | ||
getReportPortalBaseUrl: (host: string) => string; | ||
getLaunchResults: ( | ||
projectId: string, | ||
filter: string, | ||
host: string, | ||
filters: { [key: string]: string | number } | undefined, | ||
) => Promise<LaunchDetailsResp>; | ||
getProjectDetails: ( | ||
projectId: string, | ||
host: string, | ||
) => Promise<ProjectDetails>; | ||
getInstanceDetails: ( | ||
host: string, | ||
filters: { [key: string]: string | number } | undefined, | ||
) => Promise<ProjectListResp>; | ||
}; |
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,66 @@ | ||
import { DiscoveryApi } from '@backstage/core-plugin-api'; | ||
|
||
import { ReportPortalApi } from './ReportPortalApi'; | ||
import { LaunchDetailsResp, ProjectDetails, ProjectListResp } from './types'; | ||
|
||
export class ReportPortalClient implements ReportPortalApi { | ||
constructor(private readonly discoveryApi: DiscoveryApi) {} | ||
|
||
private async getBaseApiUrl() { | ||
return `${await this.discoveryApi.getBaseUrl('report-portal')}/v1/`; | ||
} | ||
|
||
getReportPortalBaseUrl(host: string) { | ||
return `https://${host}/`; | ||
} | ||
|
||
async getLaunchResults( | ||
projectId: string, | ||
host: string, | ||
filters: { [key: string]: string | number } | undefined, | ||
) { | ||
const baseUrl = new URL( | ||
`${projectId}/launch/latest`, | ||
await this.getBaseApiUrl(), | ||
); | ||
if (filters) { | ||
Object.keys(filters).forEach(key => | ||
baseUrl.searchParams.append(key, filters[key] as string), | ||
); | ||
} | ||
baseUrl.searchParams.append('host', host); | ||
const response = await fetch(baseUrl); | ||
if (response.status >= 400 && response.status < 600) { | ||
throw new Error('Failed to fetch launch details'); | ||
} | ||
return (await response.json()) as LaunchDetailsResp; | ||
} | ||
|
||
async getProjectDetails(projectId: string, host: string) { | ||
const baseUrl = new URL(`project/${projectId}`, await this.getBaseApiUrl()); | ||
baseUrl.searchParams.append('host', host); | ||
const response = await fetch(baseUrl); | ||
if (response.status >= 400 && response.status < 600) { | ||
throw new Error('Failed to fetch project details'); | ||
} | ||
return (await response.json()) as ProjectDetails; | ||
} | ||
|
||
async getInstanceDetails( | ||
host: string, | ||
filters: { [key: string]: string | number } | undefined, | ||
) { | ||
const baseUrl = new URL('project/list', await this.getBaseApiUrl()); | ||
if (filters) { | ||
Object.keys(filters).forEach(key => | ||
baseUrl.searchParams.append(key, filters[key] as string), | ||
); | ||
} | ||
baseUrl.searchParams.append('host', host); | ||
const response = await fetch(baseUrl); | ||
if (response.status >= 400 && response.status < 600) { | ||
throw new Error('Failed to get instance details'); | ||
} | ||
return (await response.json()) as ProjectListResp; | ||
} | ||
} |
Oops, something went wrong.