Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(report-portal): fix statistics card #4

Merged
merged 1 commit into from
May 15, 2024
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
8 changes: 0 additions & 8 deletions plugins/report-portal-backend/OWNERS

This file was deleted.

9 changes: 9 additions & 0 deletions plugins/report-portal-backend/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
export interface Config {
/**
* Configuration values for Report Portal plugin
* @visibility frontend
*/
reportPortal: {
/**
* Email to connect for adding more instances
* @visibility frontend
*/
supportEmail: string;
/**
* @visibility frontend
*/
integrations: Array<{
/**
* Host of report portal url
Expand Down
2 changes: 1 addition & 1 deletion 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.1",
"version": "0.2.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down
3 changes: 2 additions & 1 deletion plugins/report-portal-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
*/

export * from './dynamic/index';
export * from './service/router';
export { createRouter } from './service/router';
export { reportPortalPlugin as default } from './plugin';
7 changes: 3 additions & 4 deletions plugins/report-portal-backend/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { loggerToWinstonLogger } from '@backstage/backend-common';
import {
coreServices,
createBackendPlugin,
Expand All @@ -21,10 +20,10 @@ export const reportPortalPlugin = createBackendPlugin({
http: coreServices.httpRouter,
},
async init({ config, logger, http }) {
http.use(() =>
createRouter({
http.use(
await createRouter({
config: config,
logger: loggerToWinstonLogger(logger),
logger: logger,
}),
);
},
Expand Down
8 changes: 5 additions & 3 deletions plugins/report-portal-backend/src/service/router.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { errorHandler } from '@backstage/backend-common';
import { LoggerService } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';

import express from 'express';
import Router from 'express-promise-router';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { Logger } from 'winston';

export interface RouterOptions {
logger: Logger;
logger: LoggerService;
config: Config;
}

export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
const { config } = options;
const { config, logger } = options;

logger.info('Report portal backend plugin initialized');
const hostsConfig = config.getConfigArray('reportPortal.integrations');

const router = Router();
Expand Down
8 changes: 0 additions & 8 deletions plugins/report-portal/OWNERS

This file was deleted.

15 changes: 14 additions & 1 deletion plugins/report-portal/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
export interface Config {
/**
* Configuration values for Report Portal plugin
* @visibility frontend
*/
reportPortal: {
/**
* Email to connect for adding more instances
* @visibility frontend
*/
supportEmail: string;
/**
* @visibility frontend
*/
integrations: Array<{
/**
* Host of report portal url
* @visibility frontend
*/
host: string;
/**
* Type of projects to list
* Base api url for report portal instance
*/
baseUrl: string;
/**
* The Api token that will be used to
* @visibility secret
*/
token: string;
/**
* Filter type to apply for current host
* @visibility frontend
*/
filterType: string;
Expand Down
2 changes: 1 addition & 1 deletion plugins/report-portal/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@backstage/plugin-catalog';
import { EntityProvider } from '@backstage/plugin-catalog-react';

import { Grid } from '@material-ui/core';
import Grid from '@mui/material/Grid';

import { mockEntity } from '../src/mocks';
import { ReportPortalOverviewCard, reportPortalPlugin } from '../src/plugin';
Expand Down
8 changes: 4 additions & 4 deletions plugins/report-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appdev-platform/backstage-plugin-report-portal",
"version": "0.1.2",
"version": "0.2.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down Expand Up @@ -32,9 +32,9 @@
"@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",
"@mui/icons-material": "^5.15.17",
"@mui/material": "^5.15.17",
"@mui/styles": "^5.15.17",
"luxon": "^3.4.4",
"react-multi-progress": "^1.3.0",
"react-use": "^17.2.4"
Expand Down
13 changes: 8 additions & 5 deletions plugins/report-portal/src/api/ReportPortalClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';

import { ReportPortalApi } from './ReportPortalApi';
import {
Expand All @@ -8,7 +8,10 @@ import {
} from './types';

export class ReportPortalClient implements ReportPortalApi {
constructor(private readonly discoveryApi: DiscoveryApi) {}
constructor(
private readonly discoveryApi: DiscoveryApi,
private readonly fetchApi: FetchApi,
) {}

private async getBaseApiUrl() {
return `${await this.discoveryApi.getBaseUrl('report-portal')}/v1/`;
Expand All @@ -33,7 +36,7 @@ export class ReportPortalClient implements ReportPortalApi {
);
}
baseUrl.searchParams.append('host', host);
const response = await fetch(baseUrl);
const response = await this.fetchApi.fetch(baseUrl);
if (response.status !== 200) {
throw new Error('Failed to fetch launch details');
}
Expand All @@ -43,7 +46,7 @@ export class ReportPortalClient implements ReportPortalApi {
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);
const response = await this.fetchApi.fetch(baseUrl);
if (response.status !== 200) {
throw new Error('Failed to fetch project details');
}
Expand All @@ -61,7 +64,7 @@ export class ReportPortalClient implements ReportPortalApi {
);
}
baseUrl.searchParams.append('host', host);
const response = await fetch(baseUrl);
const response = await this.fetchApi.fetch(baseUrl);
if (response.status !== 200) {
throw new Error('Failed to get instance details');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
} from '@backstage/core-components';
import { useRouteRef } from '@backstage/core-plugin-api';

import { Button, makeStyles } from '@material-ui/core';
import Launch from '@material-ui/icons/Launch';
import Launch from '@mui/icons-material/Launch';
import Button from '@mui/material/Button';
import makeStyles from '@mui/styles/makeStyles';

import { projectsRouteRef, rootRouteRef } from '../../routes';
import { LaunchesPageContent } from './LaunchesPageContent/LaunchesPageContent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import React, { useEffect, useState } from 'react';
import { ErrorPanel, Table, TableColumn } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';

import { IconButton, Link } from '@material-ui/core';
import Launch from '@material-ui/icons/Launch';
import Launch from '@mui/icons-material/Launch';
import IconButton from '@mui/material/IconButton';
import Link from '@mui/material/Link';
import { DateTime } from 'luxon';

import {
Expand Down Expand Up @@ -160,6 +161,7 @@ export const LaunchesPageContent = (props: {
target="_blank"
rel="noopener noreferrer"
href={`https://${host}/ui/#${project}/launches/latest/${row.id}`}
size="large"
>
<Launch />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
} from '@backstage/core-components';
import { useRouteRef } from '@backstage/core-plugin-api';

import { Button, makeStyles } from '@material-ui/core';
import Launch from '@material-ui/icons/Launch';
import Launch from '@mui/icons-material/Launch';
import Button from '@mui/material/Button';
import makeStyles from '@mui/styles/makeStyles';

import { rootRouteRef } from '../../routes';
import { ProjectsPageContent } from './ProjectsPageContent/ProjectsPageContent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
} from '@backstage/core-components';
import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';

import { IconButton } from '@material-ui/core';
import Launch from '@material-ui/icons/Launch';
import { Skeleton } from '@material-ui/lab';
import Launch from '@mui/icons-material/Launch';
import IconButton from '@mui/material/IconButton';
import Skeleton from '@mui/material/Skeleton';

import {
ProjectDetails,
Expand Down Expand Up @@ -114,6 +114,7 @@ export const ProjectsPageContent = (props: { host: string }) => {
target="_blank"
rel="noopener noreferrer"
href={`https://${host}/ui/#${row.projectName}/`}
size="large"
>
<Launch />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react';
import { Link, Table, TableColumn } from '@backstage/core-components';
import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';

import { IconButton } from '@material-ui/core';
import LaunchIcon from '@material-ui/icons/Launch';
import { Skeleton } from '@material-ui/lab';
import LaunchIcon from '@mui/icons-material/Launch';
import IconButton from '@mui/material/IconButton';
import Skeleton from '@mui/material/Skeleton';

import { reportPortalApiRef } from '../../../api';
import { useInstanceDetails } from '../../../hooks';
Expand Down Expand Up @@ -75,6 +75,7 @@ export const GlobalPageContent = () => {
href={reportPortalApi.getReportPortalBaseUrl(rowData.instance)}
rel="noreferrer noopener"
target="_blank"
size="large"
>
<LaunchIcon />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import React from 'react';
import { Content, PageWithHeader } from '@backstage/core-components';
import { configApiRef, useApi } from '@backstage/core-plugin-api';

import { Button, Grid } from '@material-ui/core';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';

import { GlobalPageContent } from './GlobalPageContent';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { SvgIcon, SvgIconProps } from '@material-ui/core';
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';

export const ReportPortalIcon = (props: SvgIconProps) => {
return (
Expand Down
Loading
Loading