Skip to content

Commit

Permalink
feat: rename task listener event types
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Dec 13, 2024
1 parent 9d07650 commit b250a19
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/provider/zeebe/properties/TaskListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {

import { ListenerType, Retries } from './shared/Listener';

export const EVENT_TYPE = [ 'complete', 'assignment' ];
export const EVENT_TYPE = [ 'completing', 'assigning' ];

export const EVENT_TO_LABEL = {
complete: 'Complete',
assignment: 'Assignment'
completing: 'Completing',
assigning: 'Assigning'
};

export function TaskListenerEntries(props) {
Expand Down
7 changes: 6 additions & 1 deletion src/provider/zeebe/properties/TaskListenersProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ export function TaskListenersProps({ element, injector }) {
const items = listeners.map((listener, index) => {
const id = element.id + '-taskListener-' + index;
const type = listener.get('type') || '<no type>';
const eventType = listener.get('eventType');
const label = translate('{eventType}: {type}', {
eventType: EVENT_TO_LABEL[eventType] || eventType,
type
});

return {
id,
label: translate(`${EVENT_TO_LABEL[listener.get('eventType')]}: {type}`, { type }),
label,
entries: TaskListenerEntries({
idPrefix: id,
listener
Expand Down
19 changes: 13 additions & 6 deletions test/spec/provider/zeebe/TaskListenerProps.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<bpmn:userTask id="UserTask">
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="assignment" retries="2" type="assign_listener" />
<zeebe:taskListener eventType="assigning" retries="2" type="assign_listener" />
</zeebe:taskListeners>
<zeebe:userTask />
</bpmn:extensionElements>
Expand All @@ -28,11 +28,6 @@
</bpmn:userTask>
<bpmn:boundaryEvent id="CompensationBoundaryEvent" attachedToRef="SubProcess">
<bpmn:compensateEventDefinition id="Compensate" />
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="assignment" retries="4" type="assign_listener" />
</zeebe:taskListeners>
</bpmn:extensionElements>
</bpmn:boundaryEvent>
<bpmn:exclusiveGateway id="Gateway">
<bpmn:extensionElements>
Expand All @@ -47,12 +42,24 @@
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:subProcess>
<bpmn:userTask id="UserTaskLegacyEventTypes">
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="assignment" retries="2" type="assign_listener_legacy" />
<zeebe:taskListener eventType="complete" retries="2" type="complete_listener_legacy" />
</zeebe:taskListeners>
<zeebe:userTask />
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ZeebePropertiesTest">
<bpmndi:BPMNShape id="UserTask_di" bpmnElement="UserTask">
<dc:Bounds x="160" y="400" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTaskLegacyEventTypes_di" bpmnElement="UserTaskLegacyEventTypes">
<dc:Bounds x="160" y="200" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_di" bpmnElement="SubProcess" isExpanded="true">
<dc:Bounds x="160" y="510" width="350" height="200" />
</bpmndi:BPMNShape>
Expand Down
30 changes: 24 additions & 6 deletions test/spec/provider/zeebe/TaskListenerProps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,25 @@ describe('provider/zeebe - TaskListenerProps', function() {
const label = domQuery('.bio-properties-panel-collapsible-entry-header-title', group);

// then
expect(label).to.have.property('textContent', 'Assignment: assign_listener');
expect(label).to.have.property('textContent', 'Assigning: assign_listener');
}));


it('should display label with exact value for unknown event type', inject(async function(elementRegistry, selection) {

// given
const element = elementRegistry.get('UserTaskLegacyEventTypes');

await act(() => {
selection.select(element);
});

// when
const group = getTaskListenersGroup(container);
const label = domQuery('.bio-properties-panel-collapsible-entry-header-title', group);

// then
expect(label).to.have.property('textContent', 'assignment: assign_listener_legacy');
}));


Expand Down Expand Up @@ -270,7 +288,7 @@ describe('provider/zeebe - TaskListenerProps', function() {
const listeners = getListeners(element);
const newListener = listeners[listeners.length - 1];

expect(newListener).to.have.property('eventType', 'complete');
expect(newListener).to.have.property('eventType', 'completing');
})
);

Expand All @@ -289,13 +307,13 @@ describe('provider/zeebe - TaskListenerProps', function() {
const input = domQuery('select', eventType);

// when
changeInput(input, 'complete');
changeInput(input, 'completing');

// then
const listeners = getListeners(element);
const listener = listeners[0];

expect(listener).to.have.property('eventType', 'complete');
expect(listener).to.have.property('eventType', 'completing');
}));


Expand All @@ -309,15 +327,15 @@ describe('provider/zeebe - TaskListenerProps', function() {
const group = getTaskListenersGroup(container);
const eventType = getEventType(group);
const input = domQuery('select', eventType);
changeInput(input, 'complete');
changeInput(input, 'completing');

// when
await act(() => {
commandStack.undo();
});

// then
expect(input).to.have.property('value', 'assignment');
expect(input).to.have.property('value', 'assigning');
}));
});

Expand Down

0 comments on commit b250a19

Please sign in to comment.