Skip to content

Commit 2e86ef2

Browse files
committed
WIP event sub processes
1 parent 14147a4 commit 2e86ef2

File tree

4 files changed

+74
-27
lines changed

4 files changed

+74
-27
lines changed

lib/TaskExecution.js

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export default class TaskExecution extends EventEmitter {
160160

161161

162162
const waitingItems = buildWaitingItems(jobsResult, userTasksResult, messageSubscriptionsResult, elementInstancesResult);
163+
enrichEventSubProcessChildren(waitingItems, elementInstancesResult, this._elementRegistry);
163164

164165
if (waitingItems.length) {
165166

@@ -552,14 +553,14 @@ export function buildWaitingItems(jobsResult, userTasksResult, messageSubscripti
552553
}
553554
}
554555

555-
// Add boundary events as waiting items
556+
// Add boundary events and event sub-processes as waiting items
556557
if (elementInstancesResult.success) {
557558
for (const element of (elementInstancesResult.response.items || [])) {
558-
if (element.type !== 'BOUNDARY_EVENT') {
559-
continue;
559+
if (element.type === 'BOUNDARY_EVENT') {
560+
items.push({ type: 'boundary-event', data: element });
561+
} else if (element.type === 'EVENT_SUB_PROCESS') {
562+
items.push({ type: 'event-sub-process', data: element });
560563
}
561-
562-
items.push({ type: 'boundary-event', data: element });
563564
}
564565
}
565566

@@ -578,7 +579,7 @@ export function buildWaitingItems(jobsResult, userTasksResult, messageSubscripti
578579
function getItemTimestamp(item) {
579580
const data = item.data || {};
580581

581-
if (item.type === 'boundary-event') {
582+
if (item.type === 'boundary-event' || item.type === 'event-sub-process') {
582583
return data.startDate ? new Date(data.startDate).getTime() : 0;
583584
}
584585

@@ -670,6 +671,47 @@ export function buildChildElements(elementInstancesResult, elementId, childEleme
670671
* @param {import('./types').ApiResponse<import('@camunda8/sdk/dist/c8/lib/C8Dto').SearchVariablesResponse>} [variablesResult]
671672
* @returns {import('./types').ChildElement[]}
672673
*/
674+
/**
675+
* Enrich event sub-process waiting items with their child element instances.
676+
*
677+
* @param {import('./types').WaitingItem[]} waitingItems
678+
* @param {import('./types').ApiResponse<import('@camunda8/sdk/dist/c8/lib/C8Dto').SearchElementInstancesResponse>} elementInstancesResult
679+
* @param {Object} elementRegistry
680+
*/
681+
function enrichEventSubProcessChildren(waitingItems, elementInstancesResult, elementRegistry) {
682+
if (!elementInstancesResult.success) {
683+
return;
684+
}
685+
686+
const allInstances = elementInstancesResult.response.items || [];
687+
688+
for (const item of waitingItems) {
689+
if (item.type !== 'event-sub-process') {
690+
continue;
691+
}
692+
693+
const espId = item.data.elementId;
694+
const childIds = getChildElementIds(elementRegistry, espId);
695+
696+
if (!childIds.size) {
697+
continue;
698+
}
699+
700+
item.children = allInstances
701+
.filter(el => childIds.has(el.elementId))
702+
.map(el => ({
703+
elementId: el.elementId,
704+
elementName: el.elementName,
705+
type: el.type,
706+
state: el.state,
707+
startDate: el.startDate,
708+
endDate: el.endDate,
709+
hasIncident: el.hasIncident
710+
}))
711+
.sort((a, b) => new Date(a.startDate).getTime() - new Date(b.startDate).getTime());
712+
}
713+
}
714+
673715
function enrichChildrenWithVariables(children, elementInstancesResult, variablesResult) {
674716
if (!variablesResult?.success || !elementInstancesResult.success) {
675717
return children;

lib/components/Output/ExecutionLog.jsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const WAITING_ITEM_LABELS = {
2727
'job-inactive': 'Job waiting to be activated',
2828
'user-task-form': 'User task waiting for completion',
2929
'message-subscription': 'Waiting for message',
30-
'boundary-event': 'Boundary event triggered'
30+
'boundary-event': 'Boundary event triggered',
31+
'event-sub-process': 'Event sub-process triggered'
3132
};
3233

3334
const WAITING_ITEM_FINISHED_LABELS = {
@@ -60,8 +61,8 @@ function getWaitingItemDetails(item) {
6061
return [];
6162
}
6263

63-
// Handle boundary events
64-
if (item.type === 'boundary-event') {
64+
// Handle boundary events and event sub-processes
65+
if (item.type === 'boundary-event' || item.type === 'event-sub-process') {
6566
const details = [];
6667

6768
if (item.data.elementId) {
@@ -193,8 +194,8 @@ function getWaitingItemBadges(item) {
193194
badges.push({ text: item.data.type });
194195
}
195196

196-
// Boundary event badge - show element name or ID
197-
if (item.type === 'boundary-event' && item.data) {
197+
// Boundary event or event sub-process badge - show element name or ID
198+
if ((item.type === 'boundary-event' || item.type === 'event-sub-process') && item.data) {
198199
const label = item.data.elementName || item.data.elementId;
199200
if (label) badges.push({ text: label });
200201
}
@@ -415,7 +416,9 @@ function WaitingItem({ item, timestamp, isLast, isFinished, onSelectElement }) {
415416
const badges = getWaitingItemBadges(item);
416417

417418
const isBoundaryEvent = item.type === 'boundary-event';
418-
const isClickable = isBoundaryEvent && onSelectElement && item.data?.elementId;
419+
const isEventSubProcess = item.type === 'event-sub-process';
420+
const isClickable = (isBoundaryEvent || isEventSubProcess) && onSelectElement && item.data?.elementId;
421+
const hasChildren = isEventSubProcess && item.children?.length > 0;
419422

420423
const isPending = !isFinished && isPendingItem(item);
421424

@@ -428,8 +431,10 @@ function WaitingItem({ item, timestamp, isLast, isFinished, onSelectElement }) {
428431
? <ChevronDown size={ 14 } />
429432
: <ChevronRight size={ 14 } />;
430433

434+
const isExpandable = hasDetails || hasChildren;
435+
431436
const handleExpandToggle = () => {
432-
if (hasDetails) {
437+
if (isExpandable) {
433438
setExpanded(!expanded);
434439
}
435440
};
@@ -443,17 +448,17 @@ function WaitingItem({ item, timestamp, isLast, isFinished, onSelectElement }) {
443448

444449
const entryClass = [
445450
'execution-log__entry',
446-
hasDetails ? 'execution-log__entry--expandable' : ''
451+
isExpandable ? 'execution-log__entry--expandable' : ''
447452
].filter(Boolean).join(' ');
448453

449454
return (
450455
<li className={ `execution-log__entry-wrapper${isPending ? ' execution-log__entry-wrapper--active' : ''}` }>
451456
<span className={ dotClass } />
452457
<div
453458
className={ entryClass }
454-
onClick={ hasDetails ? handleExpandToggle : undefined }
459+
onClick={ isExpandable ? handleExpandToggle : undefined }
455460
>
456-
{ hasDetails && <span className="execution-log__toggle">{ toggleIcon }</span> }
461+
{ isExpandable && <span className="execution-log__toggle">{ toggleIcon }</span> }
457462
<span className="execution-log__label">{ label }</span>
458463
{ badges.map((badge, i) => {
459464
const badgeClass = [
@@ -485,6 +490,13 @@ function WaitingItem({ item, timestamp, isLast, isFinished, onSelectElement }) {
485490
)) }
486491
</dl>
487492
) }
493+
{ isEventSubProcess && item.children?.length > 0 && (
494+
<ol className="execution-log__children-list">
495+
{ item.children.map((child, i) => (
496+
<ChildElement key={ i } child={ child } />
497+
)) }
498+
</ol>
499+
) }
488500
</li>
489501
);
490502
}

lib/style/style.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,6 @@
549549
.execution-log__child-item {
550550
position: relative;
551551
padding: 3px 0;
552-
553-
.execution-log__dot {
554-
width: 6px;
555-
height: 6px;
556-
left: -13px;
557-
top: 9px;
558-
}
559-
560-
.execution-log__entry {
561-
font-size: 13px;
562-
}
563552
}
564553

565554
.execution-log__child-variables {

lib/types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ export type WaitingItem =
8686
| {
8787
type: 'boundary-event';
8888
data: any;
89+
}
90+
| {
91+
type: 'event-sub-process';
92+
data: any;
8993
};
9094

9195
export type WaitingState = {

0 commit comments

Comments
 (0)