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

Only Display Errors in Properties Panel #86

Merged
merged 4 commits into from
Sep 25, 2023
Merged
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
34 changes: 20 additions & 14 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const TIMER_PROPERTIES = [
*/
export function getErrors(reports, element) {
return reports.reduce((errors, report) => {
if (!element || getBusinessObject(element).get('id') !== report.id) {
const { category } = report;

if (!element
|| getBusinessObject(element).get('id') !== report.id
|| category !== 'error') {
return errors;
}

Expand Down Expand Up @@ -226,7 +230,7 @@ export function getEntryIds(report) {
];

for (const [ type, prefix ] of LIST_PROPERTIES) {
if (hasType(data, type)
if (isType(data, type)
&& getPropertyName(data)) {

const index = path[ path.length - 2 ];
Expand All @@ -235,7 +239,7 @@ export function getEntryIds(report) {
}
}

if (hasType(data, 'zeebe:LoopCharacteristics')) {
if (isType(data, 'zeebe:LoopCharacteristics')) {
return [ `multiInstance-${getPropertyName(data)}` ];
}

Expand Down Expand Up @@ -298,10 +302,6 @@ export function getErrorMessage(id, report) {
return 'Cannot be an expression.';
}

if (data.type === ERROR_TYPES.SECRET_EXPRESSION_FORMAT_DEPRECATED) {
return 'Secret expression format deprecated.';
nikku marked this conversation as resolved.
Show resolved Hide resolved
}

if (id === 'isExecutable') {
const { parentNode } = data;

Expand Down Expand Up @@ -384,7 +384,11 @@ export function getErrorMessage(id, report) {
return 'Type must be defined.';
}

if (id === 'messageSubscriptionCorrelationKey') {
if (id === 'messageSubscriptionCorrelationKey'
&& [
ERROR_TYPES.EXTENSION_ELEMENT_REQUIRED,
nikku marked this conversation as resolved.
Show resolved Hide resolved
ERROR_TYPES.PROPERTY_REQUIRED
].includes(data.type)) {
return 'Subscription correlation key must be defined.';
}

Expand Down Expand Up @@ -498,14 +502,16 @@ function isPropertyError(data, property, type) {
&& (!type || is(data.node, type));
}

function hasType(data, type) {
return data.node && is(data.node, type);
}

function getPropertyName(data) {
const propertyKey = data.type === ERROR_TYPES.PROPERTY_REQUIRED ? 'requiredProperty' : 'property';
if (data.type === ERROR_TYPES.PROPERTY_REQUIRED) {
return data.requiredProperty;
}

return data[ propertyKey ];
return data.property;
}

function isType(data, type) {
return data.node && is(data.node, type);
}

function isOneOfPropertiesRequiredError(data, requiredProperty, type) {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@bpmn-io/diagram-js-ui": "^0.2.2",
"bpmn-moddle": "^8.0.0",
"bpmnlint": "^9.2.0",
"bpmnlint-plugin-camunda-compat": "^2.7.1",
"bpmnlint-plugin-camunda-compat": "^2.8.0",
"bpmnlint-utils": "^1.0.2",
"camunda-bpmn-moddle": "^7.0.1",
"clsx": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('utils/error-messages', function() {
const errorMessage = getErrorMessage(report, 'Camunda Cloud', executionPlatformVersion);

// then
expect(errorMessage).to.equal('A <Signal Start Event> in a <Sub Process> is not supported by Camunda 8.2');
expect(errorMessage).to.equal('A <Signal Start Event> in a <Sub Process> is only supported by Camunda 8.3 or newer');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});

});
Expand Down
43 changes: 43 additions & 0 deletions test/spec/utils/properties-panel-info.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<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:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_192a7nr" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.15.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.2.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task_1">
<bpmn:extensionElements>
<zeebe:properties>
<zeebe:property value="secrets.FOO" />
</zeebe:properties>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_1" />
<bpmn:endEvent id="EndEvent_1">
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="Task_1" targetRef="EndEvent_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0h1z36w_di" bpmnElement="Task_1">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0qv5l20_di" bpmnElement="EndEvent_1">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_15s2mgu_di" bpmnElement="SequenceFlow_1">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1iq04xt_di" bpmnElement="SequenceFlow_2">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
59 changes: 56 additions & 3 deletions test/spec/utils/properties-panel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from './lint-helper';

import propertiesPanelXML from './properties-panel.bpmn';
import propertiesPanelInfoXML from './properties-panel-info.bpmn';
import propertiesPanelPlatformXML from './properties-panel-platform.bpmn';

describe('utils/properties-panel', function() {
Expand Down Expand Up @@ -1590,7 +1591,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'messageSubscriptionCorrelationKey' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});


Expand Down Expand Up @@ -1622,7 +1623,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'ServiceTask_1-input-0-source' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});


Expand Down Expand Up @@ -1654,7 +1655,7 @@ describe('utils/properties-panel', function() {
// then
expect(entryIds).to.eql([ 'ServiceTask_1-extensionProperty-0-value' ]);

expectErrorMessage(entryIds[ 0 ], 'Secret expression format deprecated.', report);
expectNoErrorMessage(entryIds[ 0 ], report);
});

});
Expand Down Expand Up @@ -1759,6 +1760,54 @@ describe('utils/properties-panel', function() {
});
});


it('should not return errors for category info', async function() {
nikku marked this conversation as resolved.
Show resolved Hide resolved

// given
const linter = new Linter();

const { root } = await createModdle(propertiesPanelInfoXML);

const reports = await linter.lint(root);

// when
let element = root.rootElements[ 0 ].flowElements.find(({ id }) => id === 'Task_1');

let errors = getErrors(reports, element);

// then
expect(errors).to.be.empty;
});


it('should not return errors for category warn', async function() {

// given
const linter = new Linter({
plugins: [
{
config: {
rules: {
'camunda-compat/secrets': 'warn'
}
}
}
]
});

const { root } = await createModdle(propertiesPanelInfoXML);

const reports = await linter.lint(root);

// when
let element = root.rootElements[ 0 ].flowElements.find(({ id }) => id === 'Task_1');

let errors = getErrors(reports, element);

// then
expect(errors).to.be.empty;
});

});

});
Expand Down Expand Up @@ -1825,4 +1874,8 @@ function expectErrorMessage(id, expectedErrorMessage, report) {

// then
expect(errorMessage).to.equal(expectedErrorMessage);
}

function expectNoErrorMessage(id, report) {
expectErrorMessage(id, undefined, report);
}
Loading