@camunda/linting 3.41.0 → 3.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +75 -75
- package/assets/linting.css +37 -37
- package/lib/Linter.js +202 -202
- package/lib/Resolver.js +31 -31
- package/lib/compiled-config.js +69 -64
- package/lib/modeler/Linting.js +124 -124
- package/lib/modeler/LintingAnnotations.js +95 -95
- package/lib/modeler/OverlayComponent.js +60 -60
- package/lib/modeler/index.js +10 -10
- package/lib/plugins/bpmnLintPlugin.js +10 -10
- package/lib/plugins/index.js +4 -4
- package/lib/utils/error-messages.js +867 -861
- package/lib/utils/properties-panel.js +757 -757
- package/lib/utils/types.js +46 -46
- package/lib/utils/version.js +8 -8
- package/package.json +85 -85
package/lib/Resolver.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export default class NestedResolver {
|
|
2
|
-
constructor(resolvers) {
|
|
3
|
-
this.resolvers = resolvers.slice().reverse();
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
resolveRule(pkg, ruleName) {
|
|
7
|
-
for (const resolver of this.resolvers) {
|
|
8
|
-
try {
|
|
9
|
-
return resolver.resolveRule(pkg, ruleName);
|
|
10
|
-
} catch (err) {
|
|
11
|
-
|
|
12
|
-
// ignore
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
throw new Error(`unknown rule <${ pkg }/${ ruleName }>`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
resolveConfig(pkg, configName) {
|
|
20
|
-
for (const resolver of this.resolvers) {
|
|
21
|
-
try {
|
|
22
|
-
return resolver.resolveConfig(pkg, configName);
|
|
23
|
-
} catch (err) {
|
|
24
|
-
|
|
25
|
-
// ignore
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
throw new Error(`unknown config <${ pkg }/${ configName }>`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
export default class NestedResolver {
|
|
2
|
+
constructor(resolvers) {
|
|
3
|
+
this.resolvers = resolvers.slice().reverse();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
resolveRule(pkg, ruleName) {
|
|
7
|
+
for (const resolver of this.resolvers) {
|
|
8
|
+
try {
|
|
9
|
+
return resolver.resolveRule(pkg, ruleName);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
|
|
12
|
+
// ignore
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
throw new Error(`unknown rule <${ pkg }/${ ruleName }>`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
resolveConfig(pkg, configName) {
|
|
20
|
+
for (const resolver of this.resolvers) {
|
|
21
|
+
try {
|
|
22
|
+
return resolver.resolveConfig(pkg, configName);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw new Error(`unknown config <${ pkg }/${ configName }>`);
|
|
30
|
+
}
|
|
31
|
+
}
|
package/lib/compiled-config.js
CHANGED
|
@@ -54,6 +54,7 @@ const rules = {
|
|
|
54
54
|
"camunda-compat/no-candidate-users": "error",
|
|
55
55
|
"camunda-compat/no-execution-listeners": "error",
|
|
56
56
|
"camunda-compat/no-expression": "error",
|
|
57
|
+
"camunda-compat/no-interrupting-event-subprocess": "error",
|
|
57
58
|
"camunda-compat/no-loop": "error",
|
|
58
59
|
"camunda-compat/no-multiple-none-start-events": "error",
|
|
59
60
|
"camunda-compat/no-priority-definition": "error",
|
|
@@ -201,130 +202,134 @@ import rule_24 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-expre
|
|
|
201
202
|
|
|
202
203
|
cache['bpmnlint-plugin-camunda-compat/no-expression'] = rule_24;
|
|
203
204
|
|
|
204
|
-
import rule_25 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
205
|
+
import rule_25 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-interrupting-event-subprocess';
|
|
205
206
|
|
|
206
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
207
|
+
cache['bpmnlint-plugin-camunda-compat/no-interrupting-event-subprocess'] = rule_25;
|
|
207
208
|
|
|
208
|
-
import rule_26 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
209
|
+
import rule_26 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-loop';
|
|
209
210
|
|
|
210
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
211
|
+
cache['bpmnlint-plugin-camunda-compat/no-loop'] = rule_26;
|
|
211
212
|
|
|
212
|
-
import rule_27 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
213
|
+
import rule_27 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-multiple-none-start-events';
|
|
213
214
|
|
|
214
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
215
|
+
cache['bpmnlint-plugin-camunda-compat/no-multiple-none-start-events'] = rule_27;
|
|
215
216
|
|
|
216
|
-
import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
217
|
+
import rule_28 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-priority-definition';
|
|
217
218
|
|
|
218
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
219
|
+
cache['bpmnlint-plugin-camunda-compat/no-priority-definition'] = rule_28;
|
|
219
220
|
|
|
220
|
-
import rule_29 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
221
|
+
import rule_29 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-propagate-all-parent-variables';
|
|
221
222
|
|
|
222
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
223
|
+
cache['bpmnlint-plugin-camunda-compat/no-propagate-all-parent-variables'] = rule_29;
|
|
223
224
|
|
|
224
|
-
import rule_30 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
225
|
+
import rule_30 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-signal-event-sub-process';
|
|
225
226
|
|
|
226
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
227
|
+
cache['bpmnlint-plugin-camunda-compat/no-signal-event-sub-process'] = rule_30;
|
|
227
228
|
|
|
228
|
-
import rule_31 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-task-
|
|
229
|
+
import rule_31 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-task-schedule';
|
|
229
230
|
|
|
230
|
-
cache['bpmnlint-plugin-camunda-compat/no-task-
|
|
231
|
+
cache['bpmnlint-plugin-camunda-compat/no-task-schedule'] = rule_31;
|
|
231
232
|
|
|
232
|
-
import rule_32 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
233
|
+
import rule_32 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-task-listeners';
|
|
233
234
|
|
|
234
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
235
|
+
cache['bpmnlint-plugin-camunda-compat/no-task-listeners'] = rule_32;
|
|
235
236
|
|
|
236
|
-
import rule_33 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
237
|
+
import rule_33 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-template';
|
|
237
238
|
|
|
238
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
239
|
+
cache['bpmnlint-plugin-camunda-compat/no-template'] = rule_33;
|
|
239
240
|
|
|
240
|
-
import rule_34 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-
|
|
241
|
+
import rule_34 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-version-tag';
|
|
241
242
|
|
|
242
|
-
cache['bpmnlint-plugin-camunda-compat/no-
|
|
243
|
+
cache['bpmnlint-plugin-camunda-compat/no-version-tag'] = rule_34;
|
|
243
244
|
|
|
244
|
-
import rule_35 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-
|
|
245
|
+
import rule_35 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-properties';
|
|
245
246
|
|
|
246
|
-
cache['bpmnlint-plugin-camunda-compat/no-zeebe-
|
|
247
|
+
cache['bpmnlint-plugin-camunda-compat/no-zeebe-properties'] = rule_35;
|
|
247
248
|
|
|
248
|
-
import rule_36 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
249
|
+
import rule_36 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-zeebe-user-task';
|
|
249
250
|
|
|
250
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
251
|
+
cache['bpmnlint-plugin-camunda-compat/no-zeebe-user-task'] = rule_36;
|
|
251
252
|
|
|
252
|
-
import rule_37 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
253
|
+
import rule_37 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/priority-definition';
|
|
253
254
|
|
|
254
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
255
|
+
cache['bpmnlint-plugin-camunda-compat/priority-definition'] = rule_37;
|
|
255
256
|
|
|
256
|
-
import rule_38 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
257
|
+
import rule_38 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/zeebe-user-task';
|
|
257
258
|
|
|
258
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
259
|
+
cache['bpmnlint-plugin-camunda-compat/zeebe-user-task'] = rule_38;
|
|
259
260
|
|
|
260
|
-
import rule_39 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
261
|
+
import rule_39 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/secrets';
|
|
261
262
|
|
|
262
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
263
|
+
cache['bpmnlint-plugin-camunda-compat/secrets'] = rule_39;
|
|
263
264
|
|
|
264
|
-
import rule_40 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
265
|
+
import rule_40 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/sequence-flow-condition';
|
|
265
266
|
|
|
266
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
267
|
+
cache['bpmnlint-plugin-camunda-compat/sequence-flow-condition'] = rule_40;
|
|
267
268
|
|
|
268
|
-
import rule_41 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
269
|
+
import rule_41 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/signal-reference';
|
|
269
270
|
|
|
270
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
271
|
+
cache['bpmnlint-plugin-camunda-compat/signal-reference'] = rule_41;
|
|
271
272
|
|
|
272
|
-
import rule_42 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
273
|
+
import rule_42 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/start-event-form';
|
|
273
274
|
|
|
274
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
275
|
+
cache['bpmnlint-plugin-camunda-compat/start-event-form'] = rule_42;
|
|
275
276
|
|
|
276
|
-
import rule_43 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
277
|
+
import rule_43 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/subscription';
|
|
277
278
|
|
|
278
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
279
|
+
cache['bpmnlint-plugin-camunda-compat/subscription'] = rule_43;
|
|
279
280
|
|
|
280
|
-
import rule_44 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/task-
|
|
281
|
+
import rule_44 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/task-listener';
|
|
281
282
|
|
|
282
|
-
cache['bpmnlint-plugin-camunda-compat/task-
|
|
283
|
+
cache['bpmnlint-plugin-camunda-compat/task-listener'] = rule_44;
|
|
283
284
|
|
|
284
|
-
import rule_45 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
285
|
+
import rule_45 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/task-schedule';
|
|
285
286
|
|
|
286
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
287
|
+
cache['bpmnlint-plugin-camunda-compat/task-schedule'] = rule_45;
|
|
287
288
|
|
|
288
|
-
import rule_46 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
289
|
+
import rule_46 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/timer';
|
|
289
290
|
|
|
290
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
291
|
+
cache['bpmnlint-plugin-camunda-compat/timer'] = rule_46;
|
|
291
292
|
|
|
292
|
-
import rule_47 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-
|
|
293
|
+
import rule_47 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-definition';
|
|
293
294
|
|
|
294
|
-
cache['bpmnlint-plugin-camunda-compat/user-task-
|
|
295
|
+
cache['bpmnlint-plugin-camunda-compat/user-task-definition'] = rule_47;
|
|
295
296
|
|
|
296
|
-
import rule_48 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
297
|
+
import rule_48 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/user-task-form';
|
|
297
298
|
|
|
298
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
299
|
+
cache['bpmnlint-plugin-camunda-compat/user-task-form'] = rule_48;
|
|
299
300
|
|
|
300
|
-
import rule_49 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/
|
|
301
|
+
import rule_49 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/version-tag';
|
|
301
302
|
|
|
302
|
-
cache['bpmnlint-plugin-camunda-compat/
|
|
303
|
+
cache['bpmnlint-plugin-camunda-compat/version-tag'] = rule_49;
|
|
303
304
|
|
|
304
|
-
import rule_50 from 'bpmnlint/rules/
|
|
305
|
+
import rule_50 from 'bpmnlint-plugin-camunda-compat/rules/camunda-cloud/wait-for-completion';
|
|
305
306
|
|
|
306
|
-
cache['bpmnlint/
|
|
307
|
+
cache['bpmnlint-plugin-camunda-compat/wait-for-completion'] = rule_50;
|
|
307
308
|
|
|
308
|
-
import rule_51 from 'bpmnlint/rules/
|
|
309
|
+
import rule_51 from 'bpmnlint/rules/start-event-required';
|
|
309
310
|
|
|
310
|
-
cache['bpmnlint/
|
|
311
|
+
cache['bpmnlint/start-event-required'] = rule_51;
|
|
311
312
|
|
|
312
|
-
import rule_52 from 'bpmnlint/rules/
|
|
313
|
+
import rule_52 from 'bpmnlint/rules/ad-hoc-sub-process';
|
|
313
314
|
|
|
314
|
-
cache['bpmnlint/
|
|
315
|
+
cache['bpmnlint/ad-hoc-sub-process'] = rule_52;
|
|
315
316
|
|
|
316
|
-
import rule_53 from 'bpmnlint/rules/
|
|
317
|
+
import rule_53 from 'bpmnlint/rules/event-sub-process-typed-start-event';
|
|
317
318
|
|
|
318
|
-
cache['bpmnlint/
|
|
319
|
+
cache['bpmnlint/event-sub-process-typed-start-event'] = rule_53;
|
|
319
320
|
|
|
320
|
-
import rule_54 from 'bpmnlint/rules/
|
|
321
|
+
import rule_54 from 'bpmnlint/rules/link-event';
|
|
321
322
|
|
|
322
|
-
cache['bpmnlint/
|
|
323
|
+
cache['bpmnlint/link-event'] = rule_54;
|
|
323
324
|
|
|
324
|
-
import rule_55 from 'bpmnlint/rules/
|
|
325
|
+
import rule_55 from 'bpmnlint/rules/no-duplicate-sequence-flows';
|
|
325
326
|
|
|
326
|
-
cache['bpmnlint/
|
|
327
|
+
cache['bpmnlint/no-duplicate-sequence-flows'] = rule_55;
|
|
327
328
|
|
|
328
|
-
import rule_56 from 'bpmnlint/rules/
|
|
329
|
+
import rule_56 from 'bpmnlint/rules/sub-process-blank-start-event';
|
|
329
330
|
|
|
330
|
-
cache['bpmnlint/
|
|
331
|
+
cache['bpmnlint/sub-process-blank-start-event'] = rule_56;
|
|
332
|
+
|
|
333
|
+
import rule_57 from 'bpmnlint/rules/single-blank-start-event';
|
|
334
|
+
|
|
335
|
+
cache['bpmnlint/single-blank-start-event'] = rule_57;
|
package/lib/modeler/Linting.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { getBusinessObject, is } from 'bpmn-js/lib/util/ModelUtil';
|
|
2
|
-
|
|
3
|
-
import { getErrors } from '../utils/properties-panel';
|
|
4
|
-
|
|
5
|
-
export default class Linting {
|
|
6
|
-
constructor(canvas, config, elementRegistry, eventBus, lintingAnnotations, selection) {
|
|
7
|
-
this._canvas = canvas;
|
|
8
|
-
this._elementRegistry = elementRegistry;
|
|
9
|
-
this._eventBus = eventBus;
|
|
10
|
-
this._lintingAnnotations = lintingAnnotations;
|
|
11
|
-
this._selection = selection;
|
|
12
|
-
|
|
13
|
-
this._active = config && config.active || false;
|
|
14
|
-
this._reports = [];
|
|
15
|
-
|
|
16
|
-
eventBus.on('selection.changed', () => this._update());
|
|
17
|
-
|
|
18
|
-
eventBus.on('lintingAnnotations.click', ({ report }) => this.showError(report));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
showError(report) {
|
|
22
|
-
const {
|
|
23
|
-
id,
|
|
24
|
-
propertiesPanel = {}
|
|
25
|
-
} = report;
|
|
26
|
-
|
|
27
|
-
const selectableElement = this._getSelectableElement(id);
|
|
28
|
-
|
|
29
|
-
if (selectableElement) {
|
|
30
|
-
this._canvas.scrollToElement(selectableElement);
|
|
31
|
-
|
|
32
|
-
if (selectableElement === this._canvas.getRootElement()) {
|
|
33
|
-
this._selection.select();
|
|
34
|
-
} else {
|
|
35
|
-
this._selection.select(selectableElement);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const { entryIds = [] } = propertiesPanel;
|
|
40
|
-
|
|
41
|
-
// TODO(philippfromme): remove timeout once properties panel is fixed
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
this._eventBus.fire('propertiesPanel.showEntry', {
|
|
44
|
-
id: entryIds[ Math.max(0, entryIds.length - 1) ]
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setErrors(reports) {
|
|
50
|
-
this._reports = reports;
|
|
51
|
-
|
|
52
|
-
this._update();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
activate() {
|
|
56
|
-
this._active = true;
|
|
57
|
-
|
|
58
|
-
this._update();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
deactivate() {
|
|
62
|
-
this._active = false;
|
|
63
|
-
|
|
64
|
-
this._update();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isActive() {
|
|
68
|
-
return this._active;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_update() {
|
|
72
|
-
|
|
73
|
-
// set annotations
|
|
74
|
-
this._lintingAnnotations.setErrors(this.isActive() ? this._reports : []);
|
|
75
|
-
|
|
76
|
-
// set properties panel errors
|
|
77
|
-
const selectedElement = this._getSelectedElement();
|
|
78
|
-
|
|
79
|
-
this._eventBus.fire('propertiesPanel.setErrors', {
|
|
80
|
-
errors: getErrors(this._reports, selectedElement)
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
_getSelectableElement(id) {
|
|
85
|
-
let element = this._elementRegistry.get(id);
|
|
86
|
-
|
|
87
|
-
if (!element) {
|
|
88
|
-
element = this._elementRegistry.filter(element => {
|
|
89
|
-
return is(element, 'bpmn:Participant') && getBusinessObject(element).get('processRef').get('id') === id;
|
|
90
|
-
})[ 0 ];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return element;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_getSelectedElement() {
|
|
97
|
-
const selection = this._selection.get();
|
|
98
|
-
|
|
99
|
-
if (!selection || !selection.length) {
|
|
100
|
-
return this._canvas.getRootElement();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const selectedElement = selection[ 0 ];
|
|
104
|
-
|
|
105
|
-
if (isLabel(selectedElement)) {
|
|
106
|
-
return selectedElement.labelTarget;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return selectedElement;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
Linting.$inject = [
|
|
114
|
-
'canvas',
|
|
115
|
-
'config.linting',
|
|
116
|
-
'elementRegistry',
|
|
117
|
-
'eventBus',
|
|
118
|
-
'lintingAnnotations',
|
|
119
|
-
'selection'
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
function isLabel(element) {
|
|
123
|
-
return !!element.labelTarget;
|
|
124
|
-
}
|
|
1
|
+
import { getBusinessObject, is } from 'bpmn-js/lib/util/ModelUtil';
|
|
2
|
+
|
|
3
|
+
import { getErrors } from '../utils/properties-panel';
|
|
4
|
+
|
|
5
|
+
export default class Linting {
|
|
6
|
+
constructor(canvas, config, elementRegistry, eventBus, lintingAnnotations, selection) {
|
|
7
|
+
this._canvas = canvas;
|
|
8
|
+
this._elementRegistry = elementRegistry;
|
|
9
|
+
this._eventBus = eventBus;
|
|
10
|
+
this._lintingAnnotations = lintingAnnotations;
|
|
11
|
+
this._selection = selection;
|
|
12
|
+
|
|
13
|
+
this._active = config && config.active || false;
|
|
14
|
+
this._reports = [];
|
|
15
|
+
|
|
16
|
+
eventBus.on('selection.changed', () => this._update());
|
|
17
|
+
|
|
18
|
+
eventBus.on('lintingAnnotations.click', ({ report }) => this.showError(report));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
showError(report) {
|
|
22
|
+
const {
|
|
23
|
+
id,
|
|
24
|
+
propertiesPanel = {}
|
|
25
|
+
} = report;
|
|
26
|
+
|
|
27
|
+
const selectableElement = this._getSelectableElement(id);
|
|
28
|
+
|
|
29
|
+
if (selectableElement) {
|
|
30
|
+
this._canvas.scrollToElement(selectableElement);
|
|
31
|
+
|
|
32
|
+
if (selectableElement === this._canvas.getRootElement()) {
|
|
33
|
+
this._selection.select();
|
|
34
|
+
} else {
|
|
35
|
+
this._selection.select(selectableElement);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { entryIds = [] } = propertiesPanel;
|
|
40
|
+
|
|
41
|
+
// TODO(philippfromme): remove timeout once properties panel is fixed
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
this._eventBus.fire('propertiesPanel.showEntry', {
|
|
44
|
+
id: entryIds[ Math.max(0, entryIds.length - 1) ]
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setErrors(reports) {
|
|
50
|
+
this._reports = reports;
|
|
51
|
+
|
|
52
|
+
this._update();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
activate() {
|
|
56
|
+
this._active = true;
|
|
57
|
+
|
|
58
|
+
this._update();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
deactivate() {
|
|
62
|
+
this._active = false;
|
|
63
|
+
|
|
64
|
+
this._update();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
isActive() {
|
|
68
|
+
return this._active;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_update() {
|
|
72
|
+
|
|
73
|
+
// set annotations
|
|
74
|
+
this._lintingAnnotations.setErrors(this.isActive() ? this._reports : []);
|
|
75
|
+
|
|
76
|
+
// set properties panel errors
|
|
77
|
+
const selectedElement = this._getSelectedElement();
|
|
78
|
+
|
|
79
|
+
this._eventBus.fire('propertiesPanel.setErrors', {
|
|
80
|
+
errors: getErrors(this._reports, selectedElement)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_getSelectableElement(id) {
|
|
85
|
+
let element = this._elementRegistry.get(id);
|
|
86
|
+
|
|
87
|
+
if (!element) {
|
|
88
|
+
element = this._elementRegistry.filter(element => {
|
|
89
|
+
return is(element, 'bpmn:Participant') && getBusinessObject(element).get('processRef').get('id') === id;
|
|
90
|
+
})[ 0 ];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return element;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_getSelectedElement() {
|
|
97
|
+
const selection = this._selection.get();
|
|
98
|
+
|
|
99
|
+
if (!selection || !selection.length) {
|
|
100
|
+
return this._canvas.getRootElement();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const selectedElement = selection[ 0 ];
|
|
104
|
+
|
|
105
|
+
if (isLabel(selectedElement)) {
|
|
106
|
+
return selectedElement.labelTarget;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return selectedElement;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Linting.$inject = [
|
|
114
|
+
'canvas',
|
|
115
|
+
'config.linting',
|
|
116
|
+
'elementRegistry',
|
|
117
|
+
'eventBus',
|
|
118
|
+
'lintingAnnotations',
|
|
119
|
+
'selection'
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
function isLabel(element) {
|
|
123
|
+
return !!element.labelTarget;
|
|
124
|
+
}
|