Skip to content

Commit

Permalink
fix: show modeling feedback error for data objects
Browse files Browse the repository at this point in the history
Related to camunda/camunda-modeler#4345

---------

Co-authored-by: Maciej Barelkowski <maciejbarel@gmail.com>
  • Loading branch information
ssidharth010 and barmac authored Feb 24, 2025
1 parent de95b43 commit d348b50
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
9 changes: 7 additions & 2 deletions lib/features/modeling-feedback/ModelingFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { is } from '../../util/ModelUtil';
*/

var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
var DATA_OBJECT_ERR_MSG = 'Data object must be placed within a pool/participant.';

/**
* @param {EventBus} eventBus
Expand All @@ -32,8 +33,12 @@ export default function ModelingFeedback(eventBus, tooltips, translate) {
shape = context.shape,
target = context.target;

if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
showError(event, translate(COLLAB_ERR_MSG));
if (is(target, 'bpmn:Collaboration')) {
if (is(shape, 'bpmn:FlowNode')) {
showError(event, translate(COLLAB_ERR_MSG));
} else if (is(shape, 'bpmn:DataObjectReference')) {
showError(event, translate(DATA_OBJECT_ERR_MSG));
}
}
});

Expand Down
45 changes: 32 additions & 13 deletions test/spec/features/modeling-feedback/ModelingFeedbackSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,46 @@ describe('features/modeling - ModelingFeedback', function() {
]
}));

it('should indicate error when placing flow elements inside collaboration', inject(
function(create, canvas, elementFactory, dragging) {

it('should indicate', inject(function(create, canvas, elementFactory, dragging) {
// given
var task = elementFactory.createShape({ type: 'bpmn:Task' });

// given
var task = elementFactory.createShape({ type: 'bpmn:Task' });
var collaboration = canvas.getRootElement();
var collaborationGfx = canvas.getGraphics(collaboration);

var collaboration = canvas.getRootElement();
var collaborationGfx = canvas.getGraphics(collaboration);
create.start(canvasEvent({ x: 100, y: 100 }), task);
dragging.hover({ element: collaboration, gfx: collaborationGfx });

create.start(canvasEvent({ x: 100, y: 100 }), task);
dragging.hover({ element: collaboration, gfx: collaborationGfx });
// when
dragging.end();

// when
dragging.end();
// then
expectTooltip('error', 'flow elements must be children of pools/participants');
}));

// then
expectTooltip('error', 'flow elements must be children of pools/participants');
}));
it('should indicate error when placing data objects inside collaboration', inject(
function(create, canvas, elementFactory, dragging) {

});
// given
var dataObject = elementFactory.createShape({ type: 'bpmn:DataObjectReference' });

var collaboration = canvas.getRootElement();
var collaborationGfx = canvas.getGraphics(collaboration);

create.start(canvasEvent({ x: 150, y: 150 }), dataObject);
dragging.hover({ element: collaboration, gfx: collaborationGfx });

// when
dragging.end();

// then
expectTooltip('error', 'Data object must be placed within a pool/participant.');
}
));

});

function expectTooltip(cls, message) {

Expand Down

0 comments on commit d348b50

Please sign in to comment.