From 652d1ad5108dea61fe59a6acac69f8b606e30c4a Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Fri, 8 Oct 2021 14:03:16 -0500 Subject: [PATCH] Combined the Status and Result columns into a single State Signed-off-by: Andre Wanlin --- .../src/components/BuildTable/BuildTable.tsx | 100 +++++++++++++----- 1 file changed, 72 insertions(+), 28 deletions(-) diff --git a/plugins/azure-devops/src/components/BuildTable/BuildTable.tsx b/plugins/azure-devops/src/components/BuildTable/BuildTable.tsx index b3d239d914..a6cfb9bf81 100644 --- a/plugins/azure-devops/src/components/BuildTable/BuildTable.tsx +++ b/plugins/azure-devops/src/components/BuildTable/BuildTable.tsx @@ -23,6 +23,8 @@ import { StatusOK, StatusWarning, StatusAborted, + StatusRunning, + StatusPending, } from '@backstage/core-components'; import { Link, Box, Typography } from '@material-ui/core'; import Alert from '@material-ui/lab/Alert'; @@ -32,22 +34,80 @@ import { BuildStatus, } from 'azure-devops-node-api/interfaces/BuildInterfaces'; -const getBuildResultComponent = ( - result: number | undefined = BuildResult.None, -) => { +const getBuildResultComponent = (result: number | undefined) => { switch (result) { - case BuildResult.None: - return ; case BuildResult.Succeeded: - return ; + return ( + + Succeeded{' '} + + ); case BuildResult.PartiallySucceeded: - return ; + return ( + + Partially Succeeded{' '} + + ); case BuildResult.Failed: - return ; + return ( + + Failed{' '} + + ); case BuildResult.Canceled: - return ; + return ( + + Canceled{' '} + + ); + case BuildResult.None: default: - return ; + return ( + + Unknown + + ); + } +}; + +const getBuildStateComponent = ( + status: number | undefined, + result: number | undefined, +) => { + switch (status) { + case BuildStatus.InProgress: + return ( + + In Progress + + ); + case BuildStatus.Completed: + return getBuildResultComponent(result); + case BuildStatus.Cancelling: + return ( + + Cancelling + + ); + case BuildStatus.Postponed: + return ( + + Postponed + + ); + case BuildStatus.NotStarted: + return ( + + Not Started + + ); + case BuildStatus.None: + default: + return ( + + Unknown + + ); } }; @@ -74,28 +134,12 @@ const columns: TableColumn[] = [ width: 'auto', }, { - title: 'Status', - field: 'status', + title: 'State', width: 'auto', render: (row: Partial) => ( - - {BuildStatus[row.status || BuildStatus.None]} - - - ), - }, - { - title: 'Result', - field: 'result', - width: 'auto', - render: (row: Partial) => ( - - {getBuildResultComponent(row.result)} - - - {BuildResult[row.result || BuildResult.None]} + {getBuildStateComponent(row.status, row.result)} ),