Skip to content

Commit

Permalink
chore: simplify utility for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 22, 2023
1 parent f50f4a7 commit 037cadc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/utils/properties-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,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 +235,7 @@ export function getEntryIds(report) {
}
}

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

Expand Down Expand Up @@ -498,14 +498,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

0 comments on commit 037cadc

Please sign in to comment.