From 37fcd06efdcb4c1751f286244c7d88b3ce5b48cf Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Fri, 4 Oct 2024 14:03:20 +0200 Subject: [PATCH] fix(orchestrator): improve error handling for incorrect nextWorkflow IDs (#2288) Improve error handling for incorrect nextWorkflow IDs Fixes: FLPATH-1748 --- .../components/WorkflowDescriptionModal.tsx | 51 +++++++++++++++---- .../src/components/WorkflowResult.tsx | 21 ++++---- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/plugins/orchestrator/src/components/WorkflowDescriptionModal.tsx b/plugins/orchestrator/src/components/WorkflowDescriptionModal.tsx index 0a84d7aea0..913fb19ba0 100644 --- a/plugins/orchestrator/src/components/WorkflowDescriptionModal.tsx +++ b/plugins/orchestrator/src/components/WorkflowDescriptionModal.tsx @@ -18,6 +18,10 @@ import { WorkflowOverviewDTO } from '@janus-idp/backstage-plugin-orchestrator-co export type WorkflowDescriptionModalProps = { workflow: WorkflowOverviewDTO; + workflowError?: { + itemId: string; + error: any; + }; runWorkflowLink: string; open: boolean; onClose?: () => void; @@ -37,7 +41,13 @@ export const RefForwardingWorkflowDescriptionModal: ForwardRefRenderFunction< ParentComponentRef, WorkflowDescriptionModalProps > = (props, forwardedRef): JSX.Element | null => { - const { workflow, open = false, onClose, runWorkflowLink } = props; + const { + workflow, + open = false, + onClose, + runWorkflowLink, + workflowError, + } = props; const classes = useStyles(); const navigate = useNavigate(); @@ -47,6 +57,27 @@ export const RefForwardingWorkflowDescriptionModal: ForwardRefRenderFunction< } }; + let content; + if (workflowError) { + content = ( + +

+ Failed to load details for the workflow ID: + {workflowError.itemId} +

+ {workflowError.error.message &&

{workflowError.error.message}

} +
+ ); + } else if (workflow.description) { + content = {workflow.description}; + } else { + content = ( + +

Are you sure you want to run this workflow?

+
+ ); + } + return ( onClose} @@ -67,17 +98,15 @@ export const RefForwardingWorkflowDescriptionModal: ForwardRefRenderFunction< - - {workflow.description ? ( - {workflow.description} - ) : ( - -

Are you sure you want to run this workflow?

-
- )} -
+ + {content} -