refactor: clean comments
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
import React, { FC } from 'react';
|
||||
|
||||
// import Alert from '@material-ui/lab/Alert';
|
||||
// import { Progress } from '@backstage/core';
|
||||
|
||||
import { BuildSummary } from 'circleci-api';
|
||||
|
||||
import { CITable, CITableBuildInfo } from '../CITable';
|
||||
@@ -26,8 +23,6 @@ import { useSelector, useDispatch } from 'react-redux';
|
||||
import { iRootState, Dispatch } from 'state/store';
|
||||
import { useApi } from '@backstage/core';
|
||||
import { circleCIApiRef } from 'api';
|
||||
// "lifecycle" : "finished", // :queued, :scheduled, :not_run, :not_running, :running or :finished
|
||||
// "outcome" : "failed", // :canceled, :infrastructure_fail, :timedout, :failed, :no_tests or :success
|
||||
|
||||
const makeReadableStatus = (status: string | undefined) => {
|
||||
if (typeof status === 'undefined') return '';
|
||||
@@ -71,13 +66,6 @@ const transform = (
|
||||
},
|
||||
status: makeReadableStatus(buildData.status),
|
||||
buildUrl: buildData.build_url,
|
||||
// tests: {
|
||||
// failed: 0,
|
||||
// passed: 10,
|
||||
// skipped: 3,
|
||||
// testUrl: 'nourlnow',
|
||||
// total: 13,
|
||||
// },
|
||||
};
|
||||
return tableBuildInfo;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Idea for this component to be somehow reusable representation of CI table view
|
||||
import React, { FC } from 'react';
|
||||
// import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
Link,
|
||||
CircularProgress,
|
||||
@@ -18,16 +16,6 @@ import {
|
||||
Table,
|
||||
} from '@backstage/core';
|
||||
import type { TableColumn } from '@backstage/core/src/components/Table';
|
||||
// const useStyles = makeStyles({
|
||||
// table: {
|
||||
// minWidth: 650,
|
||||
// },
|
||||
// avatar: {
|
||||
// height: 32,
|
||||
// width: 32,
|
||||
// borderRadius: '50%',
|
||||
// },
|
||||
// });
|
||||
|
||||
export type CITableBuildInfo = {
|
||||
id: string;
|
||||
@@ -51,7 +39,7 @@ export type CITableBuildInfo = {
|
||||
onRetryClick: () => void;
|
||||
};
|
||||
|
||||
// :retried, :canceled, :infrastructure_fail, :timedout, :not_run, :running, :failed, :queued, :scheduled, :not_running, :no_tests, :fixed, :success
|
||||
// retried, canceled, infrastructure_fail, timedout, not_run, running, failed, queued, scheduled, not_running, no_tests, fixed, success
|
||||
const getStatusComponent = (status: string | undefined = '') => {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'queued':
|
||||
@@ -69,48 +57,6 @@ const getStatusComponent = (status: string | undefined = '') => {
|
||||
}
|
||||
};
|
||||
|
||||
// export const CITableBuildRow: FC<{ build: CITableBuildInfo }> = ({ build }) => (
|
||||
// <TableRow key={build.id}>
|
||||
// <TableCell>{build.id}</TableCell>
|
||||
// <TableCell>
|
||||
// <Link to={`/circleci/build/${build.id}`}>{build.buildName}</Link>
|
||||
// </TableCell>
|
||||
// <TableCell>
|
||||
// {build.source.branchName}
|
||||
// <br />
|
||||
// {build.source.commit.hash}
|
||||
// </TableCell>
|
||||
// <TableCell align="center">{getStatusComponent(build.status)}</TableCell>
|
||||
// {build.tests && (
|
||||
// <TableCell>
|
||||
// {
|
||||
// <>
|
||||
// {build.tests.passed}/{build.tests.total} (
|
||||
// {build.tests.failed ? build.tests.failed + ', ' : ''}
|
||||
// {build.tests.skipped ? build.tests.skipped : ''})
|
||||
// </>
|
||||
// }
|
||||
// </TableCell>
|
||||
// )}
|
||||
// <TableCell align="center">
|
||||
// <Button onClick={build.onRetryClick}>
|
||||
// <RetryIcon />
|
||||
// </Button>
|
||||
// </TableCell>
|
||||
// </TableRow>
|
||||
// );
|
||||
|
||||
// export const CITableBuildHeadRow:FC<{isTestDataAvailable: boolean}> = ({isTestDataAvailable}) => (
|
||||
// <TableRow>
|
||||
// <TableCell>ID</TableCell>
|
||||
// <TableCell>Build</TableCell>
|
||||
// <TableCell>Source</TableCell>
|
||||
// <TableCell align="center">Status</TableCell>
|
||||
// {isTestDataAvailable && <TableCell>Tests</TableCell>}
|
||||
// <TableCell align="center">Actions</TableCell>
|
||||
// </TableRow>
|
||||
// );
|
||||
|
||||
const generatedColumns: TableColumn[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
@@ -164,8 +110,6 @@ export const CITable: FC<{
|
||||
builds: CITableBuildInfo[];
|
||||
projectName: string;
|
||||
}> = React.memo(({ builds = [], projectName }) => {
|
||||
// const classes = useStyles();
|
||||
// const isTestDataAvailable = builds.some(build => build.tests);
|
||||
return (
|
||||
<Table
|
||||
options={{ paging: false }}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import { circleCIApiRef } from 'api';
|
||||
import { BuildSummary } from 'circleci-api';
|
||||
import { CITableBuildInfo } from 'pages/BuildsPage/lib/CITable';
|
||||
|
||||
const makeReadableStatus = (status: string | undefined) => {
|
||||
if (typeof status === 'undefined') return '';
|
||||
return ({
|
||||
retried: 'Retried',
|
||||
canceled: 'Canceled',
|
||||
infrastructure_fail: 'Infra fail',
|
||||
timedout: 'Timedout',
|
||||
not_run: 'Not run',
|
||||
running: 'Running',
|
||||
failed: 'Failed',
|
||||
queued: 'Queued',
|
||||
scheduled: 'Scheduled',
|
||||
not_running: 'Not running',
|
||||
no_tests: 'No tests',
|
||||
fixed: 'Fixed',
|
||||
success: 'Success',
|
||||
} as Record<string, string>)[status];
|
||||
};
|
||||
|
||||
export const transformBuildSummary = (
|
||||
_: typeof circleCIApiRef.T,
|
||||
buildData: BuildSummary,
|
||||
) => {
|
||||
const tableBuildInfo: CITableBuildInfo = {
|
||||
id: String(buildData.build_num),
|
||||
buildName: buildData.subject
|
||||
? buildData.subject +
|
||||
(buildData.retry_of ? ` (retry of #${buildData.retry_of})` : '')
|
||||
: '',
|
||||
onRetryClick: () => {}, //api.retry(String(buildData.build_num)),
|
||||
source: {
|
||||
branchName: String(buildData.branch),
|
||||
commit: {
|
||||
hash: String(buildData.vcs_revision),
|
||||
url: 'todo',
|
||||
},
|
||||
},
|
||||
status: makeReadableStatus(buildData.status),
|
||||
buildUrl: buildData.build_url,
|
||||
// tests: {
|
||||
// failed: 0,
|
||||
// passed: 10,
|
||||
// skipped: 3,
|
||||
// testUrl: 'nourlnow',
|
||||
// total: 13,
|
||||
// },
|
||||
};
|
||||
return tableBuildInfo;
|
||||
};
|
||||
|
||||
export const transformBuildSummaries = (
|
||||
buildsData: BuildSummary[],
|
||||
api: typeof circleCIApiRef.T,
|
||||
): CITableBuildInfo[] => {
|
||||
return buildsData.map((buildSummary) =>
|
||||
transformBuildSummary(api, buildSummary),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user