ljmotta commented on code in PR #2230:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2230#discussion_r1558045471


##########
packages/dmn-editor/src/diagram/DrdSelectorPanel.tsx:
##########
@@ -30,19 +30,32 @@ import { Title } from 
"@patternfly/react-core/dist/js/components/Title";
 import { Form, FormGroup, FormSection } from 
"@patternfly/react-core/dist/js/components/Form";
 import { ToggleGroup, ToggleGroupItem } from 
"@patternfly/react-core/dist/js/components/ToggleGroup";
 import { AlternativeInputDataIcon, InputDataIcon } from "../icons/Icons";
+import { EmptyState, EmptyStateBody } from 
"@patternfly/react-core/dist/js/components/EmptyState";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
+import { useCallback } from "react";
 
 export function DrdSelectorPanel() {
   const thisDmn = useDmnEditorStore((s) => s.dmn);
   const diagram = useDmnEditorStore((s) => s.diagram);
   const isAlternativeInputDataShape = useDmnEditorStore((s) => 
s.computed(s).isAlternativeInputDataShape());
   const drdName = useDmnEditorStore(
     (s) =>
-      
s.dmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"]?.[s.diagram.drdIndex]["@_name"]
 ||
+      
s.dmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"]?.[s.diagram.drdIndex]?.["@_name"]
 ||
       getDefaultDrdName({ drdIndex: s.diagram.drdIndex })
   );
 
   const dmnEditorStoreApi = useDmnEditorStoreApi();
 
+  const drds = thisDmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"] 
?? [];
+
+  const removeDrd = useCallback(() => {
+    dmnEditorStoreApi.setState((s) => {
+      const nextDrds = 
s.dmn.model.definitions["dmndi:DMNDI"]?.["dmndi:DMNDiagram"];
+      nextDrds?.splice(s.diagram.drdIndex, 1);
+      s.diagram.drdIndex = Math.max(0, Math.min(s.diagram.drdIndex, 
(nextDrds?.length ?? 0) - 1));

Review Comment:
   In the case we have 3 DRDs (DRD1, DRD2, DRD3), deleting the DRD2, will 
select the DRD3. I'm inclined to think that we should select the previous 
(DRD1) instead of the next one, I'm not sure why... but I'm fine with this 
logic too. Just saying :)



-- 
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]

Reply via email to