Skip to content

Commit

Permalink
chore(orchestrator): aligns the workflows table with the design (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilzi authored and caponetto committed Jan 16, 2024
1 parent b931fe4 commit 3accbc9
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 23 deletions.
9 changes: 3 additions & 6 deletions plugins/orchestrator-backend/src/service/SonataFlowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
fromWorkflowSource,
Job,
ProcessInstance,
ProcessInstanceStateValues,
WorkflowDefinition,
WorkflowExecutionResponse,
WorkflowInfo,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion plugins/orchestrator-common/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export enum ProcessInstanceState {
Error = 'ERROR',
}

export type ProcessInstanceStateValues = Uppercase<
keyof typeof ProcessInstanceState
>;

export enum MilestoneStatus {
Available = 'AVAILABLE',
Active = 'ACTIVE',
Expand Down Expand Up @@ -51,7 +55,7 @@ export interface ProcessInstance {
rootProcessInstanceId?: string;
rootProcessId?: string;
roles?: string[];
state: ProcessInstanceState;
state: ProcessInstanceStateValues;
endpoint: string;
serviceUrl?: string;
nodes: NodeInstance[];
Expand Down
4 changes: 3 additions & 1 deletion plugins/orchestrator-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = { [P in keyof T]: T[P] };

type OmitDistributive<T, K extends PropertyKey> = T extends any
Expand Down Expand Up @@ -70,7 +72,7 @@ export interface WorkflowOverview {
name?: string;
uri?: string;
lastTriggeredMs?: number;
lastRunStatus?: string;
lastRunStatus?: ProcessInstanceStateValues;
type?: string;
avgDurationMs?: number;
description?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 11 additions & 11 deletions plugins/orchestrator/src/__fixtures__/fakeWorkflowOverviewList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -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',
Expand All @@ -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',
},
Expand All @@ -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',
},
Expand All @@ -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',
},
Expand All @@ -74,7 +74,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [
lastTriggeredMs: 1701765793,
type: 'Infrastructure',
avgDurationMs: 5000,
lastRunStatus: 'Completed',
lastRunStatus: 'COMPLETED',
description: 'Workflow description',
},
{
Expand All @@ -84,7 +84,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [
lastTriggeredMs: 1701765793,
type: 'Infrastructure',
avgDurationMs: 5000,
lastRunStatus: 'Error',
lastRunStatus: 'ERROR',
description: 'YAML based greeting workflow',
},
{
Expand All @@ -94,7 +94,7 @@ export const fakeWorkflowOverviewList: WorkflowOverview[] = [
lastTriggeredMs: 1701765793,
type: 'Infrastructure',
avgDurationMs: 5000,
lastRunStatus: 'Suspended',
lastRunStatus: 'SUSPENDED',
description: '[WF] Jira issue',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const ProcessInstanceStatus = ({ status }: { status: string }) => {
<DotIcon className={`${styles.icon} ${colorStyle}`} />
);

// TODO(mlibra): Show progress, i.e.: (2/5)
return (
<div className={styles.root}>
{icon} {humanizeProcessInstanceState(status)}
Expand Down
8 changes: 7 additions & 1 deletion plugins/orchestrator/src/components/next/WorkflowsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
nextExecuteWorkflowRouteRef,
workflowDefinitionsRouteRef,
} from '../../routes';
import { ProcessInstanceStatus } from './ProcessInstanceStatus';

export interface WorkflowsTableProps {
items: WorkflowOverview[];
Expand Down Expand Up @@ -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 => (
<ProcessInstanceStatus status={rowData.lastRunStatus} />
),
},
{ title: 'Type', field: 'type' },
{ title: 'Avg. duration', field: 'avgDuration' },
{ title: 'Description', field: 'description' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3accbc9

Please sign in to comment.