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} - + Run workflow diff --git a/plugins/orchestrator/src/components/WorkflowResult.tsx b/plugins/orchestrator/src/components/WorkflowResult.tsx index 037ef46b1e..01e18e89fe 100644 --- a/plugins/orchestrator/src/components/WorkflowResult.tsx +++ b/plugins/orchestrator/src/components/WorkflowResult.tsx @@ -27,7 +27,10 @@ import { orchestratorApiRef } from '../api'; import { VALUE_UNAVAILABLE } from '../constants'; import { executeWorkflowRouteRef } from '../routes'; import { buildUrl } from '../utils/UrlUtils'; -import { WorkflowDescriptionModal } from './WorkflowDescriptionModal'; +import { + WorkflowDescriptionModal, + WorkflowDescriptionModalProps, +} from './WorkflowDescriptionModal'; const useStyles = makeStyles(theme => ({ outputGrid: { @@ -126,6 +129,8 @@ const NextWorkflows = ({ const [currentWorkflow, setCurrentWorkflow] = React.useState( {} as WorkflowOverviewDTO, ); + const [workflowError, setWorkflowError] = + React.useState(); const runWorkflowLink = React.useMemo( () => @@ -145,16 +150,11 @@ const NextWorkflows = ({ if (itemId) { orchestratorApi .getWorkflowOverview(itemId) - .then( - workflow => { - setCurrentWorkflow(workflow.data); - }, - error => { - throw new Error(error); - }, - ) + .then(workflow => { + setCurrentWorkflow(workflow.data); + }) .catch(error => { - throw new Error(error); + setWorkflowError({ itemId, error }); }); setCurrentOpenedWorkflowDescriptionModalID(itemId); } @@ -197,6 +197,7 @@ const NextWorkflows = ({
+ Failed to load details for the workflow ID: + {workflowError.itemId} +
{workflowError.error.message}
Are you sure you want to run this workflow?