Skip to content

Commit

Permalink
feat: separate core and UI
Browse files Browse the repository at this point in the history
* move behaviors to `behavior` module
* create `core` module
* move properties panel (UI) related things to `properties-panel` module
  • Loading branch information
nikku authored and barmac committed Jan 23, 2024
1 parent 940e085 commit 58a758d
Show file tree
Hide file tree
Showing 40 changed files with 291 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import { is } from 'bpmn-js/lib/util/ModelUtil';

import { findExtension } from './Helper';
import { findExtension } from '../Helper';

/**
* Enforces no variable propagation for templated call activities.
Expand All @@ -11,7 +11,7 @@ export class CalledElementBehavior extends CommandInterceptor {
/**
* @param {*} eventBus
* @param {*} modeling
* @param {import('./ElementTemplates').default} elementTemplates
* @param {import('../ElementTemplates').default} elementTemplates
*/
constructor(eventBus, modeling, elementTemplates) {
super(eventBus);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
applyConditions
} from './Condition';
} from '../Condition';

import { isObject } from 'min-dash';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { ZEEBE_TASK_DEFINITION, ZEEBE_TASK_DEFINITION_TYPE_TYPE } from './util/bindingTypes';
import { ZEEBE_TASK_DEFINITION, ZEEBE_TASK_DEFINITION_TYPE_TYPE } from '../util/bindingTypes';

const HIGH_PRIORITY = 2500;

