You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "ljmotta (via GitHub)" <gi...@apache.org> on 2024/05/16 20:37:12 UTC

[PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

ljmotta opened a new pull request, #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341

   This PR is part of https://github.com/apache/incubator-kie-issues/issues/451
   
   ## Description
   WIP


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2127249575

   It looks great!!! Thank you @ljmotta listening to our feedback and implementing a nice solution!
   Great team work!!


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#discussion_r1607884817


##########
packages/dmn-editor/src/normalization/autoGenerateDrd.ts:
##########
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { generateUuid } from "@kie-tools/boxed-expression-component/dist/api";
+import { ExternalDmnsIndex, ExternalModelsIndex, ExternalPmmlsIndex } from "../DmnEditor";
+import { computeDiagramData } from "../store/computed/computeDiagramData";
+import { State } from "../store/Store";
+import { MIN_NODE_SIZES } from "../diagram/nodes/DefaultSizes";
+import { getNodeTypeFromDmnObject } from "../diagram/maths/DmnMaths";
+import { DMN15__tDefinitions } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
+import { DmnLatestModel } from "@kie-tools/dmn-marshaller";
+import { parseXmlHref } from "../xml/xmlHrefs";
+import { computeIndexedDrd } from "../store/computed/computeIndexes";
+import { getDefaultDrdName } from "../mutations/addOrGetDrd";
+import { addShape } from "../mutations/addShape";
+import { addEdge } from "../mutations/addEdge";
+import { EdgeType, NodeType } from "../diagram/connections/graphStructure";
+import { PositionalNodeHandleId } from "../diagram/connections/PositionalNodeHandles";
+
+export async function autoGenerateDrd(args: {
+  model: State["dmn"]["model"];
+  diagram: State["diagram"];
+  externalModelsByNamespace: ExternalModelsIndex | undefined;
+  externalModelTypesByNamespace: {
+    dmns: ExternalDmnsIndex;
+    pmmls: ExternalPmmlsIndex;
+  };
+}) {
+  // Create DRD
+  args.model.definitions["dmndi:DMNDI"] = {
+    ...args.model.definitions["dmndi:DMNDI"],
+    "dmndi:DMNDiagram": [
+      {
+        "@_id": generateUuid(),
+        "@_name": getDefaultDrdName({ drdIndex: 0 }),
+        "@_useAlternativeInputDataShape": false,

Review Comment:
   we invoke `autoGenerateDrd` from the `Diagram.tsx`. There on many places we dynamically check for this alternative shape setting like `state.computed(state).isAlternativeInputDataShape()`. is it expected, here, in `autoGenerateDrd.ts` we hard-code alternative shape to false?



##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
@@ -1182,6 +1186,131 @@ export const Diagram = React.forwardRef<DiagramRef, { container: React.RefObject
   }
 );
 
+function DmnDiagramWithoutDrd() {
+  const dmnEditorStoreApi = useDmnEditorStoreApi();
+  const { externalModelsByNamespace } = useExternalModels();
+  const applyAutoLayout = useAutoLayout();
+
+  return (
+    <Bullseye
+      style={{
+        position: "absolute",
+        width: "100%",
+        pointerEvents: "none",
+        zIndex: 1,
+        height: "auto",
+        marginTop: "120px",
+      }}
+    >
+      <div className={"kie-dmn-editor--diagram-empty-state"}>
+        <Button
+          title={"Close"}
+          style={{
+            position: "absolute",
+            top: "8px",
+            right: 0,
+          }}
+          variant={ButtonVariant.plain}
+          icon={<TimesIcon />}
+          onClick={() => {
+            dmnEditorStoreApi.setState((s) => {
+              s.diagram.autoLayout.canAutoGenerateDrd = false;
+            });
+          }}
+        />
+
+        <EmptyState>
+          <EmptyStateIcon icon={MousePointerIcon} />
+          <Title size={"md"} headingLevel={"h4"}>
+            {`This DMN's Diagram is empty`}
+          </Title>
+          <EmptyStateBody>{`The current DMN doens't have a DRD associated with the DRG.`}</EmptyStateBody>
+          <EmptyStateBody>{`Do you want to auto generated it?`}</EmptyStateBody>

Review Comment:
   ```suggestion
             <EmptyStateBody>{`The current DMN doesn't have a DRD associated with the DRG.`}</EmptyStateBody>
             <EmptyStateBody>{`Do you want to auto-generate it?`}</EmptyStateBody>
   ```



-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2124382386

   About the terminology: I guess it's fine to use the proposed sentence by Gabriele, but I'm not against using the DRG and DRD acronyms. Maybe, we can use the extended form as an alternative (eg. Decision Requirement Diagram / Graph), or use the info icon with a popup to better clarify it.
   
   About the current implementation, I like it, well done @ljmotta. In addition, I would consider just  to manage this scenario:
   - The user opens a DMN without the DMNDI;
   - The user chooses `no` when dealing with the AutoGeneration popup introduced in that PR
   - After a while, the user changed his mind and wanted to autogenerate the Graph.
   
   Based on that, can we consider as an alternative keeping the modal ALWAYS showing there until the user explicitly wants to autogenerate it? Eg.
   
   <img width="445" alt="Screenshot 2024-05-22 at 11 47 18" src="https://github.com/apache/incubator-kie-tools/assets/16005046/a5d74054-27d1-4311-ada3-d34553550a95">
   
   In that way, the users:
   - Don't need to take any actions if he/she is not interested to autogenerate the Graph;
   - We don't force the user to make that choice just after opening the file in the editor
   - The user can easily autogenerate the Graph in any moment;
   
   WDYT? 
   
   
   


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2122701569

   @ljmotta 
   Let me give my POV.  DMN is mostly about "execution", while the graphical part is just a way to easily define/visualize them.
   An indirect proof is that a model without any kind of graphical information is perfectly valid and executable. 
   What I'm driving at is that while DMN user may (or should) know all the details related to execution (e.g. difference between our most beloved `typeConstraint` and `allowedValues`) because they actually change the behavior, the graphical part are just inner details, whose knowledge does not have any impact on the execution, and could be happily ignored.
   So, I also would prefer something simpler, like 
   "The current DMN does not have any diagram associated"
   
   wdyt ?


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2127241144

   I love it. Nicely done! Looks great. +1 from me!


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2127237961

   @yesamer @gitgabrio @jomarko I've updated the PR description with the new modal. I've used a piece of each idea, and I'm very happy with the result. 


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2122568257

   @jomarko Thanks for bringing this up. I agree, I will add more information to the user, like the node placement, sizes and consequences of the yes/no choice. Now, regarding the specific terminology, the editor is specific to DMN models so I think we can assume the user will know a few things at least. It's a gray area for me, and in this case I'd say it's not necessary to explain what is DRD and DRG as both are very important DMN concepts. What you guys think? @tiagobento @baldimir @yesamer @gitgabrio 


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#discussion_r1608240604


##########
packages/dmn-editor/src/normalization/autoGenerateDrd.ts:
##########
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { generateUuid } from "@kie-tools/boxed-expression-component/dist/api";
+import { ExternalDmnsIndex, ExternalModelsIndex, ExternalPmmlsIndex } from "../DmnEditor";
+import { computeDiagramData } from "../store/computed/computeDiagramData";
+import { State } from "../store/Store";
+import { MIN_NODE_SIZES } from "../diagram/nodes/DefaultSizes";
+import { getNodeTypeFromDmnObject } from "../diagram/maths/DmnMaths";
+import { DMN15__tDefinitions } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
+import { DmnLatestModel } from "@kie-tools/dmn-marshaller";
+import { parseXmlHref } from "../xml/xmlHrefs";
+import { computeIndexedDrd } from "../store/computed/computeIndexes";
+import { getDefaultDrdName } from "../mutations/addOrGetDrd";
+import { addShape } from "../mutations/addShape";
+import { addEdge } from "../mutations/addEdge";
+import { EdgeType, NodeType } from "../diagram/connections/graphStructure";
+import { PositionalNodeHandleId } from "../diagram/connections/PositionalNodeHandles";
+
+export async function autoGenerateDrd(args: {
+  model: State["dmn"]["model"];
+  diagram: State["diagram"];
+  externalModelsByNamespace: ExternalModelsIndex | undefined;
+  externalModelTypesByNamespace: {
+    dmns: ExternalDmnsIndex;
+    pmmls: ExternalPmmlsIndex;
+  };
+}) {
+  // Create DRD
+  args.model.definitions["dmndi:DMNDI"] = {
+    ...args.model.definitions["dmndi:DMNDI"],
+    "dmndi:DMNDiagram": [
+      {
+        "@_id": generateUuid(),
+        "@_name": getDefaultDrdName({ drdIndex: 0 }),
+        "@_useAlternativeInputDataShape": false,

Review Comment:
   The modal will popup as soon as the user open the DMN model (e.g. first time opening the Editor). As `false` is the default value for any new model, I've harded code this value. The user still can change this option on the DRD dropdown.



-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "baldimir (via GitHub)" <gi...@apache.org>.
baldimir commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2124414578

   Hi, as discussed in the typeConstraint and allowedValues issue, I think the best would be to add clarifications in a hint (or the "i" icon). Similar approach should be applied everywhere throughout the application I think, so it starts to be self-documented to some extent. 


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "danielzhe (via GitHub)" <gi...@apache.org>.
danielzhe commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2127246182

   I'm late for the discussion but I don't like the terms DRG and DRD and I agree with @gitgabrio 
   
   In the old editor, I was the one who created the modal for this case. We had some discussion about at that time and the sentence we chose to use at the time was: "The diagram does not have layout information". We never used the terms "DRG" or "DRD".
   
   I saw you changed the message @ljmotta and I think the new terms are great and very clear to the user what is happening.
   
   


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#451: Implement autolayout on the new React-based DMN Editor for DMN files without Diagram information - Part 1 [incubator-kie-tools]

Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on PR #2341:
URL: https://github.com/apache/incubator-kie-tools/pull/2341#issuecomment-2127243681

   Very nice, thanks @ljmotta ! 👍 


-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org