Skip to content

Commit 86d8c39

Browse files
Skaiirnikku
authored andcommitted
fix: only show priority assignment in zeebe:userTask
Closes #21772
1 parent 1b23597 commit 86d8c39

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

src/provider/zeebe/properties/PriorityDefinitionProps.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function PriorityDefinitionProps(props) {
2525
element
2626
} = props;
2727

28-
if (!is(element, 'bpmn:UserTask')) {
28+
if (!isZeebeUserTask(element)) {
2929
return [];
3030
}
3131

@@ -59,32 +59,13 @@ function Priority(props) {
5959

6060
let extensionElements = businessObject.get('extensionElements');
6161

62-
// (1) ensure extension elements
63-
if (!extensionElements) {
64-
extensionElements = createElement(
65-
'bpmn:ExtensionElements',
66-
{ values: [] },
67-
businessObject,
68-
bpmnFactory
69-
);
70-
71-
commands.push({
72-
cmd: 'element.updateModdleProperties',
73-
context: {
74-
element,
75-
moddleElement: businessObject,
76-
properties: { extensionElements }
77-
}
78-
});
79-
}
80-
81-
// (2) ensure PriorityDefinition
62+
// (1) ensure PriorityDefinition
8263
let priorityDefinition = getPriorityDefinition(element);
8364
const isNullValue = value === null || value === '' || value === undefined;
8465

8566
if (priorityDefinition && isNullValue) {
8667

87-
// (3a) remove priority definition if it exists and priority is set to null
68+
// (2a) remove priority definition if it exists and priority is set to null
8869
commands.push({
8970
cmd: 'element.updateModdleProperties',
9071
context: {
@@ -98,7 +79,7 @@ function Priority(props) {
9879

9980
} else if (priorityDefinition && !isNullValue) {
10081

101-
// (3b) update priority definition if it already exists
82+
// (2b) update priority definition if it already exists
10283
commands.push({
10384
cmd: 'element.updateModdleProperties',
10485
context: {
@@ -110,7 +91,7 @@ function Priority(props) {
11091

11192
} else if (!priorityDefinition && !isNullValue) {
11293

113-
// (3c) create priority definition if it does not exist
94+
// (2c) create priority definition if it does not exist
11495
priorityDefinition = createElement(
11596
'zeebe:PriorityDefinition',
11697
{ priority: value },
@@ -130,7 +111,7 @@ function Priority(props) {
130111
});
131112
}
132113

133-
// (4) commit all updates
114+
// (3) commit all updates
134115
commandStack.execute('properties-panel.multi-command-executor', commands);
135116
};
136117

@@ -153,3 +134,9 @@ export function getPriorityDefinition(element) {
153134

154135
return getExtensionElementsList(businessObject, 'zeebe:PriorityDefinition')[0];
155136
}
137+
138+
function isZeebeUserTask(element) {
139+
const businessObject = getBusinessObject(element);
140+
141+
return is(element, 'bpmn:UserTask') && !!getExtensionElementsList(businessObject, 'zeebe:UserTask')[0];
142+
}

test/spec/provider/zeebe/PriorityDefinitionProps.bpmn

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@
22
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0sp2msp" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
33
<bpmn:process id="Process_08jq0zy" isExecutable="true">
44
<bpmn:serviceTask id="ServiceTask_1" name="ServiceTask_1" />
5+
<bpmn:userTask id="UserTask_0" name="UserTask_0" />
56
<bpmn:userTask id="UserTask_1" name="UserTask_1">
67
<bpmn:extensionElements>
7-
<zeebe:PriorityDefinition priority="=myPriorityValue" />
8+
<zeebe:userTask />
9+
<zeebe:priorityDefinition priority="=myPriorityValue" />
10+
</bpmn:extensionElements>
11+
</bpmn:userTask>
12+
<bpmn:userTask id="UserTask_2" name="UserTask_2">
13+
<bpmn:extensionElements>
14+
<zeebe:userTask />
815
</bpmn:extensionElements>
916
</bpmn:userTask>
10-
<bpmn:userTask id="UserTask_2" name="UserTask_2" />
1117
<bpmn:userTask id="UserTask_3" name="UserTask_3">
1218
<bpmn:extensionElements>
19+
<zeebe:userTask />
1320
<zeebe:assignmentDefinition assignee="foo" />
1421
</bpmn:extensionElements>
1522
</bpmn:userTask>
1623
<bpmn:userTask id="UserTask_4" name="UserTask_4">
1724
<bpmn:extensionElements>
18-
<zeebe:PriorityDefinition priority="=myPriorityValue" />
25+
<zeebe:userTask />
26+
<zeebe:priorityDefinition priority="=myPriorityValue" />
1927
</bpmn:extensionElements>
2028
</bpmn:userTask>
2129
</bpmn:process>

test/spec/provider/zeebe/PriorityDefinitionProps.spec.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import zeebeModdleExtensions from 'zeebe-bpmn-moddle/resources/zeebe';
3434

3535
import diagramXML from './PriorityDefinitionProps.bpmn';
3636
import { setEditorValue } from '../../../TestHelper';
37+
import { getExtensionElementsList } from '../../../../src/utils/ExtensionElementsUtil';
3738

3839

3940
describe('provider/zeebe - PriorityDefinitionProps', function() {
@@ -83,6 +84,23 @@ describe('provider/zeebe - PriorityDefinitionProps', function() {
8384
}));
8485

8586

87+
it('should NOT display for user task without zeebe:UserTask', inject(async function(elementRegistry, selection) {
88+
89+
// given
90+
const userTask = elementRegistry.get('UserTask_0');
91+
92+
await act(() => {
93+
selection.select(userTask);
94+
});
95+
96+
// when
97+
const priorityInput = domQuery('input[name=priorityDefinitionPriority]', container);
98+
99+
// then
100+
expect(priorityInput).to.not.exist;
101+
}));
102+
103+
86104
it('should display for user task', inject(async function(elementRegistry, selection) {
87105

88106
// given
@@ -153,14 +171,14 @@ describe('provider/zeebe - PriorityDefinitionProps', function() {
153171
);
154172

155173

156-
it('should create non-existing extension elements and priority definition',
174+
it('should create priority definition',
157175
inject(async function(elementRegistry, selection) {
158176

159177
// given
160178
const userTask = elementRegistry.get('UserTask_2');
161179

162180
// assume
163-
expect(getBusinessObject(userTask).get('extensionElements')).to.not.exist;
181+
expect(getExtensionElementsList(getBusinessObject(userTask), 'zeebe:priorityDefinition')).to.be.empty;
164182

165183
await act(() => {
166184
selection.select(userTask);
@@ -171,7 +189,8 @@ describe('provider/zeebe - PriorityDefinitionProps', function() {
171189
changeInput(priorityInput, 'newValue');
172190

173191
// then
174-
expect(getBusinessObject(userTask).get('extensionElements')).to.exist;
192+
const priorityDefinitionElement = getExtensionElementsList(getBusinessObject(userTask), 'zeebe:PriorityDefinition')[0];
193+
expect(priorityDefinitionElement).to.exist;
175194
})
176195
);
177196

@@ -197,7 +216,7 @@ describe('provider/zeebe - PriorityDefinitionProps', function() {
197216
// then
198217
const extensionElements = getBusinessObject(userTask).get('extensionElements');
199218
expect(getPriorityDefinition(userTask).get('priority')).to.eql('newValue');
200-
expect(extensionElements.values).to.have.length(2);
219+
expect(extensionElements.values).to.have.length(3);
201220
})
202221
);
203222

0 commit comments

Comments
 (0)