-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJobExecutionExtensionProvider.js
More file actions
69 lines (55 loc) · 1.87 KB
/
JobExecutionExtensionProvider.js
File metadata and controls
69 lines (55 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { createJobExecutionGroup as defaultCreateJobExecutionGroup } from './props/JobExecutionGroup';
export default class JobExecutionExtensionProvider {
constructor(propertiesPanel, createJobExecutionGroup = defaultCreateJobExecutionGroup) {
propertiesPanel.registerProvider(100, this);
this.createJobExecutionGroup = createJobExecutionGroup;
}
getGroups(element) {
return groups => {
const existingJobExecutionGroupIndex = groupExists(groups, 'CamundaPlatform__JobExecution');
if (existingJobExecutionGroupIndex !== -1) {
groups.splice(existingJobExecutionGroupIndex, 1);
}
const extendedJobExecutionGroup = groupExists(groups, 'job_execution');
groups = groups.slice();
if (extendedJobExecutionGroup === -1) {
const jobExecutionGroup = this.createJobExecutionGroup(element);
if (jobExecutionGroup) {
let adjacentIndex = groups.length - 2;
groups.forEach((group, index) => {
if (isAdjacentGroup(group)) {
adjacentIndex = index + 1;
}
});
groups.splice(adjacentIndex, 0, jobExecutionGroup);
}
}
return groups;
};
}
}
JobExecutionExtensionProvider.$inject = [ 'propertiesPanel' ];
function isAdjacentGroup(group) {
const entries = group.entries;
let isAdjacent = false;
if (entries) {
entries.forEach(entry => {
const property = entry.property;
if (property) {
const propertyName = property.binding.name;
if (propertyName.startsWith('camunda:async')) {
return isAdjacent = true;
}
}
});
}
if ('CamundaPlatform__AsynchronousContinuations' === group.id) {
isAdjacent = true;
}
return isAdjacent;
}
function groupExists(groups, groupId) {
return groups.reduce((acc, group, index) => {
return groupId === group.id ? index : acc;
}, -1);
}