function findChildEvent()

in client/containers/workflow-history/components/workflow-graph/helpers/find-child-event.js [32:73]


function findChildEvent({ eventId, eventType }, workflowList) {
  const slicedWorkflowList = workflowList.slice(eventId);

  // We are at the end of the workflow, no children!
  if (!slicedWorkflowList.length) {
    return {};
  }

  if (slicedWorkflowList[0].eventType === 'DecisionTaskScheduled') {
    return {
      inferredChild: slicedWorkflowList[0].eventId,
    };
  }

  if (eventType === 'WorkflowExecutionSignaled') {
    for (const targetEvent of slicedWorkflowList) {
      switch (targetEvent.eventType) {
        case 'WorkflowExecutionSignaled':
        case 'WorkflowExecutionCancelRequested':
          break;
        case 'DecisionTaskScheduled':
          return {
            inferredChild: targetEvent.eventId,
          };
      }
    }
  } else {
    for (const targetEvent of slicedWorkflowList) {
      switch (targetEvent.eventType) {
        case 'WorkflowExecutionSignaled':
        case 'WorkflowExecutionCancelRequested':
          break;
        default:
          return {
            chronologicalChild: targetEvent.eventId,
          };
      }
    }
  }

  return {};
}