diff --git a/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx b/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx index 4be4722cd4..f5d1c223ba 100644 --- a/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx +++ b/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx @@ -24,59 +24,74 @@ import { StatusError, } from '@backstage/core-components'; -export const WorkflowRunStatus = ({ +export const WorkflowRunStatus = (props: { + status?: string; + conclusion?: string; +}) => { + return ( + <> + + {getStatusDescription(props)} + + ); +}; + +export function WorkflowIcon({ status, conclusion, }: { status?: string; conclusion?: string; -}) => { +}) { if (status === undefined) return null; switch (status.toLocaleLowerCase('en-US')) { case 'queued': - return ( - <> - Queued - - ); + return ; + case 'in_progress': - return ( - <> - In progress - - ); + return ; case 'completed': switch (conclusion?.toLocaleLowerCase('en-US')) { case 'skipped' || 'canceled': - return ( - <> - Aborted - - ); + return ; + case 'timed_out': - return ( - <> - Timed out - - ); + return ; case 'failure': - return ( - <> - Error - - ); + return ; default: - return ( - <> - Completed - - ); + return ; } default: - return ( - <> - Pending - - ); + return ; } -}; +} + +export function getStatusDescription({ + status, + conclusion, +}: { + status?: string; + conclusion?: string; +}) { + if (status === undefined) return ''; + switch (status.toLocaleLowerCase('en-US')) { + case 'queued': + return 'Queued'; + case 'in_progress': + return 'In progress'; + case 'completed': + switch (conclusion?.toLocaleLowerCase('en-US')) { + case 'skipped' || 'canceled': + return 'Aborted'; + case 'timed_out': + return 'Timed out'; + case 'failure': + return 'Error'; + default: + return 'Completed'; + } + default: + return 'Pending'; + } +} diff --git a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx index 8471a5d7d6..bc4196957d 100644 --- a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx +++ b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx @@ -39,8 +39,9 @@ import { } from '@backstage/core-components'; import { useRouteRef } from '@backstage/core-plugin-api'; import { getHostnameFromEntity } from '../getHostnameFromEntity'; +import { getStatusDescription } from '../WorkflowRunStatus/WorkflowRunStatus'; -const generatedColumns: TableColumn[] = [ +const generatedColumns: TableColumn>[] = [ { title: 'ID', field: 'id', @@ -51,7 +52,7 @@ const generatedColumns: TableColumn[] = [ title: 'Message', field: 'message', highlight: true, - render: (row: Partial) => { + render: row => { const LinkWrapper = () => { const routeLink = useRouteRef(buildRouteRef); return ( @@ -66,7 +67,7 @@ const generatedColumns: TableColumn[] = [ }, { title: 'Source', - render: (row: Partial) => ( + render: row => ( {row.source?.branchName} @@ -83,9 +84,10 @@ const generatedColumns: TableColumn[] = [ }, { title: 'Status', - width: '150px', - - render: (row: Partial) => ( + customSort: (d1, d2) => { + return getStatusDescription(d1).localeCompare(getStatusDescription(d2)); + }, + render: row => (