diff --git a/plugins/orchestrator-backend/src/service/SonataFlowService.ts b/plugins/orchestrator-backend/src/service/SonataFlowService.ts index 29209c3652..35acfc3379 100644 --- a/plugins/orchestrator-backend/src/service/SonataFlowService.ts +++ b/plugins/orchestrator-backend/src/service/SonataFlowService.ts @@ -10,6 +10,7 @@ import { fromWorkflowSource, Job, ProcessInstance, + ProcessInstanceStateValues, WorkflowDefinition, WorkflowExecutionResponse, WorkflowInfo, @@ -507,7 +508,7 @@ export class SonataFlowService { let offset: number = 0; let lastTriggered: Date = new Date(0); - let lastRunStatus = ''; + let lastRunStatus: ProcessInstanceStateValues | undefined; let counter = 0; let totalDuration = 0; @@ -552,11 +553,7 @@ export class SonataFlowService { name: definition.name, uri: await this.fetchWorkflowUri(workflowId), lastTriggeredMs: lastTriggered.getTime(), - lastRunStatus: - lastRunStatus.length > 0 - ? lastRunStatus.charAt(0).toUpperCase() + - lastRunStatus.slice(1).toLowerCase() - : undefined, + lastRunStatus, type: this.extractWorkflowType(definition), avgDurationMs: counter ? totalDuration / counter : undefined, description: definition.description, diff --git a/plugins/orchestrator-common/src/models.ts b/plugins/orchestrator-common/src/models.ts index 3adc19f17c..4d94e11462 100644 --- a/plugins/orchestrator-common/src/models.ts +++ b/plugins/orchestrator-common/src/models.ts @@ -6,6 +6,10 @@ export enum ProcessInstanceState { Error = 'ERROR', } +export type ProcessInstanceStateValues = Uppercase< + keyof typeof ProcessInstanceState +>; + export enum MilestoneStatus { Available = 'AVAILABLE', Active = 'ACTIVE', @@ -51,7 +55,7 @@ export interface ProcessInstance { rootProcessInstanceId?: string; rootProcessId?: string; roles?: string[]; - state: ProcessInstanceState; + state: ProcessInstanceStateValues; endpoint: string; serviceUrl?: string; nodes: NodeInstance[]; diff --git a/plugins/orchestrator-common/src/types.ts b/plugins/orchestrator-common/src/types.ts index 47144ecb2f..3e82f5a5cc 100644 --- a/plugins/orchestrator-common/src/types.ts +++ b/plugins/orchestrator-common/src/types.ts @@ -2,6 +2,8 @@ import { Specification } from '@severlessworkflow/sdk-typescript'; import { JSONSchema7 } from 'json-schema'; import { OpenAPIV3 } from 'openapi-types'; +import { ProcessInstanceStateValues } from './models'; + type Id = { [P in keyof T]: T[P] }; type OmitDistributive = T extends any @@ -70,7 +72,7 @@ export interface WorkflowOverview { name?: string; uri?: string; lastTriggeredMs?: number; - lastRunStatus?: string; + lastRunStatus?: ProcessInstanceStateValues; type?: string; avgDurationMs?: number; description?: string; diff --git a/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverview.ts b/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverview.ts index 57004697b3..0e2d5d269a 100644 --- a/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverview.ts +++ b/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverview.ts @@ -4,7 +4,7 @@ export const fakeWorkflowOverview: WorkflowOverview = { workflowId: 'quarkus-backend-workflow-ci-switch', name: '[WF] Create a starter Quarkus Backend application with a CI pipeline - CI Switch', lastTriggeredMs: 1697276096000, - lastRunStatus: 'Success', + lastRunStatus: 'COMPLETED', type: 'ci', avgDurationMs: 150000, description: diff --git a/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverviewList.ts b/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverviewList.ts index 72a3a4acd6..7d49ca1cf8 100644 --- a/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverviewList.ts +++ b/plugins/orchestrator/src/__fixtures__/fakeWorkflowOverviewList.ts @@ -8,7 +8,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Completed', + lastRunStatus: 'COMPLETED', description: '[WF] Create a starter Quarkus Backend application with a CI pipeline - CI Switch', }, @@ -19,20 +19,20 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Running', + lastRunStatus: 'ACTIVE', description: '[WF] Launch an Ansible Job within Ansible Automation Platform with Jira integration and Timeout', }, { workflowId: 'orchestrator-ansible-job-parallel-error-handler', - name: '[WF] Ansible Job - Parallel/Error', + name: '[WF] Ansible Job - Parallel/ERROR', uri: 'orchestrator-ansible-job-parallel-error-handler.sw.yaml', lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Suspended', + lastRunStatus: 'SUSPENDED', description: - '[WF] Launch an Ansible Job within Ansible Automation Platform - Error Handling', + '[WF] Launch an Ansible Job within Ansible Automation Platform - ERROR Handling', }, { workflowId: 'orchestrator-ansible-job-long', @@ -41,7 +41,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Suspended', + lastRunStatus: 'SUSPENDED', description: '[WF] Launch an Ansible Job within Ansible Automation Platform with Jira integration', }, @@ -52,7 +52,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Error', + lastRunStatus: 'ERROR', description: '[WF] Launch an Ansible Job within Ansible Automation Platform', }, @@ -63,7 +63,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Suspended', + lastRunStatus: 'SUSPENDED', description: '[WF] Create a starter Quarkus Backend application with a CI pipeline - Extended', }, @@ -74,7 +74,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Completed', + lastRunStatus: 'COMPLETED', description: 'Workflow description', }, { @@ -84,7 +84,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Error', + lastRunStatus: 'ERROR', description: 'YAML based greeting workflow', }, { @@ -94,7 +94,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [ lastTriggeredMs: 1701765793, type: 'Infrastructure', avgDurationMs: 5000, - lastRunStatus: 'Suspended', + lastRunStatus: 'SUSPENDED', description: '[WF] Jira issue', }, ]; diff --git a/plugins/orchestrator/src/components/next/ProcessInstanceStatus.tsx b/plugins/orchestrator/src/components/next/ProcessInstanceStatus.tsx index 31782cb18a..0a962cc29a 100644 --- a/plugins/orchestrator/src/components/next/ProcessInstanceStatus.tsx +++ b/plugins/orchestrator/src/components/next/ProcessInstanceStatus.tsx @@ -35,7 +35,6 @@ export const ProcessInstanceStatus = ({ status }: { status: string }) => { ); - // TODO(mlibra): Show progress, i.e.: (2/5) return (
{icon} {humanizeProcessInstanceState(status)} diff --git a/plugins/orchestrator/src/components/next/WorkflowsTable.tsx b/plugins/orchestrator/src/components/next/WorkflowsTable.tsx index 09b0118439..07328fecca 100644 --- a/plugins/orchestrator/src/components/next/WorkflowsTable.tsx +++ b/plugins/orchestrator/src/components/next/WorkflowsTable.tsx @@ -20,6 +20,7 @@ import { nextExecuteWorkflowRouteRef, workflowDefinitionsRouteRef, } from '../../routes'; +import { ProcessInstanceStatus } from './ProcessInstanceStatus'; export interface WorkflowsTableProps { items: WorkflowOverview[]; @@ -116,7 +117,12 @@ export const WorkflowsTable = ({ items }: WorkflowsTableProps) => { () => [ { title: 'Name', field: 'name' }, { title: 'Last run', field: 'lastTriggered' }, - { title: 'Last run status', field: 'lastRunStatus' }, + { + title: 'Last run status', + render: rowData => ( + + ), + }, { title: 'Type', field: 'type' }, { title: 'Avg. duration', field: 'avgDuration' }, { title: 'Description', field: 'description' }, diff --git a/plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.test.ts b/plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.test.ts index ac9bc75880..eea1141d90 100644 --- a/plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.test.ts +++ b/plugins/orchestrator/src/dataFormatters/WorkflowOverviewFormatter.test.ts @@ -11,7 +11,7 @@ describe('WorkflowOverviewAdapter', () => { workflowId: '123', name: 'Sample Workflow', lastTriggeredMs: 1697276096000, - lastRunStatus: 'Success', + lastRunStatus: 'COMPLETED', type: 'Sample Type', avgDurationMs: 150000, description: 'Sample description',