Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add task listeners for Zeebe #1088

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to [bpmn-js-properties-panel](https://github.com/bpmn-io/bpm

___Note:__ Yet to be released changes appear here._

* `FEAT`: support Zeebe task listeners ([#1088](https://github.com/bpmn-io/bpmn-js-properties-panel/pull/1088))
* `DEPS`: update to `[email protected]`
* `DEPS`: update to `[email protected]`

## 5.26.0

* `FEAT`: make FEEL popup links configurable ([#1083](https://github.com/bpmn-io/bpmn-js-properties-panel/pull/1083))
Expand Down
32 changes: 17 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"bpmn-js": "^17.11.1",
"bpmn-js-create-append-anything": "^0.5.2",
"bpmn-moddle": "^9.0.1",
"camunda-bpmn-js-behaviors": "^1.6.1",
"camunda-bpmn-js-behaviors": "^1.7.0",
"camunda-bpmn-moddle": "^7.0.1",
"chai": "^4.5.0",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -105,7 +105,7 @@
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"webpack": "^5.95.0",
"zeebe-bpmn-moddle": "^1.6.0"
"zeebe-bpmn-moddle": "^1.7.0"
},
"peerDependencies": {
"@bpmn-io/properties-panel": ">= 3.7",
Expand Down
18 changes: 18 additions & 0 deletions src/provider/zeebe/ZeebePropertiesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
SignalProps,
TargetProps,
TaskDefinitionProps,
TaskListenersProps,
TaskScheduleProps,
TimerProps,
UserTaskImplementationProps,
Expand Down Expand Up @@ -56,6 +57,7 @@ const ZEEBE_GROUPS = [
OutputPropagationGroup,
OutputGroup,
HeaderGroup,
TaskListenersGroup,
ExecutionListenersGroup,
ExtensionPropertiesGroup
];
Expand Down Expand Up @@ -323,6 +325,22 @@ function ExecutionListenersGroup(element, injector) {
return null;
}

function TaskListenersGroup(element, injector) {
const translate = injector.get('translate');
const group = {
label: translate('Task listeners'),
id: 'Zeebe__TaskListeners',
component: ListGroup,
...TaskListenersProps({ element, injector })
};

if (group.items) {
return group;
}

return null;
}

function ExtensionPropertiesGroup(element, injector) {
const translate = injector.get('translate');
const group = {
Expand Down
66 changes: 1 addition & 65 deletions src/provider/zeebe/properties/ExecutionListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getErrorEventDefinition
} from '../../../utils/EventDefinitionUtil';

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


export const EVENT_TO_LABEL = {
Expand Down Expand Up @@ -95,70 +95,6 @@ function EventType(props) {
});
}

function ListenerType(props) {
const {
idPrefix,
element,
listener
} = props;

const modeling = useService('modeling');
const translate = useService('translate');
const debounce = useService('debounceInput');

const setValue = (value) => {
modeling.updateModdleProperties(element, listener, {
type: value
});
};

const getValue = () => {
return listener.get('type');
};

return FeelEntryWithVariableContext({
element,
id: idPrefix + '-listenerType',
label: translate('Listener type'),
getValue,
setValue,
debounce,
feel: 'optional'
});
}

function Retries(props) {
const {
idPrefix,
element,
listener
} = props;

const modeling = useService('modeling');
const translate = useService('translate');
const debounce = useService('debounceInput');

const setValue = (value) => {
modeling.updateModdleProperties(element, listener, {
retries: value
});
};

const getValue = () => {
return listener.get('retries');
};

return FeelEntryWithVariableContext({
element,
id: idPrefix + '-retries',
label: translate('Retries'),
getValue,
setValue,
debounce,
feel: 'optional'
});
}

export function getEventTypes(element) {
if (isAny(element, [ 'bpmn:BoundaryEvent', 'bpmn:StartEvent' ])) {
return [ 'end' ];
Expand Down
84 changes: 84 additions & 0 deletions src/provider/zeebe/properties/TaskListener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { SelectEntry } from '@bpmn-io/properties-panel';

import {
useService
} from '../../../hooks';

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

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

export const EVENT_TO_LABEL = {
complete: 'Complete',
assignment: 'Assignment'
};

export function TaskListenerEntries(props) {

const {
idPrefix,
listener
} = props;

return [
{
id: idPrefix + '-eventType',
component: EventType,
idPrefix,
listener,
eventTypes: EVENT_TYPE
},
{
id: idPrefix + '-listenerType',
component: ListenerType,
idPrefix,
listener
},
{
id: idPrefix + '-retries',
component: Retries,
idPrefix,
listener
}
];
}

function EventType(props) {
const {
idPrefix,
element,
listener,
eventTypes
} = props;

const modeling = useService('modeling');
const translate = useService('translate');

const getOptions = () => {
return eventTypes.map(eventType => ({
value: eventType,
label: translate(EVENT_TO_LABEL[eventType])
}));
};

const setValue = (value) => {
modeling.updateModdleProperties(element, listener, {
eventType: value
});
};

const getValue = () => {
return listener.get('eventType');
};

return SelectEntry({
element,
id: idPrefix + '-eventType',
label: translate('Event type'),
getValue,
setValue,
getOptions
});
}


Loading