diff --git a/.github/workflows/run-npm-linting.yml b/.github/workflows/run-npm-linting.yml new file mode 100644 index 00000000..3e572e28 --- /dev/null +++ b/.github/workflows/run-npm-linting.yml @@ -0,0 +1,28 @@ +name: Check the code style of the Quantum Workflow Modeler + +on: + pull_request: + types: [ opened, synchronize ] + push: + branches: + - 'master' + +jobs: + run-linters: + name: Run linters + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install Node.js dependencies and run linters + run: | + npm ci + npm run lint + working-directory: ./components/bpmn-q diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index e0135496..af1661d7 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -1,4 +1,4 @@ -name: Run all test of the Quantum Workflow Modeler +name: Run Tests on: pull_request: diff --git a/NOTICE b/NOTICE index d4a1bb4e..850d5745 100644 --- a/NOTICE +++ b/NOTICE @@ -1,16 +1,12 @@ - The source code of this project is licensed under the Apache 2.0 license, found in the LICENSE file in this directory. -The code of the QuantME Plugin und certain utility functions of the editor are based on and using code from the -QuantME Transformation Framework, licensed under the MIT license and available -under https://github.com/UST-QuAntiL/QuantME-TransformationFramework. +The code of the QuantME Plugin and certain utility functions of the editor are based on and using code from the QuantME Transformation Framework, licensed under the MIT license and available under https://github.com/UST-QuAntiL/QuantME-TransformationFramework. The code of the PlanQK Plugin is based on the code of the workflow modeler prototype of the PlanQK Platform. -Certain components of the editor use and extend the code of the bpmn-js repository, the diagram-js repository and the camunda-modeler -repository of Camunda. The bpmn-js repository is licensed under the bpmn.io license and available in the following GitHub -repository https://github.com/bpmn-io/bpmn-js. The diagram-js repository is licensed under the MIT license, available under -the following link: https://github.com/bpmn-io/diagram-js. The camunda-modeler is licensed under the MIT license and available -under the following link: https://github.com/camunda/camunda-modeler. +Certain components of the editor use and extend the code of the bpmn-js repository, the diagram-js repository and the camunda-modeler repository of Camunda. +The bpmn-js repository is licensed under the bpmn.io license and available in the following GitHub repository https://github.com/bpmn-io/bpmn-js. +The diagram-js repository is licensed under the MIT license, available under the following link: https://github.com/bpmn-io/diagram-js. +The camunda-modeler is licensed under the MIT license and available under the following link: https://github.com/camunda/camunda-modeler. Find copies of the third party license in the THIRD_PARTY_LICENSE directory under this directory. \ No newline at end of file diff --git a/README.md b/README.md index a40a9f6e..6987bb3c 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,31 @@ # Quantum Workflow Modeler -A web-based modelling tool for modelling BPMN 2.0-based quantum workflows. It uses and extends the -[bpmn-js Modeler](https://github.com/bpmn-io/bpmn-js/) of Camunda which is embedded in the User Interface (UI) of the -Quantum Workflow Modeler and handles the graphical modelling of workflows. -It contains several modelling extensions to the BPMN standard which enable the modeling of an explicit, executable data -flow and the modelling of quantum specific modelling elements. New model extensions can be integrated plugin-based into -the modeler. Read [this guide](doc/quantum-workflow-modeler/editor/plugin/plugin-integration.md) to learn how you can integrate -your own modelling extensions into the modeler. +[![GitHub license](https://img.shields.io/github/license/PlanQK/workflow-modeler)](https://github.com/PlanQK/workflow-modeler/blob/master/LICENSE) +[![Tests](https://github.com/PlanQK/workflow-modeler/actions/workflows/run-npm-test.yml/badge.svg)](https://github.com/PlanQK/workflow-modeler/actions/workflows/run-npm-test.yml) +[![Release](https://img.shields.io/github/v/release/PlanQK/workflow-modeler)](https://img.shields.io/github/v/release/PlanQK/workflow-modeler) -The modeler is implemented as an HTML web component and can be integrated in other web applications as a custom HMTL tag. -Read [this documentation](doc/integration-guide/integration-guide.md) to learn how you can -integrate the modeler in your application and which configuration options and interfaces you can use. +A web-based modeling tool for modeling BPMN 2.0-based quantum workflows. +It uses and extends the [bpmn-js Modeler](https://github.com/bpmn-io/bpmn-js/) of Camunda which is embedded in the User Interface (UI) of the Quantum Workflow Modeler and handles the graphical modeling of workflows. -The implementation of the modeler is located in the [bpmn-q folder](components/bpmn-q). Example Projects to integrate the -modeler in different UI frameworks can be found [here for a Vue.js app](components/bpmn-q-vue) -and [here for an Angular app](components/bpmn-q-angular). +It contains several modeling extensions to the BPMN standard which enable the modeling of quantum workflows. +New model extensions can be integrated plugin-based into the modeler. +Read [this guide](doc/quantum-workflow-modeler/editor/plugin/plugin-integration.md) to learn how you can integrate your own modeling extensions into the modeler. -The Quantum Workflow Modeler is a HTML web component. -The UI components of the modeler are defined with React-js and written in JavaScript. To package the project, webpack is used. +The modeler is implemented as an HTML web component and can be integrated into other web applications as a custom HTML tag. +Read [this documentation](doc/integration-guide/integration-guide.md) to learn how you can integrate the modeler into your application and which configuration options and interfaces you can use. + +The implementation of the modeler is located in the [bpmn-q folder](components/bpmn-q). +Example projects to integrate the modeler in different UI frameworks can be found [here for a Vue.js app](components/bpmn-q-vue) and [here for an Angular app](components/bpmn-q-angular). + +The Quantum Workflow Modeler is an HTML web component. +The UI components of the modeler are defined with React-js and written in JavaScript. +To package the project, webpack is used. The tests of the project use mocha with chai for karma. Refer to the [documentation](doc/README.md) for further information. ## Node Version + The project was created with npm 8.19.2 and node 18.12.1. ## Quickstart @@ -54,9 +57,8 @@ docker run --name workflow-modeler -p 8080:8080 workflow-modeler ## How to use this Library -To use the Quantum Workflow Modeler component in your application you have to install its npm package which is published -via GitHub packages. To access the package, you first [have to register the PlanQK namespace](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package) -to your npm setup and then [authenticate to GitHub](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token). +To use the Quantum Workflow Modeler component in your application you have to install its npm package which is published via GitHub packages. +To access the package, you first [have to register the PlanQK namespace](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package) to your npm setup and then [authenticate to GitHub](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token). A more detailed description can be found [here](doc/integration-guide/integration-guide.md). Then install the npm package with @@ -64,8 +66,8 @@ Then install the npm package with $> npm install --save @planqk/quantum-workflow-modeler ``` -Register the Quantum Workflow Modeler component as a custom HTML tag in the UI framework you are using. The exact steps -depend on the specific framework, but here are guides how you can do that in [Angular](), [Vue.js]() and [plain HTML](). +Register the Quantum Workflow Modeler component as a custom HTML tag in the UI framework you are using. +The exact steps depend on the specific framework, but here are guides how you can do that in [Angular](), [Vue.js]() and [plain HTML](). Use the tag of the component, ```quantum-workflow-modeler``` directly in your HTML ```html @@ -82,9 +84,9 @@ const modelerComponent = document.createElement('quantum-workflow-modeler'); ``` to integrate the modeler component into the UI of your application. -Activate the plugins you want to use in your instance of the modeler by setting the pluginConfig attribute. You can only -set the pluginConfigs attribute if the modelerComponent is already available in the DOM. If you do not do that, the rendering -will fail. +Activate the plugins you want to use in your instance of the modeler by setting the pluginConfig attribute. +You can only set the pluginConfigs attribute if the modelerComponent is already available in the DOM. +If you do not do that, the rendering will fail. ```javascript modelerComponent.pluginConfigs = [ { @@ -102,23 +104,24 @@ modelerComponent.pluginConfigs = [ ] ``` -You can configure the plugins like described [here](doc/quantum-workflow-modeler/editor/plugin/plugin-config.md). The structure -of the config is defined by the plugin and can be looked up in the documentation of the respective plugin. +You can configure the plugins as described [here](doc/quantum-workflow-modeler/editor/plugin/plugin-config.md). +The structure of the config is defined by the plugin and can be looked up in the documentation of the respective plugin. You can add listeners to custom events the Quantum Workflow Modeler triggers for changes in the currently loaded workflow, like saving or loading a workflow. Read the [EventHandler documentation](doc/quantum-workflow-modeler/editor/events/event-handler-doc.md) to learn more about the events of the modeler. ## Development Setup -To set this project up for development clone the repository and open it in your favorite editor. The project code is under -[./components](components) and is split in three parts: Under [bpmn-q](components/bpmn-q) is the actual code of the Quantum -Workflow Modeler. Under [bpmn-q-angular](components/bpmn-q-angular) is an example project with Angular which integrates the -modeler component. Under [bpmn-q-vue](components/bpmn-q-vue) is a simple Vue-js project which integrate the modeler. These -to projects do not contain code of the Quantum Workflow Modeler component. They are used for testing the integration of the -developed component to test and check its compatibility with other UI frameworks. +To set this project up for development, clone the repository and open it in your favorite editor. +The project code is under [./components](components) and is split in three parts: +Under [bpmn-q](components/bpmn-q) is the actual code of the Quantum Workflow Modeler. +Under [bpmn-q-angular](components/bpmn-q-angular) is an example project with Angular which integrates the modeler component. +Under [bpmn-q-vue](components/bpmn-q-vue) is a simple Vue-js project which integrate the modeler. +These to projects do not contain code of the Quantum Workflow Modeler component. +They are used for testing the integration of the developed component to test and check its compatibility with other UI frameworks. -The actual code for development is in [bpmn-q](components/bpmn-q). To set up the cloned project, execute the following -commands under the ./components/bpmn-q directory. +The actual code for development is in [bpmn-q](components/bpmn-q). +To set up the cloned project, execute the following commands under the ./components/bpmn-q directory. 1. Install dependencies ``` npm install @@ -127,7 +130,7 @@ commands under the ./components/bpmn-q directory. 2. Start the Modeler To execute the Quantum Workflow Modeler, a small test website can be run which only contains the modeler component. - To start this website, execute + To start this website, execute: ``` npm run dev ``` @@ -135,7 +138,7 @@ commands under the ./components/bpmn-q directory. 3. Build the Modeler - To build the modeler execute + To build the modeler execute: ``` npm run build ``` @@ -143,7 +146,7 @@ commands under the ./components/bpmn-q directory. 4. Run all Tests - To execute all tests run + To execute all tests run: ``` npm test ``` @@ -155,16 +158,10 @@ commands under the ./components/bpmn-q directory. ## Disclaimer of Warranty -Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its -Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, -without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR -PURPOSE. -You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks -associated with Your exercise of permissions under this License. +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. +You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. ## Haftungsausschluss Dies ist ein Forschungsprototyp. -Die Haftung für entgangenen Gewinn, Produktionsausfall, Betriebsunterbrechung, entgangene Nutzungen, Verlust von Daten -und Informationen, Finanzierungsaufwendungen sowie sonstige Vermögens- und Folgeschäden ist, außer in Fällen von grober -Fahrlässigkeit, Vorsatz und Personenschäden, ausgeschlossen. +Die Haftung für entgangenen Gewinn, Produktionsausfall, Betriebsunterbrechung, entgangene Nutzungen, Verlust von Daten und Informationen, Finanzierungsaufwendungen sowie sonstige Vermögens- und Folgeschäden ist, außer in Fällen von grober Fahrlässigkeit, Vorsatz und Personenschäden, ausgeschlossen. diff --git a/components/bpmn-q/.eslintignore b/components/bpmn-q/.eslintignore new file mode 100644 index 00000000..d70ebaa1 --- /dev/null +++ b/components/bpmn-q/.eslintignore @@ -0,0 +1 @@ +public \ No newline at end of file diff --git a/components/bpmn-q/.eslintrc.js b/components/bpmn-q/.eslintrc.js deleted file mode 100644 index ee100eb0..00000000 --- a/components/bpmn-q/.eslintrc.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es2021": true, - "commonjs": true, - "node": true, - "mocha": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended" - ], - "overrides": [ - ], - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - }, - "plugins": [ - "react" - ], - "rules": { - "semi": [2, "always"], - "react/prop-types": "off", - "no-prototype-builtins": "off", - "react/jsx-key": "off", - "no-unused-vars": "off", - "no-useless-escape": "off", - } -}; diff --git a/components/bpmn-q/.eslintrc.json b/components/bpmn-q/.eslintrc.json new file mode 100644 index 00000000..3fbe275d --- /dev/null +++ b/components/bpmn-q/.eslintrc.json @@ -0,0 +1,22 @@ +{ + "env": { + "browser": true, + "es2021": true, + "commonjs": true, + "node": true, + "mocha": true + }, + "extends": ["eslint:recommended", "plugin:react/recommended"], + "overrides": [], + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": ["react"], + "rules": { + "semi": [2, "always"], + "react/prop-types": "off", + "no-prototype-builtins": "off", + "react/jsx-key": "off" + } +} diff --git a/components/bpmn-q/.prettierignore b/components/bpmn-q/.prettierignore new file mode 100644 index 00000000..79b158cb Binary files /dev/null and b/components/bpmn-q/.prettierignore differ diff --git a/components/bpmn-q/.prettierrc.json b/components/bpmn-q/.prettierrc.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/components/bpmn-q/.prettierrc.json @@ -0,0 +1 @@ +{} diff --git a/components/bpmn-q/README.md b/components/bpmn-q/README.md index 4b89baad..a7987a45 100644 --- a/components/bpmn-q/README.md +++ b/components/bpmn-q/README.md @@ -1,15 +1,19 @@ # Quantum Workflow Modeler - HTML Web Component -This project contains the HTML web component for the Quantum Workflow Modeler and its implementation. + +This project contains the HTML web component for the Quantum Workflow Modeler and its implementation. ## Node Version + The project was created with npm 8.19.2 and node 18.12.1. ## Development Setup -To set this project up for development clone the repository and open it in your favorite editor. +To set this project up for development clone the repository and open it in your favorite editor. Execute the following commands under this directory: + ### Install dependencies + ``` npm install ``` @@ -18,30 +22,37 @@ npm install To execute the Quantum Workflow Modeler, a small test website can be run which only contains the modeler component. To start this website, execute + ``` npm run dev ``` + This will start a webpack dev server which loads the website specified in the [index.html file](components/bpmn-q/public/index.html) ### Build the Modeler To build the modeler execute + ``` npm run build ``` + This will build the modeler component with webpack into a single js file in the [public directory](components/bpmn-q/public). ### Run all Tests To execute all tests run + ``` -npm test +npm test ``` - This will run all mocha test specified in [karma.conf.js](components/bpmn-q/karma.conf.js) with karma. + +This will run all mocha test specified in [karma.conf.js](components/bpmn-q/karma.conf.js) with karma. ### External Endpoints - Some components of the modeler component need external endpoints to work properly. Refer to [this guide](doc/devloper-setup/developer-setup.md) - for setting up all used endpoints. + +Some components of the modeler component need external endpoints to work properly. Refer to [this guide](doc/devloper-setup/developer-setup.md) +for setting up all used endpoints. ## Disclaimer of Warranty @@ -57,4 +68,4 @@ associated with Your exercise of permissions under this License. Dies ist ein Forschungsprototyp. Die Haftung für entgangenen Gewinn, Produktionsausfall, Betriebsunterbrechung, entgangene Nutzungen, Verlust von Daten und Informationen, Finanzierungsaufwendungen sowie sonstige Vermögens- und Folgeschäden ist, außer in Fällen von grober -Fahrlässigkeit, Vorsatz und Personenschäden, ausgeschlossen. \ No newline at end of file +Fahrlässigkeit, Vorsatz und Personenschäden, ausgeschlossen. diff --git a/components/bpmn-q/babel.config.js b/components/bpmn-q/babel.config.js index c4b9486f..1a58db7b 100644 --- a/components/bpmn-q/babel.config.js +++ b/components/bpmn-q/babel.config.js @@ -1,31 +1,31 @@ module.exports = { - presets: [ + presets: [ + [ + "@babel/preset-env", + { + modules: false, + }, + ], + "@babel/preset-react", + ], + plugins: [ + "@babel/plugin-transform-runtime", + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-proposal-class-properties", + ], + env: { + production: { + only: ["src"], + plugins: [ [ - "@babel/preset-env", - { - modules: false - } + "transform-react-remove-prop-types", + { + removeImport: true, + }, ], - "@babel/preset-react" - ], - plugins: [ - "@babel/plugin-transform-runtime", - "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-proposal-class-properties" - ], - env: { - production: { - only: ["src"], - plugins: [ - [ - "transform-react-remove-prop-types", - { - removeImport: true - } - ], - "@babel/plugin-transform-react-inline-elements", - "@babel/plugin-transform-react-constant-elements" - ] - } - } -}; \ No newline at end of file + "@babel/plugin-transform-react-inline-elements", + "@babel/plugin-transform-react-constant-elements", + ], + }, + }, +}; diff --git a/components/bpmn-q/bpmnlint-plugin-custom/index.js b/components/bpmn-q/bpmnlint-plugin-custom/index.js index 450b234d..f4c2403d 100644 --- a/components/bpmn-q/bpmnlint-plugin-custom/index.js +++ b/components/bpmn-q/bpmnlint-plugin-custom/index.js @@ -1,15 +1,14 @@ module.exports = { configs: { recommended: { - rules: { - } + rules: {}, }, all: { rules: { - 'quantme-tasks': 'warn', - 'subprocess-required-start-event': 'warn', - 'subprocess-connected-end-event': 'warn' - } - } - } -} \ No newline at end of file + "quantme-tasks": "warn", + "subprocess-required-start-event": "warn", + "subprocess-connected-end-event": "warn", + }, + }, + }, +}; diff --git a/components/bpmn-q/bpmnlint-plugin-custom/rules/quantme-tasks.js b/components/bpmn-q/bpmnlint-plugin-custom/rules/quantme-tasks.js index b986503d..24c6a3b1 100644 --- a/components/bpmn-q/bpmnlint-plugin-custom/rules/quantme-tasks.js +++ b/components/bpmn-q/bpmnlint-plugin-custom/rules/quantme-tasks.js @@ -1,20 +1,22 @@ -let QuantMEAttributeChecker = require('../../modeler-component/extensions/quantme/replacement/QuantMEAttributeChecker'); +let QuantMEAttributeChecker = require("../../modeler-component/extensions/quantme/replacement/QuantMEAttributeChecker"); /** * Rule that reports QuantME tasks for which no suited replacement model exists */ -module.exports = function() { - +module.exports = function () { function check(node, reporter) { - if (node.$type && node.$type.startsWith('quantme:')) { + if (node.$type && node.$type.startsWith("quantme:")) { if (!QuantMEAttributeChecker.requiredAttributesAvailable(node)) { - reporter.report(node.id, 'Not all required attributes are set. Unable to replace task!'); + reporter.report( + node.id, + "Not all required attributes are set. Unable to replace task!" + ); return; } } } return { - check: check + check: check, }; -}; \ No newline at end of file +}; diff --git a/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-connected-end-event.js b/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-connected-end-event.js index d7f2740e..3e50dc44 100644 --- a/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-connected-end-event.js +++ b/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-connected-end-event.js @@ -1,46 +1,41 @@ -const { - is, - isAny -} = require('bpmnlint-utils'); - +const { is, isAny } = require("bpmnlint-utils"); /** * A rule that checks the presence of an end event per scope. */ module.exports = function () { - function hasEndEvent(node) { const flowElements = node.flowElements || []; - return ( - flowElements.some(node => is(node, 'bpmn:EndEvent')) - ); + return flowElements.some((node) => is(node, "bpmn:EndEvent")); } function hasConnectedEndEvent(node) { const flowElements = node.flowElements || []; - return ( - flowElements.some(node => { const incomingflow = node.incoming || []; return is(node, 'bpmn:EndEvent') && incomingflow.length === 0; }) - ); - + return flowElements.some((node) => { + const incomingflow = node.incoming || []; + return is(node, "bpmn:EndEvent") && incomingflow.length === 0; + }); } function check(node, reporter) { - console.log(node) - if (!isAny(node, ['bpmn:SubProcess'])) { + console.log(node); + if (!isAny(node, ["bpmn:SubProcess"])) { return; } if (!hasEndEvent(node)) { - - reporter.report(node.id, 'Subprocess is missing end event'); + reporter.report(node.id, "Subprocess is missing end event"); } if (hasConnectedEndEvent(node)) { - reporter.report(node.id, 'Each end event must have at least one incoming flow'); + reporter.report( + node.id, + "Each end event must have at least one incoming flow" + ); } } return { check }; -}; \ No newline at end of file +}; diff --git a/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-required-start-event.js b/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-required-start-event.js index bbb06d17..5d83043a 100644 --- a/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-required-start-event.js +++ b/components/bpmn-q/bpmnlint-plugin-custom/rules/subprocess-required-start-event.js @@ -1,38 +1,33 @@ -const { - is -} = require('bpmnlint-utils'); - +const { is } = require("bpmnlint-utils"); /** * A rule that checks that start events inside a normal sub-processes * are blank (do not have an event definition). */ module.exports = function () { - function check(node, reporter) { - - if (!is(node, 'bpmn:SubProcess') || node.triggeredByEvent) { + if (!is(node, "bpmn:SubProcess") || node.triggeredByEvent) { return; } const flowElements = node.flowElements || []; flowElements.forEach(function (flowElement) { - - if (!is(flowElement, 'bpmn:StartEvent')) { + if (!is(flowElement, "bpmn:StartEvent")) { return false; } const eventDefinitions = flowElement.eventDefinitions || []; if (eventDefinitions.length > 0) { - reporter.report(flowElement.id, 'Start event must be blank', ['eventDefinitions']); + reporter.report(flowElement.id, "Start event must be blank", [ + "eventDefinitions", + ]); } }); } return { - check + check, }; - -}; \ No newline at end of file +}; diff --git a/components/bpmn-q/client/index.js b/components/bpmn-q/client/index.js index 01847a26..22aeb18d 100644 --- a/components/bpmn-q/client/index.js +++ b/components/bpmn-q/client/index.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Institute of Architecture of Application Systems - + * Copyright (c) 2023 Institute of Architecture of Application Systems - * University of Stuttgart * * This program and the accompanying materials are made available under the @@ -9,14 +9,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { registerBpmnJSPlugin } from 'camunda-modeler-plugin-helpers'; +import { registerBpmnJSPlugin } from "camunda-modeler-plugin-helpers"; -import customLinterConfig from '../.bpmnlintrc'; +import customLinterConfig from "../.bpmnlintrc"; registerBpmnJSPlugin({ __init__: [ - function(linting) { + function (linting) { linting.setLinterConfig(customLinterConfig); - } - ] + }, + ], }); diff --git a/components/bpmn-q/karma.conf.js b/components/bpmn-q/karma.conf.js index ebf95197..27a9c23b 100644 --- a/components/bpmn-q/karma.conf.js +++ b/components/bpmn-q/karma.conf.js @@ -1,66 +1,65 @@ // Karma configuration -const webpackConfig = require('./webpack.config.js'); +const webpackConfig = require("./webpack.config.js"); module.exports = function (config) { - config.set({ + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "", - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', + // frameworks to use + // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter + frameworks: ["mocha", "webpack"], - // frameworks to use - // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter - frameworks: ['mocha', 'webpack'], + // list of files / patterns to load in the browser + files: [ + "test/tests/editor/configurations.spec.js", + "test/tests/editor/editor.spec.js", + "test/tests/editor/plugin.spec.js", + "test/tests/planqk/planqk-transformation.spec.js", + "test/tests/editor/utils/modelling-util.spec.js", + "test/tests/qhana/qhana-plugin-config.spec.js", + "test/tests/qhana/qhana-service-configs.spec.js", + "test/tests/quantme/quantme-transformation.spec.js", + "test/tests/quantme/data-object-configs.spec.js", + "test/tests/quantme/quantme-config.spec.js", + "test/tests/opentosca/opentosca-config.spec.js", + "test/tests/opentosca/deployment-utils.spec.js", + "test/tests/opentosca/deployment-model-renderer.spec.js", + "test/tests/dataflow/data-flow-transformation.spec.js", + "test/tests/dataflow/data-flow-plugin-config.spec.js", + "test/tests/dataflow/data-flow-configurations-endpoint.spec.js", + "test/tests/dataflow/data-flow-palette.spec.js", + "test/tests/dataflow/data-flow-replace-menu.spec.js", + ], - // list of files / patterns to load in the browser - files: [ - 'test/tests/editor/configurations.spec.js', - 'test/tests/editor/editor.spec.js', - 'test/tests/editor/plugin.spec.js', - 'test/tests/planqk/planqk-transformation.spec.js', - 'test/tests/editor/utils/modelling-util.spec.js', - 'test/tests/qhana/qhana-plugin-config.spec.js', - 'test/tests/qhana/qhana-service-configs.spec.js', - 'test/tests/quantme/quantme-transformation.spec.js', - 'test/tests/quantme/data-object-configs.spec.js', - 'test/tests/quantme/quantme-config.spec.js', - 'test/tests/opentosca/opentosca-config.spec.js', - 'test/tests/opentosca/deployment-utils.spec.js', - 'test/tests/opentosca/deployment-model-renderer.spec.js', - 'test/tests/dataflow/data-flow-transformation.spec.js', - 'test/tests/dataflow/data-flow-plugin-config.spec.js', - 'test/tests/dataflow/data-flow-configurations-endpoint.spec.js', - 'test/tests/dataflow/data-flow-palette.spec.js', - 'test/tests/dataflow/data-flow-replace-menu.spec.js', - ], + // list of files / patterns to exclude + exclude: [], - // list of files / patterns to exclude - exclude: [], + // preprocess matching files before serving them to the browser + // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor + preprocessors: { + "test/**/*.spec.js": ["webpack"], + }, - // preprocess matching files before serving them to the browser - // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor - preprocessors: { - 'test/**/*.spec.js': ['webpack'] - }, + webpack: webpackConfig, - webpack: webpackConfig, + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, + // start these browsers + // available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher + browsers: ["ChromeHeadless"], - // start these browsers - // available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher - browsers: ['ChromeHeadless'], + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true, + // Concurrency level + // how many browser instances should be started simultaneously + concurrency: 1, - // Concurrency level - // how many browser instances should be started simultaneously - concurrency: 1, - - mochaReporter: { - output: "minimal" - }, - }); -}; \ No newline at end of file + mochaReporter: { + output: "minimal", + }, + }); +}; diff --git a/components/bpmn-q/modeler-component/QuantumWorkflowModeler.js b/components/bpmn-q/modeler-component/QuantumWorkflowModeler.js index 35728c0d..d923a455 100644 --- a/components/bpmn-q/modeler-component/QuantumWorkflowModeler.js +++ b/components/bpmn-q/modeler-component/QuantumWorkflowModeler.js @@ -1,25 +1,36 @@ -import 'bpmn-js/dist/assets/diagram-js.css'; -import 'bpmn-js-properties-panel/dist/assets/element-templates.css'; -import 'bpmn-js-properties-panel/dist/assets/properties-panel.css'; -import './editor/resources/styling/modeler.css'; -import './editor/resources/styling/editor-ui.css'; -import './editor/ui/notifications/Notifications.css'; -import './editor/ui/notifications/Notification.css'; -import './editor/resources/styling/camunda-styles/style.css'; -import 'bpmn-js-bpmnlint/dist/assets/css/bpmn-js-bpmnlint.css'; -import './modeler.css'; - -import React from 'react'; -import { createRoot } from 'react-dom/client'; +import "bpmn-js/dist/assets/diagram-js.css"; +import "bpmn-js-properties-panel/dist/assets/element-templates.css"; +import "bpmn-js-properties-panel/dist/assets/properties-panel.css"; +import "./editor/resources/styling/modeler.css"; +import "./editor/resources/styling/editor-ui.css"; +import "./editor/ui/notifications/Notifications.css"; +import "./editor/ui/notifications/Notification.css"; +import "./editor/resources/styling/camunda-styles/style.css"; +import "bpmn-js-bpmnlint/dist/assets/css/bpmn-js-bpmnlint.css"; +import "./modeler.css"; + +import React from "react"; +import { createRoot } from "react-dom/client"; import ButtonToolbar from "./editor/ui/ButtonToolbar"; -import { createNewDiagram, loadDiagram, setAutoSaveInterval } from "./editor/util/IoUtilities"; +import { + createNewDiagram, + loadDiagram, + setAutoSaveInterval, +} from "./editor/util/IoUtilities"; import NotificationHandler from "./editor/ui/notifications/NotificationHandler"; import { createModeler, getModeler } from "./editor/ModelerHandler"; -import { getPluginButtons, getTransformationButtons } from "./editor/plugin/PluginHandler"; -import { getPluginConfig, setPluginConfig } from "./editor/plugin/PluginConfigHandler"; -import * as editorConfig from './editor/config/EditorConfigManager'; -import { initEditorEventHandler } from './editor/events/EditorEventHandler'; -import $ from 'jquery'; +import { + getPluginButtons, + getTransformationButtons, +} from "./editor/plugin/PluginHandler"; +import { + getPluginConfig, + setPluginConfig, +} from "./editor/plugin/PluginConfigHandler"; +import * as editorConfig from "./editor/config/EditorConfigManager"; +import { initEditorEventHandler } from "./editor/events/EditorEventHandler"; +import $ from "jquery"; +import { edit } from "ace-builds"; /** * The Quantum Workflow modeler HTML web component which contains the bpmn-js modeler to model BPMN diagrams, an editor @@ -27,54 +38,53 @@ import $ from 'jquery'; * the modelling of quantum workflows. */ export class QuantumWorkflowModeler extends HTMLElement { - - workflowModel; - constructor() { - super(); - } - - connectedCallback() { - - // create the HTML structure of the component - this.setInnerHtml(); - - // add listener for post messages containing a workflow to load into the modeler - const self = this; - window.addEventListener("message", function (event) { - - // check if the message contains a correctly formatted workflow - if (event.origin === window.location.href.replace(/\/$/, '') - && event.data && event.data.workflow && typeof event.data.workflow === 'string' && event.data.workflow.startsWith('')) { - - const xmlString = event.data.workflow; - self.workflowModel = xmlString; - - // open sent workflow and save its file name - editorConfig.setFileName(event.data.name); - loadDiagram(xmlString, getModeler()).then(); - } - }); - - // wait until shadow dom is loaded - requestAnimationFrame(() => { - - // start the bpmn-js modeler and render the React components - this.startModeler(); - }); - - const beforeUnloadListener = (event) => { - event.preventDefault(); - return event.returnValue = ''; - }; - addEventListener("beforeunload", beforeUnloadListener, { capture: true }); - } - - - /** - * Set up the inner structure of the component - */ - setInnerHtml() { - this.innerHTML = ` + workflowModel; + constructor() { + super(); + } + + connectedCallback() { + // create the HTML structure of the component + this.setInnerHtml(); + + // add listener for post messages containing a workflow to load into the modeler + const self = this; + window.addEventListener("message", function (event) { + // check if the message contains a correctly formatted workflow + if ( + event.origin === window.location.href.replace(/\/$/, "") && + event.data && + event.data.workflow && + typeof event.data.workflow === "string" && + event.data.workflow.startsWith('') + ) { + const xmlString = event.data.workflow; + self.workflowModel = xmlString; + + // open sent workflow and save its file name + editorConfig.setFileName(event.data.name); + loadDiagram(xmlString, getModeler()).then(); + } + }); + + // wait until shadow dom is loaded + requestAnimationFrame(() => { + // start the bpmn-js modeler and render the React components + this.startModeler(); + }); + + const beforeUnloadListener = (event) => { + event.preventDefault(); + return (event.returnValue = ""); + }; + addEventListener("beforeunload", beforeUnloadListener, { capture: true }); + } + + /** + * Set up the inner structure of the component + */ + setInnerHtml() { + this.innerHTML = `