From 7240c7046f4a7dd932f0a20439048514a1e5d786 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 24 Oct 2023 12:53:16 +0200 Subject: [PATCH 1/5] Move deployment models to separate group to enable combining them with connectors --- .../camunda-utils/ImplementationTypeUtils.js | 79 ---------------- .../opentosca/modeling/OpenTOSCARenderer.js | 11 +++ .../properties-provider/ArtifactUpload.js | 11 +++ .../modeling/properties-provider/Connector.js | 11 ++- .../properties-provider/Deployment.js | 26 ++--- .../DeploymentModelProps.js | 94 +++++++++++++++++++ .../DmnImplementationProps.js | 11 +++ .../ImplementationProps.js | 76 +++------------ .../ImplementationTypeProps.js | 38 +++----- .../ServiceTaskPropertiesProvider.js | 50 +++++++++- .../properties-provider/YamlUpload.js | 11 +++ 11 files changed, 226 insertions(+), 192 deletions(-) create mode 100644 components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js diff --git a/components/bpmn-q/modeler-component/editor/util/camunda-utils/ImplementationTypeUtils.js b/components/bpmn-q/modeler-component/editor/util/camunda-utils/ImplementationTypeUtils.js index 7c50566a..2085d5a6 100644 --- a/components/bpmn-q/modeler-component/editor/util/camunda-utils/ImplementationTypeUtils.js +++ b/components/bpmn-q/modeler-component/editor/util/camunda-utils/ImplementationTypeUtils.js @@ -42,15 +42,6 @@ export function isExternalCapable(element) { return is(element, "camunda:ExternalCapable"); } -/** - * Returns 'true' - * - * @return {boolean} true - */ -export function isDeploymentCapable() { - return true; -} - /** * getServiceTaskLikeBusinessObject - Get a 'camunda:ServiceTaskLike' business object. * @@ -78,76 +69,6 @@ export function getServiceTaskLikeBusinessObject(element) { return isServiceTaskLike(element) && getBusinessObject(element); } -// /** -// * Returns the implementation type of the given element. -// * -// * Possible implementation types are: -// * - dmn -// * - connector -// * - external -// * - class -// * - expression -// * - delegateExpression -// * - script -// * - or undefined, when no matching implementation type is found -// * -// * @param {djs.model.Base} element -// * -// * @return {String} the implementation type -// */ -// export function getImplementationType(element) { -// -// const businessObject = ( -// getListenerBusinessObject(element) || -// getServiceTaskLikeBusinessObject(element) -// ); -// -// if (!businessObject) { -// return; -// } -// -// if (isDmnCapable(businessObject)) { -// const decisionRef = businessObject.get('camunda:decisionRef'); -// if (typeof decisionRef !== 'undefined') { -// return 'dmn'; -// } -// } -// -// if (isServiceTaskLike(businessObject)) { -// const connectors = getExtensionElementsList(businessObject, 'camunda:Connector'); -// if (connectors.length) { -// return 'connector'; -// } -// } -// -// if (isExternalCapable(businessObject)) { -// const type = businessObject.get('camunda:type'); -// if (type === 'external') { -// return 'external'; -// } -// } -// -// const cls = businessObject.get('camunda:class'); -// if (typeof cls !== 'undefined') { -// return 'class'; -// } -// -// const expression = businessObject.get('camunda:expression'); -// if (typeof expression !== 'undefined') { -// return 'expression'; -// } -// -// const delegateExpression = businessObject.get('camunda:delegateExpression'); -// if (typeof delegateExpression !== 'undefined') { -// return 'delegateExpression'; -// } -// -// const script = businessObject.get('script'); -// if (typeof script !== 'undefined') { -// return 'script'; -// } -// } - export function isListener(element) { return this.isTaskListener(element) || this.isExecutionListener(element); } diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARenderer.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARenderer.js index 28861efa..e7006fe1 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARenderer.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/OpenTOSCARenderer.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { connectRectangles } from "diagram-js/lib/layout/ManhattanLayout"; import { createLine } from "diagram-js/lib/util/RenderUtil"; diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ArtifactUpload.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ArtifactUpload.js index 49b30800..c1754b87 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ArtifactUpload.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ArtifactUpload.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { HeaderButton } from "@bpmn-io/properties-panel"; import React from "react"; import ArtifactModal from "./ArtifactUploadModal"; diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js index 6a851c30..0c8a02af 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Connector.js @@ -1,8 +1,3 @@ -import { SelectEntry } from "@bpmn-io/properties-panel"; -import React from "@bpmn-io/properties-panel/preact/compat"; -import { useService } from "bpmn-js-properties-panel"; -import { getModeler } from "../../../../editor/ModelerHandler"; - /** * Copyright (c) 2023 Institute of Architecture of Application Systems - * University of Stuttgart @@ -13,6 +8,12 @@ import { getModeler } from "../../../../editor/ModelerHandler"; * * SPDX-License-Identifier: Apache-2.0 */ + +import { SelectEntry } from "@bpmn-io/properties-panel"; +import React from "@bpmn-io/properties-panel/preact/compat"; +import { useService } from "bpmn-js-properties-panel"; +import { getModeler } from "../../../../editor/ModelerHandler"; + const yaml = require("js-yaml"); /** * Entry to display the endpoints of the uploaded openapi specification for BPMN service task. diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Deployment.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Deployment.js index c668c841..2a451816 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Deployment.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/Deployment.js @@ -1,8 +1,3 @@ -import { SelectEntry } from "@bpmn-io/properties-panel"; -import React from "@bpmn-io/properties-panel/preact/compat"; -import { useService } from "bpmn-js-properties-panel"; -import { getImplementationType } from "../../../quantme/utilities/ImplementationTypeHelperExtension"; - /** * Copyright (c) 2023 Institute of Architecture of Application Systems - * University of Stuttgart @@ -14,6 +9,10 @@ import { getImplementationType } from "../../../quantme/utilities/Implementation * SPDX-License-Identifier: Apache-2.0 */ +import { SelectEntry } from "@bpmn-io/properties-panel"; +import React from "@bpmn-io/properties-panel/preact/compat"; +import { useService } from "bpmn-js-properties-panel"; + const jquery = require("jquery"); const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull"; @@ -28,7 +27,7 @@ export function Deployment({ element, translate, wineryEndpoint }) { const debounce = useService("debounceInput"); const selectOptions = function () { - const arrValues = []; + const arrValues = [{ label: "No CSAR", value: undefined }]; jquery.ajax({ url: wineryEndpoint + "/servicetemplates/?grouped", method: "GET", @@ -53,9 +52,6 @@ export function Deployment({ element, translate, wineryEndpoint }) { }, async: false, }); - if (arrValues.length === 0) { - arrValues.push({ label: "No CSARs available", value: "" }); - } return arrValues; }; @@ -65,20 +61,16 @@ export function Deployment({ element, translate, wineryEndpoint }) { const setValue = function (value) { return modeling.updateProperties(element, { - deploymentModelUrl: value || "", + deploymentModelUrl: value, }); }; - const validate = function (values) { - return values === undefined || values === "" - ? translate("Must provide a CSAR") - : ""; + const validate = function () { + return ""; }; const hidden = function () { - const implType = getImplementationType(element); - console.log("getImplementationType returns " + implType); - return !(implType === "deploymentModel"); + return false; }; return ( diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js new file mode 100644 index 00000000..ea87639b --- /dev/null +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils"; +import { ArtifactUpload } from "./ArtifactUpload"; +import { isTextFieldEntryEdited } from "@bpmn-io/properties-panel"; +import { Deployment } from "./Deployment"; +import { YamlUpload } from "./YamlUpload"; +import { Connector } from "./Connector"; +import yaml from "js-yaml"; + +const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull"; + +/** + * Properties group for service tasks. Extends the original implementation by adding a new selection option to the + * implementation entry: deployment. + * + * @param props + * @return {{component: function(*): preact.VNode, isEdited: function(*): *, id: string}[]|*[]} + * @constructor + */ +export function DeploymentModelProps(props) { + const { element, wineryEndpoint, translate } = props; + + // deployment models can only be defined for ServiceTasks + if (!getServiceTaskLikeBusinessObject(element)) { + return []; + } + + // list of configuration options + const entries = []; + + // field to define deployment models + entries.push({ + id: "deployment", + element, + translate, + wineryEndpoint, + component: Deployment, + isEdited: isTextFieldEntryEdited, + }); + + // field to upload an OpenAPI spec for automated connector generation + entries.push({ + id: "yamlUpload", + component: YamlUpload, + isEdited: isTextFieldEntryEdited, + }); + if ( + element.businessObject.deploymentModelUrl && + !element.businessObject.deploymentModelUrl.includes( + encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) + ) && + element.businessObject.yaml !== undefined + ) { + const urls = extractUrlsFromYaml(element.businessObject.yaml); + entries.push({ + id: "connector", + element, + translate, + urls, + component: Connector, + isEdited: isTextFieldEntryEdited, + }); + } + + entries.push({ + id: "artifactUpload", + element, + translate, + component: ArtifactUpload, + isEdited: isTextFieldEntryEdited, + }); + + return entries; +} + +function extractUrlsFromYaml(content) { + const doc = yaml.load(content); + + // Extract URLs from paths + const paths = Object.keys(doc.paths); + return paths.map((path) => { + return `${path}`; + }); +} diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DmnImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DmnImplementationProps.js index a380f564..9e2fc516 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DmnImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DmnImplementationProps.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { getBusinessObject } from "bpmn-js/lib/util/ModelUtil"; import { diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js index 63b3e8c2..803f2b2d 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { isTextFieldEntryEdited, TextFieldEntry, @@ -8,24 +19,16 @@ import { useService } from "bpmn-js-properties-panel"; import { getImplementationType } from "../../../quantme/utilities/ImplementationTypeHelperExtension"; import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils"; import { getExtensionElementsList } from "../../../../editor/util/camunda-utils/ExtensionElementsUtil"; -import { Deployment } from "./Deployment"; -import { Connector } from "./Connector"; -import { YamlUpload } from "./YamlUpload"; -import { ArtifactUpload } from "./ArtifactUpload"; - -const yaml = require("js-yaml"); -const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull"; /** - * Properties group for service tasks. Extends the original implementation by adding a new selection option to the - * implementation entry: deployment. + * Properties group for implementations of service tasks. * - * @param props + * @param element * @return {{component: function(*): preact.VNode, isEdited: function(*): *, id: string}[]|*[]} * @constructor */ -export function ImplementationProps(props) { - const { element, wineryEndpoint, translate } = props; +export function ImplementationProps(element) { + console.log("Rendering implementation properties for ServiceTask!"); if (!getServiceTaskLikeBusinessObject(element)) { return []; @@ -76,60 +79,11 @@ export function ImplementationProps(props) { component: ConnectorId, isEdited: isTextFieldEntryEdited, }); - - // custom extension - } else if (implementationType === "deploymentModel") { - entries.push({ - id: "deployment", - element, - translate, - wineryEndpoint, - component: Deployment, - isEdited: isTextFieldEntryEdited, - }); - entries.push({ - id: "yamlUpload", - component: YamlUpload, - isEdited: isTextFieldEntryEdited, - }); - if ( - !element.businessObject.deploymentModelUrl.includes( - encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) - ) && - element.businessObject.yaml !== undefined - ) { - const urls = extractUrlsFromYaml(element.businessObject.yaml); - entries.push({ - id: "connector", - element, - translate, - urls, - component: Connector, - isEdited: isTextFieldEntryEdited, - }); - } - entries.push({ - id: "artifactUpload", - element, - translate, - component: ArtifactUpload, - isEdited: isTextFieldEntryEdited, - }); } return entries; } -function extractUrlsFromYaml(content) { - const doc = yaml.load(content); - - // Extract URLs from paths - const paths = Object.keys(doc.paths); - return paths.map((path) => { - return `${path}`; - }); -} - export function JavaClass(props) { const { element, diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationTypeProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationTypeProps.js index 5a8f74b6..f403a103 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationTypeProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationTypeProps.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { sortBy, without } from "min-dash"; import { SelectEntry, isSelectEntryEdited } from "@bpmn-io/properties-panel"; @@ -5,7 +16,6 @@ import { useService } from "bpmn-js-properties-panel"; import { createElement } from "../../../../editor/util/camunda-utils/ElementUtil"; import { getServiceTaskLikeBusinessObject, - isDeploymentCapable, isDmnCapable, isExternalCapable, isServiceTaskLike, @@ -39,8 +49,7 @@ const IMPLEMENTATION_TYPE_NONE_LABEL = "", IMPLEMENTATION_TYPE_DELEGATE_LABEL = "Delegate expression", IMPLEMENTATION_TYPE_DMN_LABEL = "DMN", IMPLEMENTATION_TYPE_EXTERNAL_LABEL = "External", - IMPLEMENTATION_TYPE_CONNECTOR_LABEL = "Connector", - IMPLEMENTATION_TYPE_DEPLOYMENT_LABEL = "Deployment Model"; + IMPLEMENTATION_TYPE_CONNECTOR_LABEL = "Connector"; export function ImplementationTypeProps() { return [ @@ -172,21 +181,6 @@ function ImplementationType(props) { } } - // (5) deployment - if (isDeploymentCapable(businessObject)) { - updatedProperties = { - ...updatedProperties, - "opentosca:deploymentModelUrl": undefined, - }; - - if (value === "deploymentModel") { - updatedProperties = { - ...updatedProperties, - "opentosca:deploymentModelUrl": "", - }; - } - } - // (5) collect all property updates commands.push( UpdateModdlePropertiesCommand(element, businessObject, updatedProperties) @@ -233,14 +227,6 @@ function ImplementationType(props) { }); } - // add deployment - if (isDeploymentCapable(businessObject)) { - options.push({ - value: "deploymentModel", - label: translate(IMPLEMENTATION_TYPE_DEPLOYMENT_LABEL), - }); - } - return sortByPriority(options); }; diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js index 9a1bdc4a..404d24b8 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js @@ -1,6 +1,18 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { ImplementationProps } from "./ImplementationProps"; import { Group } from "@bpmn-io/properties-panel"; import { getWineryEndpoint } from "../../framework-config/config-manager"; +import { DeploymentModelProps } from "./DeploymentModelProps"; const LOW_PRIORITY = 500; @@ -33,7 +45,12 @@ export default function ServiceTaskPropertiesProvider( return function (groups) { // update ServiceTasks with the deployment extension if (element.type && element.type === "bpmn:ServiceTask") { - groups[2] = ImplementationGroup(element, injector, getWineryEndpoint()); + groups[2] = ImplementationGroup(element, injector); + groups[3] = DeploymentModelGroup( + element, + injector, + getWineryEndpoint() + ); } return groups; }; @@ -54,18 +71,43 @@ ServiceTaskPropertiesProvider.$inject = [ * * @param element The element to show the properties for. * @param injector The injector of the bpmn-js modeler - * @param wineryEndpoint The winery endpoint of the QuantME plugin * @return {null|{component: ((function(*): preact.VNode)|*), entries: *[], label, id: string}} * @constructor */ -function ImplementationGroup(element, injector, wineryEndpoint) { +function ImplementationGroup(element, injector) { const translate = injector.get("translate"); const group = { label: translate("Implementation"), id: "CamundaPlatform__Implementation", component: Group, - entries: [...ImplementationProps({ element, wineryEndpoint, translate })], + entries: [...ImplementationProps(element)], + }; + + if (group.entries.length) { + return group; + } + + return null; +} + +/** + * Properties group showing options to define deployment models for service tasks. + * + * @param element The element to show the properties for. + * @param injector The injector of the bpmn-js modeler + * @param wineryEndpoint The winery endpoint of the QuantME plugin + * @return {null|{component: ((function(*): preact.VNode)|*), entries: *[], label, id: string}} + * @constructor + */ +function DeploymentModelGroup(element, injector, wineryEndpoint) { + const translate = injector.get("translate"); + + const group = { + label: translate("Deployment Models"), + id: "CamundaPlatform__DeploymentModels", + component: Group, + entries: [...DeploymentModelProps({ element, wineryEndpoint, translate })], }; if (group.entries.length) { diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/YamlUpload.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/YamlUpload.js index 1bc556a6..8d24cf43 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/YamlUpload.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/YamlUpload.js @@ -1,3 +1,14 @@ +/** + * Copyright (c) 2023 Institute of Architecture of Application Systems - + * University of Stuttgart + * + * This program and the accompanying materials are made available under the + * terms the Apache Software License 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: Apache-2.0 + */ + import { HeaderButton } from "@bpmn-io/properties-panel"; import { useService } from "bpmn-js-properties-panel"; import React from "react"; From 7a119d3a28d42907236385109a982f5cb9520c8f Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 24 Oct 2023 13:05:25 +0200 Subject: [PATCH 2/5] Move Yaml Upload Button to Connector menu --- .../modeling/properties-provider/DeploymentModelProps.js | 7 ------- .../modeling/properties-provider/ImplementationProps.js | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js index ea87639b..bbfc40c8 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js @@ -13,7 +13,6 @@ import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camund import { ArtifactUpload } from "./ArtifactUpload"; import { isTextFieldEntryEdited } from "@bpmn-io/properties-panel"; import { Deployment } from "./Deployment"; -import { YamlUpload } from "./YamlUpload"; import { Connector } from "./Connector"; import yaml from "js-yaml"; @@ -48,12 +47,6 @@ export function DeploymentModelProps(props) { isEdited: isTextFieldEntryEdited, }); - // field to upload an OpenAPI spec for automated connector generation - entries.push({ - id: "yamlUpload", - component: YamlUpload, - isEdited: isTextFieldEntryEdited, - }); if ( element.businessObject.deploymentModelUrl && !element.businessObject.deploymentModelUrl.includes( diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js index 803f2b2d..c337fb61 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js @@ -19,6 +19,7 @@ import { useService } from "bpmn-js-properties-panel"; import { getImplementationType } from "../../../quantme/utilities/ImplementationTypeHelperExtension"; import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils"; import { getExtensionElementsList } from "../../../../editor/util/camunda-utils/ExtensionElementsUtil"; +import { YamlUpload } from "./YamlUpload"; /** * Properties group for implementations of service tasks. @@ -79,6 +80,13 @@ export function ImplementationProps(element) { component: ConnectorId, isEdited: isTextFieldEntryEdited, }); + + // field to upload an OpenAPI spec for automated connector generation + entries.push({ + id: "yamlUpload", + component: YamlUpload, + isEdited: isTextFieldEntryEdited, + }); } return entries; From be2c1d085fa64f2c42b2b352904698cac1fc03f7 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 24 Oct 2023 16:52:38 +0200 Subject: [PATCH 3/5] Move OpenAPI endpoint selection to implementation group --- .../DeploymentModelProps.js | 32 ----------------- .../ImplementationProps.js | 35 ++++++++++++++++++- .../ServiceTaskPropertiesProvider.js | 2 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js index bbfc40c8..b623fd2c 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/DeploymentModelProps.js @@ -13,10 +13,6 @@ import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camund import { ArtifactUpload } from "./ArtifactUpload"; import { isTextFieldEntryEdited } from "@bpmn-io/properties-panel"; import { Deployment } from "./Deployment"; -import { Connector } from "./Connector"; -import yaml from "js-yaml"; - -const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull"; /** * Properties group for service tasks. Extends the original implementation by adding a new selection option to the @@ -47,24 +43,6 @@ export function DeploymentModelProps(props) { isEdited: isTextFieldEntryEdited, }); - if ( - element.businessObject.deploymentModelUrl && - !element.businessObject.deploymentModelUrl.includes( - encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) - ) && - element.businessObject.yaml !== undefined - ) { - const urls = extractUrlsFromYaml(element.businessObject.yaml); - entries.push({ - id: "connector", - element, - translate, - urls, - component: Connector, - isEdited: isTextFieldEntryEdited, - }); - } - entries.push({ id: "artifactUpload", element, @@ -75,13 +53,3 @@ export function DeploymentModelProps(props) { return entries; } - -function extractUrlsFromYaml(content) { - const doc = yaml.load(content); - - // Extract URLs from paths - const paths = Object.keys(doc.paths); - return paths.map((path) => { - return `${path}`; - }); -} diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js index c337fb61..55b6e707 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js @@ -20,6 +20,10 @@ import { getImplementationType } from "../../../quantme/utilities/Implementation import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils"; import { getExtensionElementsList } from "../../../../editor/util/camunda-utils/ExtensionElementsUtil"; import { YamlUpload } from "./YamlUpload"; +import { Connector } from "./Connector"; +import yaml from "js-yaml"; + +const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull"; /** * Properties group for implementations of service tasks. @@ -28,8 +32,9 @@ import { YamlUpload } from "./YamlUpload"; * @return {{component: function(*): preact.VNode, isEdited: function(*): *, id: string}[]|*[]} * @constructor */ -export function ImplementationProps(element) { +export function ImplementationProps(props) { console.log("Rendering implementation properties for ServiceTask!"); + const { element, translate } = props; if (!getServiceTaskLikeBusinessObject(element)) { return []; @@ -81,6 +86,24 @@ export function ImplementationProps(element) { isEdited: isTextFieldEntryEdited, }); + if ( + element.businessObject.deploymentModelUrl && + !element.businessObject.deploymentModelUrl.includes( + encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) + ) && + element.businessObject.yaml !== undefined + ) { + const urls = extractUrlsFromYaml(element.businessObject.yaml); + entries.push({ + id: "connector", + element, + translate, + urls, + component: Connector, + isEdited: isTextFieldEntryEdited, + }); + } + // field to upload an OpenAPI spec for automated connector generation entries.push({ id: "yamlUpload", @@ -92,6 +115,16 @@ export function ImplementationProps(element) { return entries; } +function extractUrlsFromYaml(content) { + const doc = yaml.load(content); + + // Extract URLs from paths + const paths = Object.keys(doc.paths); + return paths.map((path) => { + return `${path}`; + }); +} + export function JavaClass(props) { const { element, diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js index 404d24b8..a6bdbb47 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ServiceTaskPropertiesProvider.js @@ -81,7 +81,7 @@ function ImplementationGroup(element, injector) { label: translate("Implementation"), id: "CamundaPlatform__Implementation", component: Group, - entries: [...ImplementationProps(element)], + entries: [...ImplementationProps({ element, translate })], }; if (group.entries.length) { From 40f585077d40e9fb1eee4eb551d9b955ded55946 Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 24 Oct 2023 17:06:53 +0200 Subject: [PATCH 4/5] Move YAMl upload button into if --- .../ImplementationProps.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js index 55b6e707..2b0be561 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js @@ -87,29 +87,31 @@ export function ImplementationProps(props) { }); if ( - element.businessObject.deploymentModelUrl && + element.businessObject.deploymentModelUrl || !element.businessObject.deploymentModelUrl.includes( encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) - ) && - element.businessObject.yaml !== undefined + ) ) { - const urls = extractUrlsFromYaml(element.businessObject.yaml); + // field to upload an OpenAPI spec for automated connector generation entries.push({ - id: "connector", - element, - translate, - urls, - component: Connector, + id: "yamlUpload", + component: YamlUpload, isEdited: isTextFieldEntryEdited, }); - } - // field to upload an OpenAPI spec for automated connector generation - entries.push({ - id: "yamlUpload", - component: YamlUpload, - isEdited: isTextFieldEntryEdited, - }); + // drop down to select endpoint from OpenAPI spec + if (element.businessObject.yaml !== undefined) { + const urls = extractUrlsFromYaml(element.businessObject.yaml); + entries.push({ + id: "connector", + element, + translate, + urls, + component: Connector, + isEdited: isTextFieldEntryEdited, + }); + } + } } return entries; From fedbd4b099d339eb9456a379d286458ee2ea845a Mon Sep 17 00:00:00 2001 From: Benjamin Weder Date: Tue, 24 Oct 2023 17:11:06 +0200 Subject: [PATCH 5/5] Invert null check --- .../modeling/properties-provider/ImplementationProps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js index 2b0be561..bdf85186 100644 --- a/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js +++ b/components/bpmn-q/modeler-component/extensions/opentosca/modeling/properties-provider/ImplementationProps.js @@ -87,7 +87,7 @@ export function ImplementationProps(props) { }); if ( - element.businessObject.deploymentModelUrl || + !element.businessObject.deploymentModelUrl || !element.businessObject.deploymentModelUrl.includes( encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL)) )