tiagobento commented on code in PR #3557:
URL:
https://github.com/apache/incubator-kie-tools/pull/3557#discussion_r3183653674
##########
packages/bpmn-editor-envelope/src/customTasks/MilestoneTask.tsx:
##########
@@ -86,12 +86,61 @@ export function getMilestoneTask(i18n:
BpmnEditorEnvelopeI18n): CustomTask {
iconSvgElement: MILESTONE_TASK_ICON,
propertiesPanelComponent: MilestoneTaskProperties,
matches: (task) => task["@_drools:taskName"] === "Milestone",
- produce: () => ({
- __$$element: "task",
- "@_id": generateUuid(),
- "@_drools:taskName": "Milestone",
- "@_name": i18n.milestone,
- }),
+ produce: () => {
+ const conditionInputId = generateUuid();
+ return {
+ __$$element: "task",
+ "@_id": generateUuid(),
+ "@_drools:taskName": "Milestone",
+ "@_name": i18n.milestone,
+ ioSpecification: {
+ "@_id": generateUuid(),
+ dataInput: [
+ {
+ "@_id": conditionInputId,
+ "@_name": "Condition",
+ "@_drools:dtype": "String",
+ },
+ ],
+ inputSet: [
+ {
+ "@_id": generateUuid(),
+ dataInputRefs: [{ __$$text: conditionInputId }],
+ },
+ ],
+ dataOutput: [],
+ outputSet: [
+ {
+ "@_id": generateUuid(),
+ dataOutputRefs: [],
+ },
+ ],
+ },
+ dataInputAssociation: [],
+ dataOutputAssociation: [],
+ };
+ },
+ onAdded: (state, task) => {
+ const definitions = state.bpmn.model.definitions;
+ definitions.rootElement ??= [];
+
+ let stringItemDefinition = definitions.rootElement.find(
+ (r) => r.__$$element === "itemDefinition" && r["@_structureRef"] ===
"String"
+ );
+
+ if (!stringItemDefinition) {
+ stringItemDefinition = {
+ __$$element: "itemDefinition",
+ "@_id": generateUuid(),
+ "@_structureRef": "String",
+ };
+ definitions.rootElement.push(stringItemDefinition);
+ }
Review Comment:
Can you use `addOrGetItemDefinitions` here instead?
##########
packages/bpmn-editor-envelope/src/customTasks/MilestoneTask.tsx:
##########
@@ -86,12 +86,61 @@ export function getMilestoneTask(i18n:
BpmnEditorEnvelopeI18n): CustomTask {
iconSvgElement: MILESTONE_TASK_ICON,
propertiesPanelComponent: MilestoneTaskProperties,
matches: (task) => task["@_drools:taskName"] === "Milestone",
- produce: () => ({
- __$$element: "task",
- "@_id": generateUuid(),
- "@_drools:taskName": "Milestone",
- "@_name": i18n.milestone,
- }),
+ produce: () => {
+ const conditionInputId = generateUuid();
+ return {
+ __$$element: "task",
+ "@_id": generateUuid(),
+ "@_drools:taskName": "Milestone",
+ "@_name": i18n.milestone,
+ ioSpecification: {
+ "@_id": generateUuid(),
+ dataInput: [
+ {
+ "@_id": conditionInputId,
+ "@_name": "Condition",
+ "@_drools:dtype": "String",
+ },
+ ],
+ inputSet: [
+ {
+ "@_id": generateUuid(),
+ dataInputRefs: [{ __$$text: conditionInputId }],
+ },
+ ],
+ dataOutput: [],
+ outputSet: [
+ {
+ "@_id": generateUuid(),
+ dataOutputRefs: [],
+ },
+ ],
+ },
+ dataInputAssociation: [],
+ dataOutputAssociation: [],
+ };
+ },
+ onAdded: (state, task) => {
+ const definitions = state.bpmn.model.definitions;
+ definitions.rootElement ??= [];
+
+ let stringItemDefinition = definitions.rootElement.find(
+ (r) => r.__$$element === "itemDefinition" && r["@_structureRef"] ===
"String"
+ );
+
+ if (!stringItemDefinition) {
+ stringItemDefinition = {
+ __$$element: "itemDefinition",
+ "@_id": generateUuid(),
+ "@_structureRef": "String",
+ };
+ definitions.rootElement.push(stringItemDefinition);
+ }
Review Comment:
You could also look into `getDataMapping` and `setInputDataMapping`.
##########
packages/bpmn-editor-envelope/src/customTasks/MilestoneTask.tsx:
##########
@@ -86,12 +86,61 @@ export function getMilestoneTask(i18n:
BpmnEditorEnvelopeI18n): CustomTask {
iconSvgElement: MILESTONE_TASK_ICON,
propertiesPanelComponent: MilestoneTaskProperties,
matches: (task) => task["@_drools:taskName"] === "Milestone",
- produce: () => ({
- __$$element: "task",
- "@_id": generateUuid(),
- "@_drools:taskName": "Milestone",
- "@_name": i18n.milestone,
- }),
+ produce: () => {
+ const conditionInputId = generateUuid();
+ return {
+ __$$element: "task",
+ "@_id": generateUuid(),
+ "@_drools:taskName": "Milestone",
+ "@_name": i18n.milestone,
+ ioSpecification: {
+ "@_id": generateUuid(),
+ dataInput: [
+ {
+ "@_id": conditionInputId,
+ "@_name": "Condition",
Review Comment:
Can we please extract the "Condition" string to be a constant? I've been
keeping track of all of the extension points we have in here
https://github.com/apache/incubator-kie-tools/blob/main/packages/bpmn-marshaller/src/drools-extension.ts.
This would be an entirely new constant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]