From ce6a0da6cb9fa3f70a6733af5cf4686745c49b35 Mon Sep 17 00:00:00 2001 From: Eric Nilsson Date: Mon, 5 Oct 2020 15:55:43 +0200 Subject: [PATCH 1/2] #2534 Refactored WorkflowRunStatus to account for the run's conclusion along with the status --- .../WorkflowRunDetails/WorkflowRunDetails.tsx | 10 ++++- .../WorkflowRunStatus/WorkflowRunStatus.tsx | 42 ++++++++++++++++--- .../WorkflowRunsTable/WorkflowRunsTable.tsx | 3 +- .../src/components/useWorkflowRuns.ts | 1 + 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx index fd2cc69376..7714ad6cb6 100644 --- a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx +++ b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx @@ -106,7 +106,10 @@ const StepView = ({ step }: { step: Step }) => { /> - + ); @@ -204,7 +207,10 @@ export const WorkflowRunDetails = ({ entity }: { entity: Entity }) => { Status - + diff --git a/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx b/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx index 089c319802..b1a71ea3ed 100644 --- a/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx +++ b/plugins/github-actions/src/components/WorkflowRunStatus/WorkflowRunStatus.tsx @@ -14,13 +14,22 @@ * limitations under the License. */ -import { StatusPending, StatusRunning, StatusOK } from '@backstage/core'; +import { + StatusPending, + StatusRunning, + StatusOK, + StatusWarning, + StatusAborted, + StatusError, +} from '@backstage/core'; import React from 'react'; export const WorkflowRunStatus = ({ status, + conclusion, }: { status: string | undefined; + conclusion: string | undefined; }) => { if (status === undefined) return null; switch (status.toLowerCase()) { @@ -37,11 +46,32 @@ export const WorkflowRunStatus = ({ ); case 'completed': - return ( - <> - Completed - - ); + switch (conclusion?.toLowerCase()) { + case 'skipped' || 'canceled': + return ( + <> + Aborted + + ); + case 'timed_out': + return ( + <> + Timed out + + ); + case 'failure': + return ( + <> + Error + + ); + default: + return ( + <> + Completed + + ); + } default: return ( <> diff --git a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx index 4e99be6926..fcde5fefbb 100644 --- a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx +++ b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx @@ -46,6 +46,7 @@ export type WorkflowRun = { }; }; status: string; + conclusion: string; onReRunClick: () => void; }; @@ -84,7 +85,7 @@ const generatedColumns: TableColumn[] = [ render: (row: Partial) => ( - + ), }, diff --git a/plugins/github-actions/src/components/useWorkflowRuns.ts b/plugins/github-actions/src/components/useWorkflowRuns.ts index 25ede3f997..d0be852beb 100644 --- a/plugins/github-actions/src/components/useWorkflowRuns.ts +++ b/plugins/github-actions/src/components/useWorkflowRuns.ts @@ -87,6 +87,7 @@ export function useWorkflowRuns({ }, }, status: run.status, + conclusion: run.conclusion, url: run.url, githubUrl: run.html_url, })); From 4906317b7ebdc665af368a6bfc09081541a21ffd Mon Sep 17 00:00:00 2001 From: Eric Nilsson Date: Mon, 5 Oct 2020 16:16:35 +0200 Subject: [PATCH 2/2] Added missing prop for workflowRunStatus in Cards.tsx --- plugins/github-actions/src/components/Cards/Cards.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/github-actions/src/components/Cards/Cards.tsx b/plugins/github-actions/src/components/Cards/Cards.tsx index 28783efdea..7e4d5f5fb6 100644 --- a/plugins/github-actions/src/components/Cards/Cards.tsx +++ b/plugins/github-actions/src/components/Cards/Cards.tsx @@ -60,7 +60,10 @@ const WidgetContent = ({ metadata={{ status: ( <> - + ), message: lastRun.message,