Skip to content

Commit 242f204

Browse files
Introduced isExecuteSyncStepType in @kbn/workflow
1 parent b586869 commit 242f204

6 files changed

Lines changed: 29 additions & 13 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export const WORKFLOW_EXECUTE_STEP_TYPE = 'workflow.execute' as const;
11+
export const WORKFLOW_EXECUTE_ASYNC_STEP_TYPE = 'workflow.executeAsync' as const;
12+
13+
export const isExecuteSyncStepType = (stepType: string | undefined): boolean =>
14+
stepType === WORKFLOW_EXECUTE_STEP_TYPE;
15+
16+
export const isExecuteAsyncStepType = (stepType: string | undefined): boolean =>
17+
stepType === WORKFLOW_EXECUTE_ASYNC_STEP_TYPE;
18+
19+
export const isExecuteStepType = (stepType: string | undefined): boolean =>
20+
isExecuteSyncStepType(stepType) || isExecuteAsyncStepType(stepType);

src/platform/packages/shared/kbn-workflows/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export * from './types/utils';
3939
export * from './common/constants';
4040
export * from './common/privileges';
4141
export * from './common/utils';
42+
export * from './common/step_types';
4243
export * from './common/elasticsearch_request_builder';
4344
export * from './common/kibana_request_builder';
4445
export * from './server/constants';

src/platform/plugins/shared/workflows_management/public/features/workflow_execution_detail/model/use_child_workflow_executions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
WorkflowExecutionDto,
1515
WorkflowStepExecutionDto,
1616
} from '@kbn/workflows';
17-
import { isTerminalStatus } from '@kbn/workflows';
17+
import { isExecuteSyncStepType, isTerminalStatus } from '@kbn/workflows';
1818
import { useKibana } from '../../../hooks/use_kibana';
1919

2020
export interface ChildWorkflowExecutionInfo {
@@ -28,8 +28,6 @@ export interface ChildWorkflowExecutionInfo {
2828

2929
export type ChildWorkflowExecutionsMap = Map<string, ChildWorkflowExecutionInfo>;
3030

31-
const WORKFLOW_EXECUTE_STEP_TYPE = 'workflow.execute';
32-
3331
export function useChildWorkflowExecutions(
3432
parentExecution: WorkflowExecutionDto | undefined | null
3533
): { childExecutions: ChildWorkflowExecutionsMap; isLoading: boolean } {
@@ -40,9 +38,7 @@ export function useChildWorkflowExecutions(
4038
const terminalChildKey = useMemo(() => {
4139
if (!parentExecution?.stepExecutions) return '';
4240
return parentExecution.stepExecutions
43-
.filter(
44-
(step) => step.stepType === WORKFLOW_EXECUTE_STEP_TYPE && isTerminalStatus(step.status)
45-
)
41+
.filter((step) => isExecuteSyncStepType(step.stepType) && isTerminalStatus(step.status))
4642
.map((step) => step.id)
4743
.join(',');
4844
}, [parentExecution?.stepExecutions]);

src/platform/plugins/shared/workflows_management/public/features/workflow_execution_detail/ui/build_step_executions_tree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
1212

1313
import type { StackFrame, WorkflowStepExecutionDto } from '@kbn/workflows';
14-
import { ExecutionStatus, isTerminalStatus } from '@kbn/workflows';
14+
import { ExecutionStatus, isExecuteSyncStepType, isTerminalStatus } from '@kbn/workflows';
1515
import type { ChildWorkflowExecutionsMap } from '../model/use_child_workflow_executions';
1616

1717
export interface StepListTreeItem {
@@ -223,7 +223,7 @@ export function injectChildWorkflowSteps(
223223
const childStepExecutions: WorkflowStepExecutionDto[] = [];
224224

225225
function processNode(node: StepExecutionTreeItem): StepExecutionTreeItem {
226-
const isWorkflowExecuteStep = node.stepType === 'workflow.execute' && node.stepExecutionId;
226+
const isWorkflowExecuteStep = isExecuteSyncStepType(node.stepType) && node.stepExecutionId;
227227

228228
if (!isWorkflowExecuteStep) {
229229
return {

src/platform/plugins/shared/workflows_management/public/features/workflow_execution_detail/ui/workflow_step_execution_details.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2525
import { i18n } from '@kbn/i18n';
2626
import { FormattedMessage } from '@kbn/i18n-react';
2727
import type { WorkflowStepExecutionDto } from '@kbn/workflows';
28-
import { isTerminalStatus } from '@kbn/workflows';
28+
import { isExecuteSyncStepType, isTerminalStatus } from '@kbn/workflows';
2929
import { StepExecutionDataView } from './step_execution_data_view';
3030
import { WorkflowExecutionOverview } from './workflow_execution_overview';
3131
import type { WorkflowExecutionLinkInfo } from '../../../hooks/navigation/use_navigate_to_execution';
@@ -78,7 +78,7 @@ export const WorkflowStepExecutionDetails = React.memo<WorkflowStepExecutionDeta
7878

7979
const isOverviewPseudoStep = stepExecution?.stepType === '__overview';
8080
const isTriggerPseudoStep = stepExecution?.stepType?.startsWith('trigger_');
81-
const isWorkflowExecuteStep = stepExecution?.stepType === 'workflow.execute';
81+
const isWorkflowExecuteStep = isExecuteSyncStepType(stepExecution?.stepType);
8282

8383
const handleWorkflowLinkClick = useCallback(
8484
(e: React.MouseEvent) => {

src/platform/plugins/shared/workflows_management/server/workflows_management/lib/get_child_workflow_executions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
EsWorkflowStepExecution,
1414
WorkflowStepExecutionDto,
1515
} from '@kbn/workflows';
16-
import { isTerminalStatus } from '@kbn/workflows';
16+
import { isExecuteSyncStepType, isTerminalStatus } from '@kbn/workflows';
1717
import { getStepExecutionsByWorkflowExecution } from '@kbn/workflows/server';
1818

1919
export interface ChildWorkflowExecutionItem {
@@ -38,7 +38,6 @@ interface ChildRef {
3838
childExecutionId: string;
3939
}
4040

41-
const WORKFLOW_EXECUTE_STEP_TYPE = 'workflow.execute';
4241
const STEP_SOURCE_EXCLUDES = ['input', 'output'];
4342
const PARENT_SOURCE_INCLUDES = ['spaceId', 'stepExecutionIds'];
4443
const CHILD_SOURCE_INCLUDES = [
@@ -53,7 +52,7 @@ const extractChildRefs = (steps: EsWorkflowStepExecution[]): ChildRef[] =>
5352
steps
5453
.filter(
5554
(step) =>
56-
step.stepType === WORKFLOW_EXECUTE_STEP_TYPE &&
55+
isExecuteSyncStepType(step.stepType) &&
5756
isTerminalStatus(step.status) &&
5857
typeof step.state?.executionId === 'string'
5958
)

0 commit comments

Comments
 (0)