/**
* Checks the conditions of an element template and sets/resets the
* corresponding properties on the element.
*/
export default class ElementTemplatesConditionChecker extends CommandInterceptor {
export default class ConditionalBehavior extends CommandInterceptor {
constructor(eventBus, elementTemplates, commandStack, bpmnFactory, injector) {
super(eventBus);

Expand Down Expand Up @@ -105,7 +105,7 @@ export default class ElementTemplatesConditionChecker extends CommandInterceptor
}


ElementTemplatesConditionChecker.$inject = [
ConditionalBehavior.$inject = [
'eventBus',
'elementTemplates',
'commandStack',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { getDefaultValue } from './Helper';
import { getPropertyValue, setPropertyValue } from './util/propertyUtil';
import { getDefaultValue } from '../Helper';
import { getPropertyValue, setPropertyValue } from '../util/propertyUtil';

/**
* Handles generated value properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { getBusinessObject, isAny } from 'bpmn-js/lib/util/ModelUtil';
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
import { isString } from 'min-dash';

import { findMessage, getTemplateId, TEMPLATE_ID_ATTR } from './Helper';
import { findMessage, getTemplateId, TEMPLATE_ID_ATTR } from '../Helper';
import {
getReferringElement,
removeRootElement
} from './util/rootElementUtil';
} from '../util/rootElementUtil';

/**
* Handles referenced elements.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { isObject } from 'min-dash';
import { applyConditions } from './Condition';
import { findExtension } from './Helper';
import { applyConditions } from '../Condition';
import { findExtension } from '../Helper';

/**
* Restores the original order of the template properties
Expand Down
23 changes: 23 additions & 0 deletions src/cloud-element-templates/behavior/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ConditionalBehavior from './ConditionalBehavior';
import ReplaceBehavior from './ReplaceBehavior';
import UpdatePropertiesOrderBehavior from './UpdatePropertiesOrderBehavior';
import { ReferencedElementBehavior } from './ReferencedElementBehavior';
import { GeneratedValueBehavior } from './GeneratedValueBehavior';
import { CalledElementBehavior } from './CalledElementBehavior';

export default {
__init__: [
'elementTemplatesReplaceBehavior',
'elementTemplatesConditionalBehavior',
'elementTemplatesGeneratedValueBehavior',
'elementTemplatesReferencedElementBehavior',
'elementTemplatesUpdatePropertiesOrderBehavior',
'elementTemplatesCalledElementBehavior'
],
elementTemplatesReplaceBehavior: [ 'type', ReplaceBehavior ],
elementTemplatesConditionalBehavior: [ 'type', ConditionalBehavior ],
elementTemplatesGeneratedValueBehavior: [ 'type', GeneratedValueBehavior ],
elementTemplatesReferencedElementBehavior: [ 'type', ReferencedElementBehavior ],
elementTemplatesUpdatePropertiesOrderBehavior: [ 'type', UpdatePropertiesOrderBehavior ],
elementTemplatesCalledElementBehavior: [ 'type', CalledElementBehavior ]
};
19 changes: 19 additions & 0 deletions src/cloud-element-templates/core/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ElementTemplates from '../ElementTemplates';
import ElementTemplatesLoader from '../ElementTemplatesLoader';

import commandsModule from '../cmd';
import createModule from '../create';
import behaviorModule from '../behavior';

export default {
__depends__: [
commandsModule,
behaviorModule,
createModule
],
__init__: [
'elementTemplatesLoader'
],
elementTemplates: [ 'type', ElementTemplates ],
elementTemplatesLoader: [ 'type', ElementTemplatesLoader ]
};
42 changes: 5 additions & 37 deletions src/cloud-element-templates/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
import translateModule from 'diagram-js/lib/i18n/translate';

import ElementTemplatesConditionChecker from './ElementTemplatesConditionChecker';
import ElementTemplates from './ElementTemplates';
import ElementTemplatesLoader from './ElementTemplatesLoader';
import ReplaceBehavior from './ReplaceBehavior';
import commandsModule from './cmd';
import templateElementFactoryModule from './create';
import ElementTemplatesPropertiesProvider from './ElementTemplatesPropertiesProvider';
import UpdateTemplatePropertiesOrder from './UpdateTemplatePropertiesOrder';
import { ReferencedElementBehavior } from './ReferencedElementBehavior';
import { GeneratedValueBehavior } from './GeneratedValueBehavior';
import { CalledElementBehavior } from './CalledElementBehavior';

import coreModule from './core';
import propertiesProviderModule from './properties-panel';

export default {
__depends__: [
commandsModule,
templateElementFactoryModule,
translateModule
],
__init__: [
'elementTemplatesLoader',
'replaceBehavior',
'elementTemplatesPropertiesProvider',
'elementTemplatesConditionChecker',
'generatedValueBehavior',
'referencedElementBehavior',
'updateTemplatePropertiesOrder',
'calledElementBehavior'
],
elementTemplates: [ 'type', ElementTemplates ],
elementTemplatesLoader: [ 'type', ElementTemplatesLoader ],
replaceBehavior: [ 'type', ReplaceBehavior ],
elementTemplatesPropertiesProvider: [ 'type', ElementTemplatesPropertiesProvider ],
elementTemplatesConditionChecker: [ 'type', ElementTemplatesConditionChecker ],
generatedValueBehavior: [ 'type', GeneratedValueBehavior ],
referencedElementBehavior: [ 'type', ReferencedElementBehavior ],
updateTemplatePropertiesOrder: [ 'type', UpdateTemplatePropertiesOrder ],
calledElementBehavior: [ 'type', CalledElementBehavior ]
coreModule,
propertiesProviderModule,
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
*/

import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
import ElementTemplates from './ElementTemplates';
import { getPropertyValue, validateProperty } from './util/propertyUtil';
import ElementTemplates from '../ElementTemplates';
import { getPropertyValue, validateProperty } from '../util/propertyUtil';

import { applyConditions } from './Condition';
import { applyConditions } from '../Condition';

import BpmnModdle from 'bpmn-moddle';
import { is } from 'bpmn-js/lib/util/ModelUtil';

import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe';

import { Validator } from './Validator';
import { Validator } from '../Validator';

export const elementTemplateLintRule = ({ templates = [] }) => {
const moddle = new BpmnModdle({ zeebe: zeebeModdle });
Expand Down
1 change: 1 addition & 0 deletions src/cloud-element-templates/linting/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LinterPlugin';
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
createElementTemplatesGroup,
TemplateProps
} from '../element-templates/components';
} from '../../element-templates/components';

import {
CustomProperties,
MessageProps
} from './properties';

import { getTemplateId } from './Helper';
import { getTemplateId } from '../Helper';

import { applyConditions } from './Condition';
import { getPropertyValue } from './util/propertyUtil';
import { applyConditions } from '../Condition';
import { getPropertyValue } from '../util/propertyUtil';

const LOWER_PRIORITY = 300;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Markup from 'preact-markup';

import { sanitizeHTML } from '../../element-templates/util/sanitize';
import { sanitizeHTML } from '../../../element-templates/util/sanitize';

export function PropertyTooltip(props) {

Expand Down
13 changes: 13 additions & 0 deletions src/cloud-element-templates/properties-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import translateModule from 'diagram-js/lib/i18n/translate';

import ElementTemplatesPropertiesProvider from './ElementTemplatesPropertiesProvider';

export default {
__depends__: [
translateModule
],
__init__: [
'elementTemplatesPropertiesProvider'
],
elementTemplatesPropertiesProvider: [ 'type', ElementTemplatesPropertiesProvider ]
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {

import { useService } from 'bpmn-js-properties-panel';

import { PropertyDescription } from '../../element-templates/components/PropertyDescription';
import { PropertyDescription } from '../../../element-templates/components/PropertyDescription';
import { PropertyTooltip } from '../components/PropertyTooltip';

import { getPropertyValue, setPropertyValue, validateProperty } from '../util/propertyUtil';
import { getPropertyValue, setPropertyValue, validateProperty } from '../../util/propertyUtil';

import {
Group,
Expand All @@ -28,14 +28,14 @@ import {
ZEEBE_OUTPUT_TYPE,
ZEEBE_PROPERTY_TYPE,
ZEEBE_TASK_HEADER_TYPE
} from '../util/bindingTypes';
} from '../../util/bindingTypes';

import {
FeelEntryWithVariableContext,
FeelTextAreaEntryWithVariableContext,
FeelEntry,
FeelTextAreaEntry
} from '../../entries/FeelEntryWithContext';
} from '../../../entries/FeelEntryWithContext';


const DEFAULT_CUSTOM_GROUP = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import {
} from 'min-dash';

import { isSelectEntryEdited } from '@bpmn-io/properties-panel';
import ReferenceSelect from '../../entries/ReferenceSelect';
import ReferenceSelect from '../../../entries/ReferenceSelect';

import { useService } from 'bpmn-js-properties-panel';

import {
getMessage,
getMessageEventDefinition,
isMessageSupported
} from '../../utils/EventDefinitionUtil';
} from '../../../utils/EventDefinitionUtil';

import {
createElement,
findRootElementById,
findRootElementsByType,
getRoot,
nextId
} from '../../utils/ElementUtil';
} from '../../../utils/ElementUtil';

export const EMPTY_OPTION = '';
export const CREATE_NEW_OPTION = 'create-new';
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export { default as ElementTemplatesPropertiesProviderModule } from './element-t

// utils
export { Validator as CloudElementTemplatesValidator } from './cloud-element-templates/Validator';
export { ElementTemplateLinterPlugin as CloudElementTemplatesLinterPlugin } from './cloud-element-templates/LinterPlugin';
export { ElementTemplateLinterPlugin as CloudElementTemplatesLinterPlugin } from './cloud-element-templates/linting';
2 changes: 1 addition & 1 deletion test/spec/Example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import ZeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe';
import CloudElementTemplatesPropertiesProviderModule from 'src/cloud-element-templates';
import ElementTemplatesPropertiesProviderModule from 'src/element-templates';

import { ElementTemplateLinterPlugin } from 'src/cloud-element-templates/LinterPlugin';
import { ElementTemplateLinterPlugin } from 'src/cloud-element-templates/linting';

const singleStart = window.__env__ && window.__env__.SINGLE_START;

Expand Down
21 changes: 6 additions & 15 deletions test/spec/cloud-element-templates/ElementTemplates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
} from 'bpmn-js/lib/util/ModelUtil';

import coreModule from 'bpmn-js/lib/core';
import elementTemplatesModule from 'src/cloud-element-templates';
import { BpmnPropertiesPanelModule } from 'bpmn-js-properties-panel';
import elementTemplatesCoreModule from 'src/cloud-element-templates/core';
import modelingModule from 'bpmn-js/lib/features/modeling';

import zeebeModdlePackage from 'zeebe-bpmn-moddle/resources/zeebe';
Expand Down Expand Up @@ -46,12 +45,8 @@ describe('provider/cloud-element-templates - ElementTemplates', function() {
container: container,
modules: [
coreModule,
elementTemplatesModule,
modelingModule,
BpmnPropertiesPanelModule,
{
propertiesPanel: [ 'value', { registerProvider() {} } ]
}
elementTemplatesCoreModule,
modelingModule
],
moddleExtensions: {
zeebe: zeebeModdlePackage
Expand Down Expand Up @@ -996,7 +991,7 @@ describe('provider/cloud-element-templates - ElementTemplates', function() {
container: container,
modules: [
coreModule,
elementTemplatesModule,
elementTemplatesCoreModule,
modelingModule,
{
propertiesPanel: [ 'value', { registerProvider() {} } ]
Expand Down Expand Up @@ -1130,12 +1125,8 @@ describe('provider/cloud-element-templates - ElementTemplates - integration', fu
container: container,
modules: [
coreModule,
elementTemplatesModule,
modelingModule,
BpmnPropertiesPanelModule,
{
propertiesPanel: [ 'value', { registerProvider() {} } ]
}
elementTemplatesCoreModule,
modelingModule
],
moddleExtensions: {
zeebe: zeebeModdlePackage
Expand Down
Loading

0 comments on commit 58a758d

Please sign in to comment.