diff --git a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx b/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx index 0c1337ea6e..c9ab028359 100644 --- a/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildListComponent/BuildListComponent.tsx @@ -14,49 +14,13 @@ * limitations under the License. */ import React, { useRef, useState } from 'react'; -import { Table, TableColumn } from '@backstage/core-components'; +import { Table } from '@backstage/core-components'; import { useApi } from '@backstage/core-plugin-api'; -import { Build, BuildFilters, xcmetricsApiRef } from '../../api'; -import { formatDuration, formatTime } from '../../utils'; -import { Chip, Grid } from '@material-ui/core'; +import { BuildFilters, xcmetricsApiRef } from '../../api'; +import { Grid } from '@material-ui/core'; import { BuildListFilterComponent as Filters } from '../BuildListFilterComponent'; import { DateTime } from 'luxon'; - -const columns: TableColumn[] = [ - { - title: 'Status', - field: 'buildStatus', - }, - { - title: 'Project', - field: 'projectName', - }, - { - title: 'Schema', - field: 'schema', - }, - { - title: 'Started', - field: 'startedAt', - searchable: false, - render: data => formatTime(data.startTimestamp), - }, - { - title: 'Duration', - field: 'duration', - render: data => formatDuration(data.duration), - }, - { - title: 'User', - field: 'userid', - }, - { - field: 'isCI', - render: data => data.isCi && , - width: '10', - sorting: false, - }, -]; +import { buildPageColumns } from '../BuildTableColumns'; export const BuildListComponent = () => { const client = useApi(xcmetricsApiRef); @@ -82,7 +46,7 @@ export const BuildListComponent = () => { /> { diff --git a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx b/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx index 08cb82c8ca..4f6604702e 100644 --- a/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx +++ b/plugins/xcmetrics/src/components/BuildListFilterComponent/BuildListFilterComponent.tsx @@ -90,21 +90,21 @@ export const BuildListFilterComponent = ({ direction="row" className={classes.filtersContent} > - + setValues({ ...values, from: date })} /> - + setValues({ ...values, to: date })} /> - + , + failed: , + stopped: , +}; + +const baseColumns: TableColumn[] = [ + { + field: 'buildStatus', + render: data => STATUS_ICONS[data.buildStatus], + }, + { + title: 'Project', + field: 'projectName', + }, + { + title: 'Schema', + field: 'schema', + }, + { + title: 'Started', + field: 'startedAt', + render: data => formatTime(data.startTimestamp), + cellStyle: { whiteSpace: 'nowrap' }, + }, + { + title: 'Duration', + field: 'duration', + render: data => formatDuration(data.duration), + }, + { + title: 'User', + field: 'userid', + }, +]; + +const isCi: TableColumn = { + field: 'isCI', + render: data => data.isCi && , + width: '10', + sorting: false, +}; + +export const overviewColumns: TableColumn[] = [...baseColumns, isCi]; + +export const buildPageColumns: TableColumn[] = [ + ...baseColumns, + { + title: 'Host', + field: 'machineName', + }, + { + title: 'Warnings', + field: 'warningCount', + }, + { + title: 'Category', + field: 'category', + render: data => , + }, + isCi, +]; diff --git a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx b/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx index cee8e2a549..6fa3abda2e 100644 --- a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx +++ b/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx @@ -13,69 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { ReactChild } from 'react'; +import React from 'react'; import { ContentHeader, SupportButton, Progress, - StatusOK, - StatusError, - StatusWarning, Table, - TableColumn, EmptyState, InfoCard, } from '@backstage/core-components'; import { useApi } from '@backstage/core-plugin-api'; -import { Build, BuildStatus, xcmetricsApiRef } from '../../api'; +import { xcmetricsApiRef } from '../../api'; import { useAsync } from 'react-use'; import { Alert } from '@material-ui/lab'; import { StatusMatrixComponent } from '../StatusMatrixComponent'; -import { formatDuration, formatTime } from '../../utils'; -import { Chip, Grid } from '@material-ui/core'; +import { Grid } from '@material-ui/core'; import { OverviewTrendsComponent } from '../OverviewTrendsComponent'; - -const STATUS_ICONS: { [key in BuildStatus]: ReactChild } = { - succeeded: , - failed: , - stopped: , -}; - -const columns: TableColumn[] = [ - { - field: 'buildStatus', - render: data => STATUS_ICONS[data.buildStatus], - }, - { - title: 'Project', - field: 'projectName', - }, - { - title: 'Schema', - field: 'schema', - }, - { - title: 'Started', - field: 'startedAt', - searchable: false, - render: data => formatTime(data.startTimestamp), - }, - { - title: 'Duration', - field: 'duration', - render: data => formatDuration(data.duration), - }, - { - title: 'User', - field: 'userid', - }, - { - field: 'isCI', - render: data => data.isCi && , - width: '10', - sorting: false, - }, -]; +import { overviewColumns } from '../BuildTableColumns'; export const OverviewComponent = () => { const client = useApi(xcmetricsApiRef); @@ -108,9 +62,14 @@ export const OverviewComponent = () => {
Latest Builds diff --git a/plugins/xcmetrics/src/utils/format.ts b/plugins/xcmetrics/src/utils/format.ts index 085441bb84..8c6dadb768 100644 --- a/plugins/xcmetrics/src/utils/format.ts +++ b/plugins/xcmetrics/src/utils/format.ts @@ -23,8 +23,7 @@ export const formatDuration = (seconds: number) => { const h = duration.hours ? `${duration.hours} h` : ''; const m = duration.minutes ? `${duration.minutes} m` : ''; - const s = - duration.hours < 12 && duration.seconds ? `${duration.seconds} s` : ''; + const s = duration.hours < 12 ? `${duration.seconds ?? 0} s` : ''; return `${h} ${m} ${s}`; };