Skip to content
Draft
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: 0 additions & 34 deletions lib/hooks/useSelectedElement.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useState, useEffect } from 'react';

import {
getBusinessObject,
is,
isAny
} from 'bpmn-js/lib/util/ModelUtil';

Expand Down Expand Up @@ -50,16 +48,6 @@ export function useSelectedElement(injector) {

setSelectedElement(newSelection[0]);
setMessage(null);
if (newSelection.length !== 1) {
setSelectedElement(null);
setMessage(SINGLE_TASK_SELECTION_REQUIRED_MESSAGE);
} else if (!isAny(newSelection[0], SUPPORTED_ELEMENT_TYPES)) {
setSelectedElement(null);
setMessage(TASK_SELECTION_REQUIRED_MESSAGE);
} else {
setSelectedElement(newSelection[0]);
setMessage(null);
}
};

return [ selectedElement, message ];
Expand All @@ -74,27 +62,5 @@ function validateSelection(selection) {
return TASK_SELECTION_REQUIRED_MESSAGE;
}

if (isInAdHocSubprocess(selection[0])) {
return AD_HOC_SUBPROCESS_TASK_UNSUPPORTED_MESSAGE;
}

return null;
}

function isInAdHocSubprocess(element) {
const bo = getBusinessObject(element);
let parent = getParent(bo);

while (parent) {
if (is(parent, 'bpmn:AdHocSubProcess')) {
return true;
}
parent = getParent(parent);
}

return false;
}

function getParent(bo) {
return bo.$parent;
}
11 changes: 5 additions & 6 deletions test/components/TaskTesting/TaskTesting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { bootstrapModeler, inject, getModeler } from '../../util/Util';
import TaskTesting from '../../../lib/components/TaskTesting/TaskTesting';

import {
SINGLE_TASK_SELECTION_REQUIRED_MESSAGE,
AD_HOC_SUBPROCESS_TASK_UNSUPPORTED_MESSAGE
SINGLE_TASK_SELECTION_REQUIRED_MESSAGE
} from '../../../lib/hooks/useSelectedElement';

import { DEFAULT_CONFIG } from '../../../lib/ElementConfig';
Expand Down Expand Up @@ -76,7 +75,7 @@ describe('TaskTesting', function() {
}));


it('should display unsupported message for a task in ad-hoc subprocess', inject(
it('should allow to test a task in an ad-hoc subprocess', inject(
async function(elementRegistry, selection) {

// given
Expand All @@ -86,12 +85,12 @@ describe('TaskTesting', function() {
selection.select(elementRegistry.get('AdHocSubProcessTask'));

// then
await screen.findByText(AD_HOC_SUBPROCESS_TASK_UNSUPPORTED_MESSAGE);
await screen.findByTestId('test-task-btn');
})
);


it('should display unsupported message for a task in a collapsed ad-hoc subprocess', inject(
it('should allow to test a task in a collapsed ad-hoc subprocess', inject(
async function(elementRegistry, selection, canvas) {

// given
Expand All @@ -102,7 +101,7 @@ describe('TaskTesting', function() {
selection.select(elementRegistry.get('CollapsedAdHocSubProcessTask'));

// then
await screen.findByText(AD_HOC_SUBPROCESS_TASK_UNSUPPORTED_MESSAGE);
await screen.findByTestId('test-task-btn');
})
);

Expand Down