From f94cd7820b481ee40dca0746e7289e089b62d5b2 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 1 Nov 2024 14:52:54 +0100
Subject: [PATCH 01/25] kie-issues#1595: Sandbox: Add "Open in Boxed Expression
Editor" button in the DMN Runner form output cards
Closes: https://github.com/apache/incubator-kie-issues/issues/1595
---
packages/boxed-expression-component/README.md | 10 ----------
packages/form-dmn/src/FormDmnOutputs.tsx | 11 ++++++++++-
.../src/dmnRunner/DmnRunnerDrawerPanelContent.tsx | 6 ++++++
.../src/editor/Toolbar/NewFileDropdownMenu.tsx | 5 +----
.../envelopeLocator/EditorEnvelopeLocatorFactory.ts | 12 +-----------
.../hooks/EditorEnvelopeLocatorContext.tsx | 2 --
packages/online-editor/src/home/HomePage.tsx | 5 +----
7 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/packages/boxed-expression-component/README.md b/packages/boxed-expression-component/README.md
index a9dc432b9c5..ee3b6bb598c 100644
--- a/packages/boxed-expression-component/README.md
+++ b/packages/boxed-expression-component/README.md
@@ -28,16 +28,6 @@ This editor provides the possibility to edit the expression related to a Decisio
The main component is `src/components/BoxedExpressionEditor/BoxedExpressionEditor.tsx`.
It represents the entry point for using the editor.
-In the `showcase` folder, there is a tiny React application, which represent the Proof Of Value about how it is possible to integrate the `BoxedExpressionEditor` component inside another existing application.
-
-Once the showcase application gets launched, you can see on the right side of the page the JSON that is actually produced for the corresponding selected logic type.
-Such JSON represents the model data that must be adopted to initialize the `BoxedExpressionEditor` component, by populating its props.
-
-The retrieval of the updated expression is performed by making usage of global functions, belonging to `beeApiWrapper` object, that must be available in the `Window` namespace and used by the `BoxedExpressionEditor` component.
-All exposed function expected to exist, are defined in `src/api/BoxedExpressionEditor.ts`.
-
-Consider that the showcase app is able to display the most updated JSON representing an expression, because uses such APIs (please refer to `showcase/src/index.tsx`).
-
## Scripts
In the main project (where the components actually live), it is possible to execute, from the root folder, the following scripts (`pnpm` is recommended):
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index 9cd9ac6ce94..aec2c8407f5 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -40,6 +40,8 @@ import "./styles.scss";
import { ErrorBoundary } from "@kie-tools/dmn-runner/dist/ErrorBoundary";
import { ExclamationTriangleIcon } from "@patternfly/react-icons/dist/js/icons/exclamation-triangle-icon";
import { DecisionResult, DmnEvaluationStatus, DmnEvaluationResult } from "@kie-tools/extended-services-api";
+import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
const ISSUES_URL = "https://github.com/apache/incubator-kie-issues/issues";
@@ -61,6 +63,7 @@ export interface FormDmnOutputsProps {
locale?: string;
notificationsPanel: boolean;
openExecutionTab?: () => void;
+ openBoxedExpressionEditor?: (nodeId: string) => void;
}
export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsProps) {
@@ -258,7 +261,13 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
onAnimationEnd={(e) => onAnimationEnd(e, index)}
>
- {dmnFormResult.decisionName}
+
+ {dmnFormResult.decisionName}
+ props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ />
+
{result(dmnFormResult.result)}
{resultStatus(dmnFormResult.evaluationStatus)}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index ac899b3bf2e..1805f3ba1f4 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -324,6 +324,12 @@ export function DmnRunnerDrawerPanelContent() {
locale={locale}
notificationsPanel={true}
openExecutionTab={openExecutionTab}
+ openBoxedExpressionEditor={(nodeId) => {
+ // TODO we need somehow access 'dmnEditorStoreApi'
+ // dmnEditorStoreApi.setState((state) => {
+ // state.dispatch(state).boxedExpressionEditor.open(nodeId);
+ // })
+ }}
/>
diff --git a/packages/online-editor/src/editor/Toolbar/NewFileDropdownMenu.tsx b/packages/online-editor/src/editor/Toolbar/NewFileDropdownMenu.tsx
index 47462d66535..72471d958fb 100644
--- a/packages/online-editor/src/editor/Toolbar/NewFileDropdownMenu.tsx
+++ b/packages/online-editor/src/editor/Toolbar/NewFileDropdownMenu.tsx
@@ -32,10 +32,7 @@ import {
MenuItem,
MenuList,
} from "@patternfly/react-core/dist/js/components/Menu";
-import {
- SupportedFileExtensions,
- useEditorEnvelopeLocator,
-} from "../../envelopeLocator/hooks/EditorEnvelopeLocatorContext";
+import { useEditorEnvelopeLocator } from "../../envelopeLocator/hooks/EditorEnvelopeLocatorContext";
import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button";
import { Alert, AlertActionCloseButton } from "@patternfly/react-core/dist/js/components/Alert";
import { basename, extname } from "path";
diff --git a/packages/online-editor/src/envelopeLocator/EditorEnvelopeLocatorFactory.ts b/packages/online-editor/src/envelopeLocator/EditorEnvelopeLocatorFactory.ts
index eb679129b4a..750abf073d2 100644
--- a/packages/online-editor/src/envelopeLocator/EditorEnvelopeLocatorFactory.ts
+++ b/packages/online-editor/src/envelopeLocator/EditorEnvelopeLocatorFactory.ts
@@ -18,7 +18,7 @@
*/
import { EditorEnvelopeLocator, EnvelopeContentType, EnvelopeMapping } from "@kie-tools-core/editor/dist/api";
-import { FileTypes, isOfKind } from "@kie-tools-core/workspaces-git-fs/dist/constants/ExtensionHelper";
+import { isOfKind } from "@kie-tools-core/workspaces-git-fs/dist/constants/ExtensionHelper";
import { EditorConfig } from "./EditorEnvelopeLocatorApi";
export const GLOB_PATTERN = {
@@ -29,16 +29,6 @@ export const GLOB_PATTERN = {
pmml: "**/*.pmml",
};
-export const supportedFileExtensionArray = [
- FileTypes.DMN,
- FileTypes.BPMN,
- FileTypes.BPMN2,
- FileTypes.SCESIM,
- FileTypes.PMML,
-];
-
-export type SupportedFileExtensions = (typeof supportedFileExtensionArray)[number];
-
export function isModel(path: string): boolean {
return isOfKind("dmn", path) || isOfKind("bpmn", path) || isOfKind("pmml", path);
}
diff --git a/packages/online-editor/src/envelopeLocator/hooks/EditorEnvelopeLocatorContext.tsx b/packages/online-editor/src/envelopeLocator/hooks/EditorEnvelopeLocatorContext.tsx
index 2f8586d9afe..ac9194e355f 100644
--- a/packages/online-editor/src/envelopeLocator/hooks/EditorEnvelopeLocatorContext.tsx
+++ b/packages/online-editor/src/envelopeLocator/hooks/EditorEnvelopeLocatorContext.tsx
@@ -25,8 +25,6 @@ import { EditorConfig } from "../EditorEnvelopeLocatorApi";
import { EditorEnvelopeLocator } from "@kie-tools-core/editor/dist/api/EditorEnvelopeLocator";
import { FileTypes } from "@kie-tools-core/workspaces-git-fs/dist/constants/ExtensionHelper";
-export type SupportedFileExtensions = "bpmn" | "bpmn2" | "BPMN" | "BPMN2" | "dmn" | "DMN" | "pmml" | "PMML";
-
// FIXME: Chaging `any` to `EditorEnvelopeLocator` breaks --env live. Please adress this as part of https://github.com/apache/incubator-kie-issues/issues/109
export const EditorEnvelopeLocatorContext = React.createContext({} as any);
diff --git a/packages/online-editor/src/home/HomePage.tsx b/packages/online-editor/src/home/HomePage.tsx
index b0a7f639172..1863fbefbb7 100644
--- a/packages/online-editor/src/home/HomePage.tsx
+++ b/packages/online-editor/src/home/HomePage.tsx
@@ -23,10 +23,7 @@ import { PageSection } from "@patternfly/react-core/dist/js/components/Page";
import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text";
import { Title } from "@patternfly/react-core/dist/js/components/Title";
import { Label } from "@patternfly/react-core/dist/js/components/Label";
-import {
- SupportedFileExtensions,
- useEditorEnvelopeLocator,
-} from "../envelopeLocator/hooks/EditorEnvelopeLocatorContext";
+import { useEditorEnvelopeLocator } from "../envelopeLocator/hooks/EditorEnvelopeLocatorContext";
import { useHistory } from "react-router";
import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button";
import {
From 5c8c3636a6a4ba0580918528c84bd93a878d7c4d Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Tue, 17 Dec 2024 12:32:09 +0100
Subject: [PATCH 02/25] ChannelApi changes
---
packages/dmn-editor-envelope/src/DmnEditorFactory.tsx | 4 ++++
packages/dmn-editor-envelope/src/DmnEditorRoot.tsx | 4 ++++
packages/dmn-editor/src/DmnEditor.tsx | 6 ++++++
packages/editor/src/api/Editor.ts | 1 +
packages/editor/src/api/KogitoEditorEnvelopeApi.ts | 1 +
.../editor/src/embedded/embedded/EmbeddedEditor.tsx | 4 ++++
.../editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts | 3 +++
packages/form-dmn/src/FormDmnOutputs.tsx | 5 ++++-
.../kie-bc-editors/src/common/GwtEditorWrapper.tsx | 5 +++++
.../online-editor/src/dmnRunner/DmnRunnerDrawer.tsx | 5 +++--
.../src/dmnRunner/DmnRunnerDrawerPanelContent.tsx | 10 +++++-----
packages/online-editor/src/editor/EditorPage.tsx | 2 +-
.../pmml-editor/src/editor/PMMLEditorInterface.tsx | 5 +++++
13 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
index 0af0ec31460..b675707ce7d 100644
--- a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
+++ b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
@@ -68,6 +68,10 @@ export class DmnEditorInterface implements Editor {
return Promise.resolve(); // No-op for now. The DMN Editor only has the LIGHT theme.
}
+ public async openBoxedExpressionEditor(nodeId: string): Promise {
+ return this.self.openBoxedExpressionEditor(nodeId);
+ }
+
public async undo(): Promise {
return this.self.undo();
}
diff --git a/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx b/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
index 6388a6b4a11..2323396163a 100644
--- a/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
+++ b/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
@@ -100,6 +100,10 @@ export class DmnEditorRoot extends React.Component {
+ await this.dmnEditorRef.current?.openBoxedExpressionEditor(nodeId);
+ }
+
public async undo(): Promise {
this.setState((prev) => ({ ...prev, pointer: Math.max(0, prev.pointer - 1) }));
}
diff --git a/packages/dmn-editor/src/DmnEditor.tsx b/packages/dmn-editor/src/DmnEditor.tsx
index 3a1b18aa288..f0ccda8c71f 100644
--- a/packages/dmn-editor/src/DmnEditor.tsx
+++ b/packages/dmn-editor/src/DmnEditor.tsx
@@ -67,6 +67,7 @@ const SVG_PADDING = 20;
export type DmnEditorRef = {
reset: (mode: DmnLatestModel) => void;
getDiagramSvg: () => Promise;
+ openBoxedExpressionEditor(nodeId: string): Promise;
getCommands: () => Commands;
};
@@ -203,6 +204,11 @@ export const DmnEditorInternal = ({
const state = dmnEditorStoreApi.getState();
return state.dispatch(state).dmn.reset(normalize(model));
},
+ openBoxedExpressionEditor: async (nodeId: string) => {
+ dmnEditorStoreApi.setState((state) => {
+ state.dispatch(state).boxedExpressionEditor.open(nodeId);
+ });
+ },
getDiagramSvg: async () => {
const nodes = diagramRef.current?.getReactFlowInstance()?.getNodes();
const edges = diagramRef.current?.getReactFlowInstance()?.getEdges();
diff --git a/packages/editor/src/api/Editor.ts b/packages/editor/src/api/Editor.ts
index 50be1dad7d5..e01acb6dbd1 100644
--- a/packages/editor/src/api/Editor.ts
+++ b/packages/editor/src/api/Editor.ts
@@ -44,4 +44,5 @@ export interface EditorApi {
redo(): Promise;
validate(): Promise;
setTheme(theme: EditorTheme): Promise;
+ openBoxedExpressionEditor(nodeId: string): Promise;
}
diff --git a/packages/editor/src/api/KogitoEditorEnvelopeApi.ts b/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
index 006454754c0..32e2ad2379a 100644
--- a/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
+++ b/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
@@ -51,6 +51,7 @@ export interface EditorInitArgs {
export interface KogitoEditorEnvelopeApi extends KeyboardShortcutsEnvelopeApi, I18nEnvelopeApi {
kogitoEditor_contentChanged(content: EditorContent, args: { showLoadingOverlay: boolean }): Promise;
+ kogitoEditor_openBoxedExpressionEditor(nodeId: string): void;
kogitoEditor_editorUndo(): void;
kogitoEditor_editorRedo(): void;
kogitoEditor_initRequest(association: Association, editorInit: EditorInitArgs): Promise;
diff --git a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
index 107218ce624..2a1907e0d87 100644
--- a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
+++ b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
@@ -193,6 +193,10 @@ const RefForwardingEmbeddedEditor: React.ForwardRefRenderFunction envelopeServer.envelopeApi.requests.kogitoEditor_validate(),
setTheme: (theme) => Promise.resolve(envelopeServer.shared.kogitoEditor_theme.set(theme)),
onKeyDown: (ke: React.KeyboardEvent) => onKeyDown(envelopeServer, ke),
+ openBoxedExpressionEditor: (nodeId) =>
+ Promise.resolve(
+ Promise.resolve(envelopeServer.envelopeApi.notifications.kogitoEditor_openBoxedExpressionEditor.send(nodeId))
+ ),
};
}, [props.isReady, isReady, stateControl, envelopeServer, onKeyDown]);
diff --git a/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts b/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
index 3af26fd882f..a9baf58c506 100644
--- a/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
+++ b/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
@@ -126,6 +126,9 @@ export class KogitoEditorEnvelopeApiImpl<
.finally(() => this.view().setLoadingFinished());
};
+ public kogitoEditor_openBoxedExpressionEditor(nodeId: string) {
+ this.editor.openBoxedExpressionEditor(nodeId);
+ }
public kogitoEditor_editorUndo() {
this.editor.undo();
}
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index aec2c8407f5..d266df29c7e 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -265,7 +265,10 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
{dmnFormResult.decisionName}
props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ onClick={() => {
+ console.error("here");
+ props.openBoxedExpressionEditor?.(dmnFormResult.decisionId);
+ }}
/>
diff --git a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
index 02066e01f15..75c9938fd15 100644
--- a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
+++ b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
@@ -75,6 +75,11 @@ export class GwtEditorWrapper implements Editor {
return <>>;
}
+ public async openBoxedExpressionEditor(nodeId: string) {
+ // TODO FIX
+ return this.stateControlService.undo();
+ }
+
public async undo() {
return this.stateControlService.undo();
}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
index aba841edf2e..d6fe6c52c03 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
@@ -23,8 +23,9 @@ import { Drawer, DrawerContent, DrawerContentBody } from "@patternfly/react-core
import { useDmnRunnerState } from "./DmnRunnerContext";
import { DmnRunnerMode } from "./DmnRunnerStatus";
import { DmnRunnerErrorBoundary } from "./DmnRunnerErrorBoundary";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
-export function DmnRunnerDrawer(props: React.PropsWithChildren<{}>) {
+export function DmnRunnerDrawer(props: React.PropsWithChildren<{ editor: EmbeddedEditorRef | undefined }>) {
const dmnRunnerState = useDmnRunnerState();
return (
) {
}
panelContent={
-
+
}
>
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index 1805f3ba1f4..8d25951de3b 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -38,6 +38,7 @@ import { DmnRunnerLoading } from "./DmnRunnerLoading";
import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { PanelId, useEditorDockContext } from "../editor/EditorPageDockContextProvider";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
enum ButtonPosition {
INPUT,
@@ -53,7 +54,7 @@ interface DmnRunnerStylesConfig {
buttonPosition: ButtonPosition;
}
-export function DmnRunnerDrawerPanelContent() {
+export function DmnRunnerDrawerPanelContent(props: { editor: EmbeddedEditorRef | undefined }) {
// STATEs
const [drawerError, setDrawerError] = useState(false);
const [dmnRunnerStylesConfig, setDmnRunnerStylesConfig] = useState({
@@ -325,10 +326,9 @@ export function DmnRunnerDrawerPanelContent() {
notificationsPanel={true}
openExecutionTab={openExecutionTab}
openBoxedExpressionEditor={(nodeId) => {
- // TODO we need somehow access 'dmnEditorStoreApi'
- // dmnEditorStoreApi.setState((state) => {
- // state.dispatch(state).boxedExpressionEditor.open(nodeId);
- // })
+ console.error("here 2");
+ props.editor?.openBoxedExpressionEditor(nodeId);
+ console.error(props.editor + " here 3");
}}
/>
diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx
index 1d3c343e716..ed8b38f2b97 100644
--- a/packages/online-editor/src/editor/EditorPage.tsx
+++ b/packages/online-editor/src/editor/EditorPage.tsx
@@ -479,7 +479,7 @@ Error details: ${err}`);
-
+
{embeddedEditorFile && (
{
+ // TODO FIX
+ return this.self.undo();
+ }
+
public async undo(): Promise {
return this.self.undo();
}
From fffdcc5ae35545470064a652df0181f285b797a9 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 18 Dec 2024 11:57:55 +0100
Subject: [PATCH 03/25] unsupported operation
---
packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx | 3 +--
packages/pmml-editor/src/editor/PMMLEditorInterface.tsx | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
index 75c9938fd15..44b25703caa 100644
--- a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
+++ b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
@@ -76,8 +76,7 @@ export class GwtEditorWrapper implements Editor {
}
public async openBoxedExpressionEditor(nodeId: string) {
- // TODO FIX
- return this.stateControlService.undo();
+ throw new Error("Operation 'openBoxedExpressionEditor' is not supported in old GWT based editor");
}
public async undo() {
diff --git a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
index 8233bc94c7b..b4b40a299bc 100644
--- a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
+++ b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
@@ -55,8 +55,7 @@ export class PMMLEditorInterface implements Editor {
}
public async openBoxedExpressionEditor(nodeId: string): Promise {
- // TODO FIX
- return this.self.undo();
+ throw new Error("Operation 'openBoxedExpressionEditor' is not supported in PMML Editor");
}
public async undo(): Promise {
From 065a5dfdb1853b03a19e7b090c9d140554742938 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 18 Dec 2024 12:36:26 +0100
Subject: [PATCH 04/25] Remove console.error logs
---
packages/form-dmn/src/FormDmnOutputs.tsx | 1 -
.../online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx | 2 --
2 files changed, 3 deletions(-)
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index d266df29c7e..b0d802b3444 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -266,7 +266,6 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
{
- console.error("here");
props.openBoxedExpressionEditor?.(dmnFormResult.decisionId);
}}
/>
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index 8d25951de3b..6a9c2fc47c9 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -326,9 +326,7 @@ export function DmnRunnerDrawerPanelContent(props: { editor: EmbeddedEditorRef |
notificationsPanel={true}
openExecutionTab={openExecutionTab}
openBoxedExpressionEditor={(nodeId) => {
- console.error("here 2");
props.editor?.openBoxedExpressionEditor(nodeId);
- console.error(props.editor + " here 3");
}}
/>
From 37a33f3988c0bd08cef2ec249df4d163ca2a5d4a Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 18 Dec 2024 13:30:25 +0100
Subject: [PATCH 05/25] remove async and Promise
---
packages/dmn-editor-envelope/src/DmnEditorFactory.tsx | 4 ++--
packages/dmn-editor-envelope/src/DmnEditorRoot.tsx | 4 ++--
packages/dmn-editor/src/DmnEditor.tsx | 4 ++--
packages/editor/src/api/Editor.ts | 2 +-
packages/editor/src/embedded/embedded/EmbeddedEditor.tsx | 4 +---
packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx | 2 +-
packages/pmml-editor/src/editor/PMMLEditorInterface.tsx | 2 +-
7 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
index b675707ce7d..c13a9fefd03 100644
--- a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
+++ b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
@@ -68,8 +68,8 @@ export class DmnEditorInterface implements Editor {
return Promise.resolve(); // No-op for now. The DMN Editor only has the LIGHT theme.
}
- public async openBoxedExpressionEditor(nodeId: string): Promise {
- return this.self.openBoxedExpressionEditor(nodeId);
+ public openBoxedExpressionEditor(nodeId: string): void {
+ this.self.openBoxedExpressionEditor(nodeId);
}
public async undo(): Promise {
diff --git a/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx b/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
index 2323396163a..284178b8a07 100644
--- a/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
+++ b/packages/dmn-editor-envelope/src/DmnEditorRoot.tsx
@@ -100,8 +100,8 @@ export class DmnEditorRoot extends React.Component {
- await this.dmnEditorRef.current?.openBoxedExpressionEditor(nodeId);
+ public openBoxedExpressionEditor(nodeId: string): void {
+ this.dmnEditorRef.current?.openBoxedExpressionEditor(nodeId);
}
public async undo(): Promise {
diff --git a/packages/dmn-editor/src/DmnEditor.tsx b/packages/dmn-editor/src/DmnEditor.tsx
index f0ccda8c71f..e1115f7f97f 100644
--- a/packages/dmn-editor/src/DmnEditor.tsx
+++ b/packages/dmn-editor/src/DmnEditor.tsx
@@ -67,7 +67,7 @@ const SVG_PADDING = 20;
export type DmnEditorRef = {
reset: (mode: DmnLatestModel) => void;
getDiagramSvg: () => Promise;
- openBoxedExpressionEditor(nodeId: string): Promise;
+ openBoxedExpressionEditor: (nodeId: string) => void;
getCommands: () => Commands;
};
@@ -204,7 +204,7 @@ export const DmnEditorInternal = ({
const state = dmnEditorStoreApi.getState();
return state.dispatch(state).dmn.reset(normalize(model));
},
- openBoxedExpressionEditor: async (nodeId: string) => {
+ openBoxedExpressionEditor: (nodeId: string) => {
dmnEditorStoreApi.setState((state) => {
state.dispatch(state).boxedExpressionEditor.open(nodeId);
});
diff --git a/packages/editor/src/api/Editor.ts b/packages/editor/src/api/Editor.ts
index e01acb6dbd1..b69ac2d1df4 100644
--- a/packages/editor/src/api/Editor.ts
+++ b/packages/editor/src/api/Editor.ts
@@ -44,5 +44,5 @@ export interface EditorApi {
redo(): Promise;
validate(): Promise;
setTheme(theme: EditorTheme): Promise;
- openBoxedExpressionEditor(nodeId: string): Promise;
+ openBoxedExpressionEditor(nodeId: string): void;
}
diff --git a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
index 2a1907e0d87..87dfca1aef5 100644
--- a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
+++ b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
@@ -194,9 +194,7 @@ const RefForwardingEmbeddedEditor: React.ForwardRefRenderFunction Promise.resolve(envelopeServer.shared.kogitoEditor_theme.set(theme)),
onKeyDown: (ke: React.KeyboardEvent) => onKeyDown(envelopeServer, ke),
openBoxedExpressionEditor: (nodeId) =>
- Promise.resolve(
- Promise.resolve(envelopeServer.envelopeApi.notifications.kogitoEditor_openBoxedExpressionEditor.send(nodeId))
- ),
+ envelopeServer.envelopeApi.notifications.kogitoEditor_openBoxedExpressionEditor.send(nodeId),
};
}, [props.isReady, isReady, stateControl, envelopeServer, onKeyDown]);
diff --git a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
index 44b25703caa..a11977f9849 100644
--- a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
+++ b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
@@ -75,7 +75,7 @@ export class GwtEditorWrapper implements Editor {
return <>>;
}
- public async openBoxedExpressionEditor(nodeId: string) {
+ public openBoxedExpressionEditor(nodeId: string) {
throw new Error("Operation 'openBoxedExpressionEditor' is not supported in old GWT based editor");
}
diff --git a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
index b4b40a299bc..e7675935459 100644
--- a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
+++ b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
@@ -54,7 +54,7 @@ export class PMMLEditorInterface implements Editor {
);
}
- public async openBoxedExpressionEditor(nodeId: string): Promise {
+ public openBoxedExpressionEditor(nodeId: string): void {
throw new Error("Operation 'openBoxedExpressionEditor' is not supported in PMML Editor");
}
From a52fa9707ea90945e45f3719ace1d220cb8f216e Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 18 Dec 2024 14:55:19 +0100
Subject: [PATCH 06/25] Use button
---
packages/form-dmn/src/FormDmnOutputs.tsx | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index b0d802b3444..5fedc7f9505 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -19,6 +19,7 @@
import * as React from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon";
import { InfoCircleIcon } from "@patternfly/react-icons/dist/js/icons/info-circle-icon";
import { ExclamationCircleIcon } from "@patternfly/react-icons/dist/js/icons/exclamation-circle-icon";
@@ -40,8 +41,8 @@ import "./styles.scss";
import { ErrorBoundary } from "@kie-tools/dmn-runner/dist/ErrorBoundary";
import { ExclamationTriangleIcon } from "@patternfly/react-icons/dist/js/icons/exclamation-triangle-icon";
import { DecisionResult, DmnEvaluationStatus, DmnEvaluationResult } from "@kie-tools/extended-services-api";
-import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
+import { Button } from "@patternfly/react-core/dist/js/components/Button";
const ISSUES_URL = "https://github.com/apache/incubator-kie-issues/issues";
@@ -263,11 +264,12 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
{dmnFormResult.decisionName}
- }
data-navigate-to-expression-id={dmnFormResult.decisionId}
- onClick={() => {
- props.openBoxedExpressionEditor?.(dmnFormResult.decisionId);
- }}
+ onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
/>
From e838157fbc9281084f87a70d103f2f4d88cf3879 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 20 Dec 2024 13:10:17 +0100
Subject: [PATCH 07/25] Introduce NewDmn* envelope and channel APIs
---
.../src/NewDmnEditorChannelApi.ts | 22 +++++++++
.../src/NewDmnEditorEnvelopeApi.ts | 24 ++++++++++
.../src/NewDmnEditorEnvelopeApiFactory.ts | 46 +++++++++++++++++++
.../src/NewDmnEditorFactory.tsx | 32 +++++++++++++
packages/editor/src/api/Editor.ts | 1 -
.../editor/src/api/KogitoEditorEnvelopeApi.ts | 1 -
.../src/embedded/embedded/EmbeddedEditor.tsx | 2 -
.../envelope/KogitoEditorEnvelopeApiImpl.ts | 3 --
.../src/common/GwtEditorWrapper.tsx | 4 --
.../dmnRunner/DmnRunnerDrawerPanelContent.tsx | 9 +++-
.../src/envelope/NewDmnEditorEnvelopeApp.ts | 13 ++++--
.../src/editor/PMMLEditorInterface.tsx | 4 --
12 files changed, 140 insertions(+), 21 deletions(-)
create mode 100644 packages/dmn-editor-envelope/src/NewDmnEditorChannelApi.ts
create mode 100644 packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
create mode 100644 packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
create mode 100644 packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorChannelApi.ts b/packages/dmn-editor-envelope/src/NewDmnEditorChannelApi.ts
new file mode 100644
index 00000000000..a29086a40ed
--- /dev/null
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorChannelApi.ts
@@ -0,0 +1,22 @@
+/*
+ * 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 { KogitoEditorChannelApi } from "@kie-tools-core/editor/dist/api";
+
+export interface NewDmnEditorChannelApi extends KogitoEditorChannelApi {}
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
new file mode 100644
index 00000000000..44f4e2fa1b1
--- /dev/null
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
@@ -0,0 +1,24 @@
+/*
+ * 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 { KogitoEditorEnvelopeApi } from "@kie-tools-core/editor/dist/api";
+
+export interface NewDmnEditorEnvelopeApi extends KogitoEditorEnvelopeApi {
+ dmnEditor_openBoxedExpressionEditor(nodeId: string): void;
+}
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
new file mode 100644
index 00000000000..3899c779c2a
--- /dev/null
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
@@ -0,0 +1,46 @@
+/*
+ * 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 { EnvelopeApiFactoryArgs } from "@kie-tools-core/envelope";
+import { EditorEnvelopeViewApi, KogitoEditorEnvelopeApiImpl } from "@kie-tools-core/editor/dist/envelope";
+import { KogitoEditorEnvelopeContextType } from "@kie-tools-core/editor/dist/api";
+import { DmnEditorInterface } from "./DmnEditorFactory";
+import { NewDmnEditorEnvelopeApi } from "./NewDmnEditorEnvelopeApi";
+import { NewDmnEditorChannelApi } from "./NewDmnEditorChannelApi";
+import { NewDmnEditorFactory } from "./NewDmnEditorFactory";
+
+export type NewDmnEnvelopeApiFactoryArgs = EnvelopeApiFactoryArgs<
+ NewDmnEditorEnvelopeApi,
+ NewDmnEditorChannelApi,
+ EditorEnvelopeViewApi,
+ KogitoEditorEnvelopeContextType
+>;
+
+export class NewDmnEditorEnvelopeApiImpl
+ extends KogitoEditorEnvelopeApiImpl
+ implements NewDmnEditorEnvelopeApi
+{
+ constructor(readonly dmnArgs: NewDmnEnvelopeApiFactoryArgs) {
+ super(dmnArgs, new NewDmnEditorFactory());
+ }
+
+ public dmnEditor_openBoxedExpressionEditor(nodeId: string): void {
+ this.getEditorOrThrowError().openBoxedExpressionEditor(nodeId);
+ }
+}
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
new file mode 100644
index 00000000000..ab5cc84071a
--- /dev/null
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
@@ -0,0 +1,32 @@
+/*
+ * 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 * as React from "react";
+import { EditorFactory, EditorInitArgs, KogitoEditorEnvelopeContextType } from "@kie-tools-core/editor/dist/api";
+import { NewDmnEditorChannelApi } from "./NewDmnEditorChannelApi";
+import { DmnEditorInterface } from "./DmnEditorFactory";
+
+export class NewDmnEditorFactory implements EditorFactory {
+ public createEditor(
+ envelopeContext: KogitoEditorEnvelopeContextType,
+ initArgs: EditorInitArgs
+ ): Promise {
+ return Promise.resolve(new DmnEditorInterface(envelopeContext, initArgs));
+ }
+}
diff --git a/packages/editor/src/api/Editor.ts b/packages/editor/src/api/Editor.ts
index b69ac2d1df4..50be1dad7d5 100644
--- a/packages/editor/src/api/Editor.ts
+++ b/packages/editor/src/api/Editor.ts
@@ -44,5 +44,4 @@ export interface EditorApi {
redo(): Promise;
validate(): Promise;
setTheme(theme: EditorTheme): Promise;
- openBoxedExpressionEditor(nodeId: string): void;
}
diff --git a/packages/editor/src/api/KogitoEditorEnvelopeApi.ts b/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
index 32e2ad2379a..006454754c0 100644
--- a/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
+++ b/packages/editor/src/api/KogitoEditorEnvelopeApi.ts
@@ -51,7 +51,6 @@ export interface EditorInitArgs {
export interface KogitoEditorEnvelopeApi extends KeyboardShortcutsEnvelopeApi, I18nEnvelopeApi {
kogitoEditor_contentChanged(content: EditorContent, args: { showLoadingOverlay: boolean }): Promise;
- kogitoEditor_openBoxedExpressionEditor(nodeId: string): void;
kogitoEditor_editorUndo(): void;
kogitoEditor_editorRedo(): void;
kogitoEditor_initRequest(association: Association, editorInit: EditorInitArgs): Promise;
diff --git a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
index 87dfca1aef5..107218ce624 100644
--- a/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
+++ b/packages/editor/src/embedded/embedded/EmbeddedEditor.tsx
@@ -193,8 +193,6 @@ const RefForwardingEmbeddedEditor: React.ForwardRefRenderFunction envelopeServer.envelopeApi.requests.kogitoEditor_validate(),
setTheme: (theme) => Promise.resolve(envelopeServer.shared.kogitoEditor_theme.set(theme)),
onKeyDown: (ke: React.KeyboardEvent) => onKeyDown(envelopeServer, ke),
- openBoxedExpressionEditor: (nodeId) =>
- envelopeServer.envelopeApi.notifications.kogitoEditor_openBoxedExpressionEditor.send(nodeId),
};
}, [props.isReady, isReady, stateControl, envelopeServer, onKeyDown]);
diff --git a/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts b/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
index a9baf58c506..3af26fd882f 100644
--- a/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
+++ b/packages/editor/src/envelope/KogitoEditorEnvelopeApiImpl.ts
@@ -126,9 +126,6 @@ export class KogitoEditorEnvelopeApiImpl<
.finally(() => this.view().setLoadingFinished());
};
- public kogitoEditor_openBoxedExpressionEditor(nodeId: string) {
- this.editor.openBoxedExpressionEditor(nodeId);
- }
public kogitoEditor_editorUndo() {
this.editor.undo();
}
diff --git a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
index a11977f9849..02066e01f15 100644
--- a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
+++ b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx
@@ -75,10 +75,6 @@ export class GwtEditorWrapper implements Editor {
return <>>;
}
- public openBoxedExpressionEditor(nodeId: string) {
- throw new Error("Operation 'openBoxedExpressionEditor' is not supported in old GWT based editor");
- }
-
public async undo() {
return this.stateControlService.undo();
}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index 6a9c2fc47c9..27150eb8fb2 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -39,6 +39,8 @@ import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { PanelId, useEditorDockContext } from "../editor/EditorPageDockContextProvider";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
+import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
+import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
enum ButtonPosition {
INPUT,
@@ -325,8 +327,11 @@ export function DmnRunnerDrawerPanelContent(props: { editor: EmbeddedEditorRef |
locale={locale}
notificationsPanel={true}
openExecutionTab={openExecutionTab}
- openBoxedExpressionEditor={(nodeId) => {
- props.editor?.openBoxedExpressionEditor(nodeId);
+ openBoxedExpressionEditor={(nodeId: string) => {
+ const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
+ .envelopeApi as unknown as MessageBusClientApi;
+
+ newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
}}
/>
diff --git a/packages/online-editor/src/envelope/NewDmnEditorEnvelopeApp.ts b/packages/online-editor/src/envelope/NewDmnEditorEnvelopeApp.ts
index 2a7d112a7b6..e74b14280cc 100644
--- a/packages/online-editor/src/envelope/NewDmnEditorEnvelopeApp.ts
+++ b/packages/online-editor/src/envelope/NewDmnEditorEnvelopeApp.ts
@@ -18,10 +18,15 @@
*/
import * as EditorEnvelope from "@kie-tools-core/editor/dist/envelope";
-import { DmnEditorFactory } from "@kie-tools/dmn-editor-envelope/dist/DmnEditorFactory";
+import { DmnEditorInterface } from "@kie-tools/dmn-editor-envelope/dist/DmnEditorFactory";
+import { NewDmnEditorChannelApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorChannelApi";
+import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
+import { NewDmnEditorEnvelopeApiImpl } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApiFactory";
-EditorEnvelope.init({
+EditorEnvelope.initCustom({
container: document.getElementById("envelope-app")!,
- bus: { postMessage: (message, targetOrigin, _) => window.parent.postMessage(message, "*", _) },
- editorFactory: new DmnEditorFactory(),
+ bus: { postMessage: (message, targetOrigin, _) => window.parent.postMessage(message, targetOrigin!, _) },
+ apiImplFactory: {
+ create: (args) => new NewDmnEditorEnvelopeApiImpl(args),
+ },
});
diff --git a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
index e7675935459..67d9f74812b 100644
--- a/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
+++ b/packages/pmml-editor/src/editor/PMMLEditorInterface.tsx
@@ -54,10 +54,6 @@ export class PMMLEditorInterface implements Editor {
);
}
- public openBoxedExpressionEditor(nodeId: string): void {
- throw new Error("Operation 'openBoxedExpressionEditor' is not supported in PMML Editor");
- }
-
public async undo(): Promise {
return this.self.undo();
}
From 3cba7d8d4703624aa928ec3b6a82e0111b673dab Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Tue, 7 Jan 2025 12:04:35 +0100
Subject: [PATCH 08/25] Do not show button for legacy editor
---
.../src/DmnEditorFactory.tsx | 6 +-----
.../src/NewDmnEditorEnvelopeApiFactory.ts | 6 +++---
.../src/NewDmnEditorFactory.tsx | 12 ++++++++---
packages/form-dmn/src/FormDmnOutputs.tsx | 16 ++++++++-------
.../src/dmnRunner/DmnRunnerDrawer.tsx | 6 ++++--
.../dmnRunner/DmnRunnerDrawerPanelContent.tsx | 20 ++++++++++++-------
.../online-editor/src/editor/EditorPage.tsx | 2 +-
.../src/envelope/NewDmnEditorEnvelopeApp.ts | 4 ++--
8 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
index c13a9fefd03..ca44d6f5bcb 100644
--- a/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
+++ b/packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
@@ -42,7 +42,7 @@ export class DmnEditorFactory implements EditorFactory {
return this.self.undo();
}
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
index 3899c779c2a..8c58c9dbdcf 100644
--- a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApiFactory.ts
@@ -20,7 +20,7 @@
import { EnvelopeApiFactoryArgs } from "@kie-tools-core/envelope";
import { EditorEnvelopeViewApi, KogitoEditorEnvelopeApiImpl } from "@kie-tools-core/editor/dist/envelope";
import { KogitoEditorEnvelopeContextType } from "@kie-tools-core/editor/dist/api";
-import { DmnEditorInterface } from "./DmnEditorFactory";
+import { NewDmnEditorInterface } from "./NewDmnEditorFactory";
import { NewDmnEditorEnvelopeApi } from "./NewDmnEditorEnvelopeApi";
import { NewDmnEditorChannelApi } from "./NewDmnEditorChannelApi";
import { NewDmnEditorFactory } from "./NewDmnEditorFactory";
@@ -28,12 +28,12 @@ import { NewDmnEditorFactory } from "./NewDmnEditorFactory";
export type NewDmnEnvelopeApiFactoryArgs = EnvelopeApiFactoryArgs<
NewDmnEditorEnvelopeApi,
NewDmnEditorChannelApi,
- EditorEnvelopeViewApi,
+ EditorEnvelopeViewApi,
KogitoEditorEnvelopeContextType
>;
export class NewDmnEditorEnvelopeApiImpl
- extends KogitoEditorEnvelopeApiImpl
+ extends KogitoEditorEnvelopeApiImpl
implements NewDmnEditorEnvelopeApi
{
constructor(readonly dmnArgs: NewDmnEnvelopeApiFactoryArgs) {
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
index ab5cc84071a..42389ffda0f 100644
--- a/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
@@ -22,11 +22,17 @@ import { EditorFactory, EditorInitArgs, KogitoEditorEnvelopeContextType } from "
import { NewDmnEditorChannelApi } from "./NewDmnEditorChannelApi";
import { DmnEditorInterface } from "./DmnEditorFactory";
-export class NewDmnEditorFactory implements EditorFactory {
+export class NewDmnEditorFactory implements EditorFactory {
public createEditor(
envelopeContext: KogitoEditorEnvelopeContextType,
initArgs: EditorInitArgs
- ): Promise {
- return Promise.resolve(new DmnEditorInterface(envelopeContext, initArgs));
+ ): Promise {
+ return Promise.resolve(new NewDmnEditorInterface(envelopeContext, initArgs));
+ }
+}
+
+export class NewDmnEditorInterface extends DmnEditorInterface {
+ public openBoxedExpressionEditor(nodeId: string): void {
+ this.self.openBoxedExpressionEditor(nodeId);
}
}
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index 5fedc7f9505..fe143392822 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -264,13 +264,15 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
{dmnFormResult.decisionName}
- }
- data-navigate-to-expression-id={dmnFormResult.decisionId}
- onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
- />
+ {props.openBoxedExpressionEditor !== undefined && (
+ }
+ data-navigate-to-expression-id={dmnFormResult.decisionId}
+ onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ />
+ )}
{result(dmnFormResult.result)}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
index d6fe6c52c03..bd3235a26eb 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
@@ -25,7 +25,9 @@ import { DmnRunnerMode } from "./DmnRunnerStatus";
import { DmnRunnerErrorBoundary } from "./DmnRunnerErrorBoundary";
import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
-export function DmnRunnerDrawer(props: React.PropsWithChildren<{ editor: EmbeddedEditorRef | undefined }>) {
+export function DmnRunnerDrawer(
+ props: React.PropsWithChildren<{ editor: EmbeddedEditorRef | undefined; isLegacyDmnEditor: boolean }>
+) {
const dmnRunnerState = useDmnRunnerState();
return (
-
+
}
>
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index 27150eb8fb2..d5c3b5d5225 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -56,7 +56,10 @@ interface DmnRunnerStylesConfig {
buttonPosition: ButtonPosition;
}
-export function DmnRunnerDrawerPanelContent(props: { editor: EmbeddedEditorRef | undefined }) {
+export function DmnRunnerDrawerPanelContent(props: {
+ editor: EmbeddedEditorRef | undefined;
+ isLegacyDmnEditor: boolean;
+}) {
// STATEs
const [drawerError, setDrawerError] = useState(false);
const [dmnRunnerStylesConfig, setDmnRunnerStylesConfig] = useState({
@@ -327,12 +330,15 @@ export function DmnRunnerDrawerPanelContent(props: { editor: EmbeddedEditorRef |
locale={locale}
notificationsPanel={true}
openExecutionTab={openExecutionTab}
- openBoxedExpressionEditor={(nodeId: string) => {
- const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
- .envelopeApi as unknown as MessageBusClientApi;
-
- newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
- }}
+ openBoxedExpressionEditor={
+ !props.isLegacyDmnEditor
+ ? (nodeId: string) => {
+ const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
+ .envelopeApi as unknown as MessageBusClientApi;
+ newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
+ }
+ : undefined
+ }
/>
diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx
index ed8b38f2b97..f07e0e515ad 100644
--- a/packages/online-editor/src/editor/EditorPage.tsx
+++ b/packages/online-editor/src/editor/EditorPage.tsx
@@ -479,7 +479,7 @@ Error details: ${err}`);
-
+
{embeddedEditorFile && (
({
+EditorEnvelope.initCustom({
container: document.getElementById("envelope-app")!,
bus: { postMessage: (message, targetOrigin, _) => window.parent.postMessage(message, targetOrigin!, _) },
apiImplFactory: {
From 000f526aecdb0631d12569cd95113a8945e06a7f Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Tue, 7 Jan 2025 12:10:25 +0100
Subject: [PATCH 09/25] documentation
---
packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts | 4 ++++
packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
index 44f4e2fa1b1..692f3ca8622 100644
--- a/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorEnvelopeApi.ts
@@ -20,5 +20,9 @@
import { KogitoEditorEnvelopeApi } from "@kie-tools-core/editor/dist/api";
export interface NewDmnEditorEnvelopeApi extends KogitoEditorEnvelopeApi {
+ /**
+ * Open boxed expression editor for given node
+ * @param nodeId id of the node to open
+ */
dmnEditor_openBoxedExpressionEditor(nodeId: string): void;
}
diff --git a/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
index 42389ffda0f..ca94144d6c6 100644
--- a/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
+++ b/packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
@@ -32,6 +32,10 @@ export class NewDmnEditorFactory implements EditorFactory
Date: Wed, 8 Jan 2025 11:43:21 +0100
Subject: [PATCH 10/25] Add arrow button
---
.../src/table/BeeTable/BeeTableHeader.tsx | 88 +++++++++++--------
1 file changed, 51 insertions(+), 37 deletions(-)
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index 6b8da177426..4e166969503 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -30,6 +30,9 @@ import { BeeTableThController } from "./BeeTableThController";
import { assertUnreachable } from "../../expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector";
import { InlineEditableTextInput } from "./InlineEditableTextInput";
import { DEFAULT_EXPRESSION_VARIABLE_NAME } from "../../expressionVariable/ExpressionVariableMenu";
+import { Button } from "@patternfly/react-core/dist/js/components/Button";
+import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
export interface BeeTableColumnUpdate {
typeRef: string | undefined;
@@ -229,43 +232,54 @@ export function BeeTableHeader({
}
}}
headerCellInfo={
-
- {column.headerCellElement ? (
- column.headerCellElement
- ) : column.isInlineEditable && !isReadOnly ? (
-
{
- onExpressionHeaderUpdated(
- column,
- columnIndex
- )({ "@_label": value, "@_typeRef": column.dataType });
- }}
- isReadOnly={isReadOnly}
- />
- ) : (
-
- {column.label}
-
- )}
- {column.dataType ? (
-
- ({column.dataType})
-
- ) : null}
-
+
+
+ {column.headerCellElement ? (
+ column.headerCellElement
+ ) : column.isInlineEditable && !isReadOnly ? (
+
{
+ onExpressionHeaderUpdated(
+ column,
+ columnIndex
+ )({ "@_label": value, "@_typeRef": column.dataType });
+ }}
+ isReadOnly={isReadOnly}
+ />
+ ) : (
+
+ {column.label}
+
+ )}
+ {column.dataType ? (
+
+ ({column.dataType})
+
+ ) : null}
+
+ {/* {props.openBoxedExpressionEditor !== undefined && ( */}
+ }
+ // data-navigate-to-expression-id={dmnFormResult.decisionId}
+ // onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ />
+ {/* )} */}
+
}
/>
)}
From de467bec8cc08b65ddd13761503fc212cb6f8a99 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Thu, 9 Jan 2025 08:30:53 +0100
Subject: [PATCH 11/25] handlers
---
.../src/@types/react-table.ts | 2 ++
.../src/table/BeeTable/BeeTableHeader.tsx | 3 +-
.../src/dmnRunner/DmnRunnerTable.tsx | 10 +++++++
.../src/DmnRunnerOutputsTable.tsx | 29 ++++++++++++++++---
4 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index 0b73090593c..738f3ac9268 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -40,6 +40,8 @@ declare module "react-table" {
export interface ColumnInterface {
/** Used by react-table to hold the original id chosen for the column, independently of applied operations */
originalId?: string;
+ decisionId?: string;
+ headerCellClickCallback?: () => void;
/** Column identifier */
accessor: string;
/** Column group type */
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index 4e166969503..dca1c31d7c6 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -276,7 +276,8 @@ export function BeeTableHeader({
// title={`Open ${dmnFormResult.decisionName} expression`}
icon={}
// data-navigate-to-expression-id={dmnFormResult.decisionId}
- // onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ onClick={() => column.headerCellClickCallback?.()}
+ title={column.decisionId}
/>
{/* )} */}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
index fe794958b28..ed87734ce80 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
@@ -32,10 +32,14 @@ import setObjectValueByPath from "lodash/set";
import cloneDeep from "lodash/cloneDeep";
import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
+import { useEditorRef } from "@kie-tools-core/editor/dist/embedded";
+import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
+import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
export function DmnRunnerTable() {
// STATEs
const [dmnRunnerTableError, setDmnRunnerTableError] = useState(false);
+ const { editor } = useEditorRef();
// REFs
const [inputsContainerRef, setInputsContainerRef] = useState(null);
@@ -137,6 +141,12 @@ export function DmnRunnerTable() {
i18n={i18n.dmnRunner.table}
jsonSchemaBridge={jsonSchemaBridge}
results={results}
+ dmnSpecialCallback={(nodeId: string) => {
+ const newDmnEditorEnvelopeApi = editor?.getEnvelopeServer()
+ .envelopeApi as unknown as MessageBusClientApi;
+
+ newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
+ }}
/>
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index 018467a96a4..d2b78006f28 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -50,9 +50,16 @@ interface Props {
results: Array | undefined;
jsonSchemaBridge: DmnUnitablesJsonSchemaBridge;
scrollableParentRef: React.RefObject;
+ dmnSpecialCallback?: (nodeId: string) => void;
}
-export function DmnRunnerOutputsTable({ i18n, jsonSchemaBridge, results, scrollableParentRef }: Props) {
+export function DmnRunnerOutputsTable({
+ i18n,
+ jsonSchemaBridge,
+ results,
+ scrollableParentRef,
+ dmnSpecialCallback,
+}: Props) {
const outputUid = useMemo(() => nextId(), []);
const outputErrorBoundaryRef = useRef(null);
const [outputError, setOutputError] = useState(false);
@@ -80,6 +87,7 @@ export function DmnRunnerOutputsTable({ i18n, jsonSchemaBridge, results, scrolla
outputsPropertiesMap={outputsPropertiesMap}
results={results}
id={outputUid}
+ dmnSpecialCallback={dmnSpecialCallback}
/>
) : (
@@ -129,9 +137,17 @@ interface OutputsTableProps {
results: (DecisionResult[] | undefined)[] | undefined;
outputsPropertiesMap: Map;
scrollableParentRef: React.RefObject;
+ dmnSpecialCallback?: (nodeId: string) => void;
}
-function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollableParentRef }: OutputsTableProps) {
+function OutputsBeeTable({
+ id,
+ i18n,
+ outputsPropertiesMap,
+ results,
+ scrollableParentRef,
+ dmnSpecialCallback,
+}: OutputsTableProps) {
const beeTableOperationConfig = useMemo(
() => [
{
@@ -229,7 +245,7 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
);
const beeTableColumns = useMemo[]>(() => {
- return (results?.[0] ?? []).flatMap(({ result, decisionName }) => {
+ return (results?.[0] ?? []).flatMap(({ result, decisionName, decisionId }) => {
const outputProperties = outputsPropertiesMap.get(decisionName);
if (!outputProperties) {
return [];
@@ -286,6 +302,7 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null) {
return [
{
+ decisionId: decisionId,
originalId: `parent-${outputProperties?.name}-` + generateUuid(),
label: "",
accessor: (`output-parent-${outputProperties?.name}-` + generateUuid()) as any,
@@ -295,7 +312,11 @@ function OutputsBeeTable({ id, i18n, outputsPropertiesMap, results, scrollablePa
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
- originalId: `${outputProperties?.name}-` + generateUuid(),
+ decisionId: decisionId,
+ headerCellClickCallback: () => {
+ dmnSpecialCallback?.(decisionId);
+ },
+ originalId: `${outputProperties?.name}-` + generateUuid() + `${outputProperties?.properties?.id}`,
label: outputProperties?.name ?? "",
accessor: (`output-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
From 7d93fa14c0dd459deb64f9e67b38c9ddecb5109d Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 10 Jan 2025 14:23:25 +0100
Subject: [PATCH 12/25] pass proper editor instance
---
packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx | 7 +++----
packages/online-editor/src/editor/EditorPage.tsx | 1 +
.../src/editor/EditorPageDockContextProvider.tsx | 5 ++++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
index ed87734ce80..997be2e6201 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
@@ -32,14 +32,13 @@ import setObjectValueByPath from "lodash/set";
import cloneDeep from "lodash/cloneDeep";
import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
-import { useEditorRef } from "@kie-tools-core/editor/dist/embedded";
import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
-export function DmnRunnerTable() {
+export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined }) {
// STATEs
const [dmnRunnerTableError, setDmnRunnerTableError] = useState(false);
- const { editor } = useEditorRef();
// REFs
const [inputsContainerRef, setInputsContainerRef] = useState(null);
@@ -142,7 +141,7 @@ export function DmnRunnerTable() {
jsonSchemaBridge={jsonSchemaBridge}
results={results}
dmnSpecialCallback={(nodeId: string) => {
- const newDmnEditorEnvelopeApi = editor?.getEnvelopeServer()
+ const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
.envelopeApi as unknown as MessageBusClientApi;
newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx
index f07e0e515ad..3b8236360b3 100644
--- a/packages/online-editor/src/editor/EditorPage.tsx
+++ b/packages/online-editor/src/editor/EditorPage.tsx
@@ -468,6 +468,7 @@ Error details: ${err}`);
workspaceFile={file.workspaceFile}
workspaces={workspaces}
dmnLanguageService={dmnLanguageService}
+ editor={editor}
isEditorReady={editor?.isReady ?? false}
editorValidate={editor?.validate}
>
diff --git a/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx b/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx
index 692615d5d9e..e4abdd2ce5f 100644
--- a/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx
+++ b/packages/online-editor/src/editor/EditorPageDockContextProvider.tsx
@@ -35,6 +35,7 @@ import { DmnLanguageService } from "@kie-tools/dmn-language-service";
import { DmnRunnerTable } from "../dmnRunner/DmnRunnerTable";
import { ErrorBoundary } from "../reactExt/ErrorBoundary";
import { DmnRunnerErrorBoundary } from "../dmnRunner/DmnRunnerErrorBoundary";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
interface EditorPageDockContextType {
panel: PanelId;
@@ -74,6 +75,7 @@ interface Props {
workspaces: WorkspacesContextType;
dmnLanguageService?: DmnLanguageService;
isEditorReady: boolean;
+ editor: EmbeddedEditorRef | undefined;
editorValidate?: () => Promise;
}
@@ -83,6 +85,7 @@ export function EditorPageDockContextProvider({
workspaces,
workspaceFile,
isEditorReady,
+ editor,
editorValidate,
}: React.PropsWithChildren) {
const { i18n } = useOnlineI18n();
@@ -186,7 +189,7 @@ export function EditorPageDockContextProvider({
case PanelId.DMN_RUNNER_TABLE:
return (
-
+
);
default:
From 64a5a35c7663bb80ea92b04a9d8f963b12728122 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 10 Jan 2025 14:50:22 +0100
Subject: [PATCH 13/25] output columns
---
.../src/@types/react-table.ts | 1 +
.../src/table/BeeTable/BeeTableHeader.tsx | 19 +++++++++----------
.../src/DmnRunnerOutputsTable.tsx | 2 +-
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index 738f3ac9268..a80df179ba2 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -41,6 +41,7 @@ declare module "react-table" {
/** Used by react-table to hold the original id chosen for the column, independently of applied operations */
originalId?: string;
decisionId?: string;
+ decisionName?: string;
headerCellClickCallback?: () => void;
/** Column identifier */
accessor: string;
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index dca1c31d7c6..db104fe4d53 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -270,16 +270,15 @@ export function BeeTableHeader({
) : null}
- {/* {props.openBoxedExpressionEditor !== undefined && ( */}
- }
- // data-navigate-to-expression-id={dmnFormResult.decisionId}
- onClick={() => column.headerCellClickCallback?.()}
- title={column.decisionId}
- />
- {/* )} */}
+ {column.decisionId !== undefined && column.headerCellClickCallback !== undefined && (
+ }
+ // data-navigate-to-expression-id={dmnFormResult.decisionId}
+ onClick={() => column.headerCellClickCallback?.()}
+ />
+ )}
}
/>
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index d2b78006f28..75884b1ad0e 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -302,7 +302,6 @@ function OutputsBeeTable({
if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null) {
return [
{
- decisionId: decisionId,
originalId: `parent-${outputProperties?.name}-` + generateUuid(),
label: "",
accessor: (`output-parent-${outputProperties?.name}-` + generateUuid()) as any,
@@ -312,6 +311,7 @@ function OutputsBeeTable({
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
+ decisionName: decisionName,
decisionId: decisionId,
headerCellClickCallback: () => {
dmnSpecialCallback?.(decisionId);
From 1a230c88fb99a9222e212c30f850b9b51c0d5999 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 10 Jan 2025 15:07:57 +0100
Subject: [PATCH 14/25] all output columns
---
.../unitables-dmn/src/DmnRunnerOutputsTable.tsx | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index 75884b1ad0e..37ffe38e528 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -275,6 +275,11 @@ function OutputsBeeTable({
return deepFlattenObjectColumn(collectedOutput, outputProperties?.properties);
}
return {
+ decisionName: decisionName,
+ decisionId: decisionId,
+ headerCellClickCallback: () => {
+ dmnSpecialCallback?.(decisionId);
+ },
originalId: "context-" + generateUuid(),
label: "context",
accessor: (`output-context-` + generateUuid()) as any,
@@ -333,6 +338,11 @@ function OutputsBeeTable({
if (Array.isArray(result)) {
return [
{
+ decisionName: decisionName,
+ decisionId: decisionId,
+ headerCellClickCallback: () => {
+ dmnSpecialCallback?.(decisionId);
+ },
originalId: `${outputProperties?.name}-` + generateUuid(),
label: `${outputProperties?.name}`,
accessor: (`output-array-parent-${outputProperties?.name}-` + generateUuid()) as any,
@@ -357,6 +367,11 @@ function OutputsBeeTable({
if (typeof result === "object") {
return [
{
+ decisionName: decisionName,
+ decisionId: decisionId,
+ headerCellClickCallback: () => {
+ dmnSpecialCallback?.(decisionId);
+ },
originalId: `${outputProperties?.name}-` + generateUuid(),
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
From fdad8ba207732a5a8ed633ca37b4bbe3257eccd4 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 15 Jan 2025 13:51:07 +0100
Subject: [PATCH 15/25] Fix useMemo dependencies
---
packages/form-dmn/src/FormDmnOutputs.tsx | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index fe143392822..303b8a92ba2 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -67,7 +67,7 @@ export interface FormDmnOutputsProps {
openBoxedExpressionEditor?: (nodeId: string) => void;
}
-export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsProps) {
+export function FormDmnOutputs({ openExecutionTab, openBoxedExpressionEditor, ...props }: FormDmnOutputsProps) {
const [formResultStatus, setFormResultStatus] = useState(FormDmnOutputsStatus.EMPTY);
const [formResultError, setFormResultError] = useState(false);
const i18n = useMemo(() => {
@@ -251,6 +251,13 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
[i18n]
);
+ const onOpenBoxedExpressionEditor = useCallback(
+ (nodeId: string) => {
+ return openBoxedExpressionEditor?.(nodeId);
+ },
+ [openBoxedExpressionEditor]
+ );
+
const resultsToRender = useMemo(
() =>
props.results?.map((dmnFormResult, index) => (
@@ -264,13 +271,13 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
{dmnFormResult.decisionName}
- {props.openBoxedExpressionEditor !== undefined && (
+ {onOpenBoxedExpressionEditor !== undefined && (
}
data-navigate-to-expression-id={dmnFormResult.decisionId}
- onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
+ onClick={() => onOpenBoxedExpressionEditor?.(dmnFormResult.decisionId)}
/>
)}
@@ -280,7 +287,7 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
)),
- [onAnimationEnd, props.results, result, resultStatus]
+ [onAnimationEnd, onOpenBoxedExpressionEditor, props.results, result, resultStatus]
);
const formResultErrorMessage = useMemo(
From ae3d87ce3b08be3ad67eb5b759e8198913c2095b Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 15 Jan 2025 17:22:10 +0100
Subject: [PATCH 16/25] useContext
---
.../src/dmnRunner/DmnRunnerContext.tsx | 3 +++
.../dmnRunner/DmnRunnerContextProvider.tsx | 10 ++++++++
.../src/dmnRunner/DmnRunnerDrawer.tsx | 7 ++----
.../dmnRunner/DmnRunnerDrawerPanelContent.tsx | 23 +++++++++++--------
.../online-editor/src/editor/EditorPage.tsx | 4 +++-
5 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
index 7812fb0ae62..facdf25a6fd 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
@@ -26,6 +26,7 @@ import { InputRow } from "@kie-tools/form-dmn";
import { DecisionResult } from "@kie-tools/extended-services-api";
import { DmnRunnerProviderAction } from "./DmnRunnerTypes";
import type { JSONSchema4 } from "json-schema";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
export interface DmnRunnerContextType {
configs: UnitablesInputsConfigs;
@@ -41,6 +42,8 @@ export interface DmnRunnerContextType {
results: Array;
resultsDifference: Array>;
status: DmnRunnerStatus;
+ dmnEditor: EmbeddedEditorRef | undefined;
+ isLegacyDmnEditor: boolean;
}
export interface DmnRunnerCallbacksContextType {
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
index 7cb82c0e04e..b61470e64d5 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
@@ -73,11 +73,14 @@ import {
import { extractDifferencesFromArray } from "@kie-tools/dmn-runner/dist/results";
import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema";
import type { JSONSchema4 } from "json-schema";
+import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
interface Props {
isEditorReady?: boolean;
workspaceFile: WorkspaceFile;
dmnLanguageService?: DmnLanguageService;
+ dmnEditor: EmbeddedEditorRef | undefined;
+ isLegacyDmnEditor: boolean;
}
const initialDmnRunnerProviderStates: DmnRunnerProviderState = {
@@ -163,6 +166,9 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
const status = useMemo(() => (isExpanded ? DmnRunnerStatus.AVAILABLE : DmnRunnerStatus.UNAVAILABLE), [isExpanded]);
const dmnRunnerAjv = useMemo(() => new DmnRunnerAjv().getAjv(), []);
+ const dmnEditor = useMemo(() => props.dmnEditor, [props.dmnEditor]);
+ const isLegacyDmnEditor = useMemo(() => props.isLegacyDmnEditor, [props.isLegacyDmnEditor]);
+
useLayoutEffect(() => {
if (props.isEditorReady) {
setCanBeVisualized(true);
@@ -708,6 +714,8 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
results,
resultsDifference,
status,
+ dmnEditor,
+ isLegacyDmnEditor,
}),
[
canBeVisualized,
@@ -723,6 +731,8 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
results,
resultsDifference,
status,
+ dmnEditor,
+ isLegacyDmnEditor,
]
);
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
index bd3235a26eb..aba841edf2e 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
@@ -23,11 +23,8 @@ import { Drawer, DrawerContent, DrawerContentBody } from "@patternfly/react-core
import { useDmnRunnerState } from "./DmnRunnerContext";
import { DmnRunnerMode } from "./DmnRunnerStatus";
import { DmnRunnerErrorBoundary } from "./DmnRunnerErrorBoundary";
-import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
-export function DmnRunnerDrawer(
- props: React.PropsWithChildren<{ editor: EmbeddedEditorRef | undefined; isLegacyDmnEditor: boolean }>
-) {
+export function DmnRunnerDrawer(props: React.PropsWithChildren<{}>) {
const dmnRunnerState = useDmnRunnerState();
return (
-
+
}
>
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index d5c3b5d5225..05785fa6c88 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -38,7 +38,6 @@ import { DmnRunnerLoading } from "./DmnRunnerLoading";
import { DmnRunnerProviderActionType } from "./DmnRunnerTypes";
import { PanelId, useEditorDockContext } from "../editor/EditorPageDockContextProvider";
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
-import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
@@ -56,10 +55,7 @@ interface DmnRunnerStylesConfig {
buttonPosition: ButtonPosition;
}
-export function DmnRunnerDrawerPanelContent(props: {
- editor: EmbeddedEditorRef | undefined;
- isLegacyDmnEditor: boolean;
-}) {
+export function DmnRunnerDrawerPanelContent() {
// STATEs
const [drawerError, setDrawerError] = useState(false);
const [dmnRunnerStylesConfig, setDmnRunnerStylesConfig] = useState({
@@ -71,8 +67,17 @@ export function DmnRunnerDrawerPanelContent(props: {
const [rowSelectionIsOpen, openRowSelection] = useState(false);
const { i18n, locale } = useOnlineI18n();
- const { currentInputIndex, dmnRunnerKey, extendedServicesError, inputs, jsonSchema, results, resultsDifference } =
- useDmnRunnerState();
+ const {
+ currentInputIndex,
+ dmnRunnerKey,
+ extendedServicesError,
+ inputs,
+ jsonSchema,
+ results,
+ resultsDifference,
+ dmnEditor,
+ isLegacyDmnEditor,
+ } = useDmnRunnerState();
const { setDmnRunnerContextProviderState, onRowAdded, setDmnRunnerInputs, setDmnRunnerMode } = useDmnRunnerDispatch();
const { notificationsPanel, onOpenPanel } = useEditorDockContext();
@@ -331,9 +336,9 @@ export function DmnRunnerDrawerPanelContent(props: {
notificationsPanel={true}
openExecutionTab={openExecutionTab}
openBoxedExpressionEditor={
- !props.isLegacyDmnEditor
+ !isLegacyDmnEditor
? (nodeId: string) => {
- const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
+ const newDmnEditorEnvelopeApi = dmnEditor?.getEnvelopeServer()
.envelopeApi as unknown as MessageBusClientApi;
newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
}
diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx
index f07e0e515ad..91c32b77e76 100644
--- a/packages/online-editor/src/editor/EditorPage.tsx
+++ b/packages/online-editor/src/editor/EditorPage.tsx
@@ -475,11 +475,13 @@ Error details: ${err}`);
workspaceFile={file.workspaceFile}
isEditorReady={editor?.isReady}
dmnLanguageService={dmnLanguageService}
+ dmnEditor={editor}
+ isLegacyDmnEditor={settings.editors.useLegacyDmnEditor}
>
-
+
{embeddedEditorFile && (
Date: Tue, 21 Jan 2025 13:31:43 +0100
Subject: [PATCH 17/25] useSettings to obtain isLegacyDMNeditor
---
.../online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx | 5 +++--
packages/online-editor/src/editor/EditorPage.tsx | 1 -
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
index b61470e64d5..88656c9420f 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
@@ -74,13 +74,13 @@ import { extractDifferencesFromArray } from "@kie-tools/dmn-runner/dist/results"
import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema";
import type { JSONSchema4 } from "json-schema";
import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
+import { useSettings } from "../settings/SettingsContext";
interface Props {
isEditorReady?: boolean;
workspaceFile: WorkspaceFile;
dmnLanguageService?: DmnLanguageService;
dmnEditor: EmbeddedEditorRef | undefined;
- isLegacyDmnEditor: boolean;
}
const initialDmnRunnerProviderStates: DmnRunnerProviderState = {
@@ -167,7 +167,8 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
const dmnRunnerAjv = useMemo(() => new DmnRunnerAjv().getAjv(), []);
const dmnEditor = useMemo(() => props.dmnEditor, [props.dmnEditor]);
- const isLegacyDmnEditor = useMemo(() => props.isLegacyDmnEditor, [props.isLegacyDmnEditor]);
+ const { settings } = useSettings();
+ const isLegacyDmnEditor = useMemo(() => settings.editors.useLegacyDmnEditor, [settings.editors.useLegacyDmnEditor]);
useLayoutEffect(() => {
if (props.isEditorReady) {
diff --git a/packages/online-editor/src/editor/EditorPage.tsx b/packages/online-editor/src/editor/EditorPage.tsx
index 91c32b77e76..e0ba6b6f63f 100644
--- a/packages/online-editor/src/editor/EditorPage.tsx
+++ b/packages/online-editor/src/editor/EditorPage.tsx
@@ -476,7 +476,6 @@ Error details: ${err}`);
isEditorReady={editor?.isReady}
dmnLanguageService={dmnLanguageService}
dmnEditor={editor}
- isLegacyDmnEditor={settings.editors.useLegacyDmnEditor}
>
From e1045a27e2caafcde8a29fb968b5ff59470e71c4 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Tue, 21 Jan 2025 16:03:58 +0100
Subject: [PATCH 18/25] use Flex and column vertical alignment
---
.../src/table/BeeTable/BeeTableHeader.tsx | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index db104fe4d53..158064009d5 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -271,13 +271,14 @@ export function BeeTableHeader({
) : null}
{column.decisionId !== undefined && column.headerCellClickCallback !== undefined && (
- }
- // data-navigate-to-expression-id={dmnFormResult.decisionId}
- onClick={() => column.headerCellClickCallback?.()}
- />
+
+ }
+ onClick={() => column.headerCellClickCallback?.()}
+ />
+
)}
}
From f6334edb04b9e62f85612429560fb4aa892e0925 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Wed, 22 Jan 2025 08:51:08 +0100
Subject: [PATCH 19/25] clean up passed props
---
.../online-editor/src/dmnRunner/DmnRunnerContext.tsx | 1 -
.../src/dmnRunner/DmnRunnerContextProvider.tsx | 11 ++---------
.../src/dmnRunner/DmnRunnerDrawerPanelContent.tsx | 5 ++++-
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
index facdf25a6fd..fcbbda6d9ac 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerContext.tsx
@@ -43,7 +43,6 @@ export interface DmnRunnerContextType {
resultsDifference: Array>;
status: DmnRunnerStatus;
dmnEditor: EmbeddedEditorRef | undefined;
- isLegacyDmnEditor: boolean;
}
export interface DmnRunnerCallbacksContextType {
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
index 88656c9420f..e14ba93af5c 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx
@@ -74,7 +74,6 @@ import { extractDifferencesFromArray } from "@kie-tools/dmn-runner/dist/results"
import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema";
import type { JSONSchema4 } from "json-schema";
import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
-import { useSettings } from "../settings/SettingsContext";
interface Props {
isEditorReady?: boolean;
@@ -166,10 +165,6 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
const status = useMemo(() => (isExpanded ? DmnRunnerStatus.AVAILABLE : DmnRunnerStatus.UNAVAILABLE), [isExpanded]);
const dmnRunnerAjv = useMemo(() => new DmnRunnerAjv().getAjv(), []);
- const dmnEditor = useMemo(() => props.dmnEditor, [props.dmnEditor]);
- const { settings } = useSettings();
- const isLegacyDmnEditor = useMemo(() => settings.editors.useLegacyDmnEditor, [settings.editors.useLegacyDmnEditor]);
-
useLayoutEffect(() => {
if (props.isEditorReady) {
setCanBeVisualized(true);
@@ -715,8 +710,7 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
results,
resultsDifference,
status,
- dmnEditor,
- isLegacyDmnEditor,
+ dmnEditor: props.dmnEditor,
}),
[
canBeVisualized,
@@ -732,8 +726,7 @@ export function DmnRunnerContextProvider(props: PropsWithChildren) {
results,
resultsDifference,
status,
- dmnEditor,
- isLegacyDmnEditor,
+ props.dmnEditor,
]
);
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
index 05785fa6c88..cc3b3ad7086 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerDrawerPanelContent.tsx
@@ -40,6 +40,7 @@ import { PanelId, useEditorDockContext } from "../editor/EditorPageDockContextPr
import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
+import { useSettings } from "../settings/SettingsContext";
enum ButtonPosition {
INPUT,
@@ -76,13 +77,15 @@ export function DmnRunnerDrawerPanelContent() {
results,
resultsDifference,
dmnEditor,
- isLegacyDmnEditor,
} = useDmnRunnerState();
const { setDmnRunnerContextProviderState, onRowAdded, setDmnRunnerInputs, setDmnRunnerMode } = useDmnRunnerDispatch();
const { notificationsPanel, onOpenPanel } = useEditorDockContext();
const formInputs: InputRow = useMemo(() => inputs[currentInputIndex], [inputs, currentInputIndex]);
+ const { settings } = useSettings();
+ const isLegacyDmnEditor = useMemo(() => settings.editors.useLegacyDmnEditor, [settings.editors.useLegacyDmnEditor]);
+
const onResize = useCallback((width: number) => {
// FIXME: PatternFly bug. The first interaction without resizing the splitter will result in width === 0.
if (width === 0) {
From f2e83797c22b2f8dae942d5253c8ca2ffd8ce334 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Thu, 23 Jan 2025 09:51:42 +0100
Subject: [PATCH 20/25] simplify properties
---
.../src/@types/react-table.ts | 2 --
.../src/table/BeeTable/BeeTableHeader.tsx | 6 ++---
packages/form-dmn/src/FormDmnOutputs.tsx | 3 +--
.../src/dmnRunner/DmnRunnerTable.tsx | 22 +++++++++++-----
.../src/DmnRunnerOutputsTable.tsx | 26 +++++++------------
5 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index a80df179ba2..7e064cfb36f 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -40,8 +40,6 @@ declare module "react-table" {
export interface ColumnInterface {
/** Used by react-table to hold the original id chosen for the column, independently of applied operations */
originalId?: string;
- decisionId?: string;
- decisionName?: string;
headerCellClickCallback?: () => void;
/** Column identifier */
accessor: string;
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index 158064009d5..97683b2b40d 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -270,12 +270,12 @@ export function BeeTableHeader({
) : null}
- {column.decisionId !== undefined && column.headerCellClickCallback !== undefined && (
+ {column.headerCellClickCallback !== undefined && (
}
+ title={`Open '${column.label}' expression`}
+ icon={}
onClick={() => column.headerCellClickCallback?.()}
/>
diff --git a/packages/form-dmn/src/FormDmnOutputs.tsx b/packages/form-dmn/src/FormDmnOutputs.tsx
index 303b8a92ba2..a6f3e037568 100644
--- a/packages/form-dmn/src/FormDmnOutputs.tsx
+++ b/packages/form-dmn/src/FormDmnOutputs.tsx
@@ -274,9 +274,8 @@ export function FormDmnOutputs({ openExecutionTab, openBoxedExpressionEditor, ..
{onOpenBoxedExpressionEditor !== undefined && (
}
- data-navigate-to-expression-id={dmnFormResult.decisionId}
onClick={() => onOpenBoxedExpressionEditor?.(dmnFormResult.decisionId)}
/>
)}
diff --git a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
index 997be2e6201..f0d2a95f929 100644
--- a/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
+++ b/packages/online-editor/src/dmnRunner/DmnRunnerTable.tsx
@@ -35,6 +35,7 @@ import { DmnRunnerExtendedServicesError } from "./DmnRunnerContextProvider";
import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api";
import { NewDmnEditorEnvelopeApi } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorEnvelopeApi";
import { EmbeddedEditorRef } from "@kie-tools-core/editor/dist/embedded";
+import { useSettings } from "../settings/SettingsContext";
export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined }) {
// STATEs
@@ -116,6 +117,9 @@ export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined })
setDmnRunnerTableError(false);
}, [jsonSchema]);
+ const { settings } = useSettings();
+ const isLegacyDmnEditor = useMemo(() => settings.editors.useLegacyDmnEditor, [settings.editors.useLegacyDmnEditor]);
+
return (
<>
{extendedServicesError ? (
@@ -140,12 +144,18 @@ export function DmnRunnerTable(props: { editor: EmbeddedEditorRef | undefined })
i18n={i18n.dmnRunner.table}
jsonSchemaBridge={jsonSchemaBridge}
results={results}
- dmnSpecialCallback={(nodeId: string) => {
- const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
- .envelopeApi as unknown as MessageBusClientApi;
-
- newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
- }}
+ openBoxedExpressionEditor={
+ !isLegacyDmnEditor
+ ? (nodeId: string) => {
+ const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
+ .envelopeApi as unknown as MessageBusClientApi;
+
+ newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(
+ nodeId
+ );
+ }
+ : undefined
+ }
/>
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index 37ffe38e528..234b9ac9620 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -50,7 +50,7 @@ interface Props {
results: Array | undefined;
jsonSchemaBridge: DmnUnitablesJsonSchemaBridge;
scrollableParentRef: React.RefObject;
- dmnSpecialCallback?: (nodeId: string) => void;
+ openBoxedExpressionEditor?: (nodeId: string) => void;
}
export function DmnRunnerOutputsTable({
@@ -58,7 +58,7 @@ export function DmnRunnerOutputsTable({
jsonSchemaBridge,
results,
scrollableParentRef,
- dmnSpecialCallback,
+ openBoxedExpressionEditor,
}: Props) {
const outputUid = useMemo(() => nextId(), []);
const outputErrorBoundaryRef = useRef(null);
@@ -87,7 +87,7 @@ export function DmnRunnerOutputsTable({
outputsPropertiesMap={outputsPropertiesMap}
results={results}
id={outputUid}
- dmnSpecialCallback={dmnSpecialCallback}
+ openBoxedExpressionEditor={openBoxedExpressionEditor}
/>
) : (
@@ -137,7 +137,7 @@ interface OutputsTableProps {
results: (DecisionResult[] | undefined)[] | undefined;
outputsPropertiesMap: Map;
scrollableParentRef: React.RefObject;
- dmnSpecialCallback?: (nodeId: string) => void;
+ openBoxedExpressionEditor?: (nodeId: string) => void;
}
function OutputsBeeTable({
@@ -146,7 +146,7 @@ function OutputsBeeTable({
outputsPropertiesMap,
results,
scrollableParentRef,
- dmnSpecialCallback,
+ openBoxedExpressionEditor,
}: OutputsTableProps) {
const beeTableOperationConfig = useMemo(
() => [
@@ -275,10 +275,8 @@ function OutputsBeeTable({
return deepFlattenObjectColumn(collectedOutput, outputProperties?.properties);
}
return {
- decisionName: decisionName,
- decisionId: decisionId,
headerCellClickCallback: () => {
- dmnSpecialCallback?.(decisionId);
+ openBoxedExpressionEditor?.(decisionId);
},
originalId: "context-" + generateUuid(),
label: "context",
@@ -316,10 +314,8 @@ function OutputsBeeTable({
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
- decisionName: decisionName,
- decisionId: decisionId,
headerCellClickCallback: () => {
- dmnSpecialCallback?.(decisionId);
+ openBoxedExpressionEditor?.(decisionId);
},
originalId: `${outputProperties?.name}-` + generateUuid() + `${outputProperties?.properties?.id}`,
label: outputProperties?.name ?? "",
@@ -338,10 +334,8 @@ function OutputsBeeTable({
if (Array.isArray(result)) {
return [
{
- decisionName: decisionName,
- decisionId: decisionId,
headerCellClickCallback: () => {
- dmnSpecialCallback?.(decisionId);
+ openBoxedExpressionEditor?.(decisionId);
},
originalId: `${outputProperties?.name}-` + generateUuid(),
label: `${outputProperties?.name}`,
@@ -367,10 +361,8 @@ function OutputsBeeTable({
if (typeof result === "object") {
return [
{
- decisionName: decisionName,
- decisionId: decisionId,
headerCellClickCallback: () => {
- dmnSpecialCallback?.(decisionId);
+ openBoxedExpressionEditor?.(decisionId);
},
originalId: `${outputProperties?.name}-` + generateUuid(),
label: outputProperties?.name ?? "",
From 28ce164d308403869c7398b39dd14373e047a7ea Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Thu, 23 Jan 2025 11:47:11 +0100
Subject: [PATCH 21/25] simplify props
---
.../src/@types/react-table.ts | 1 -
.../src/table/BeeTable/BeeTableHeader.tsx | 4 +-
.../src/DmnRunnerOutputsTable.tsx | 38 +++++++++----------
3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index 7e064cfb36f..0b73090593c 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -40,7 +40,6 @@ declare module "react-table" {
export interface ColumnInterface {
/** Used by react-table to hold the original id chosen for the column, independently of applied operations */
originalId?: string;
- headerCellClickCallback?: () => void;
/** Column identifier */
accessor: string;
/** Column group type */
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index 97683b2b40d..d38f0e0bfe9 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -270,13 +270,13 @@ export function BeeTableHeader({
) : null}
- {column.headerCellClickCallback !== undefined && (
+ {column.groupType === "dmn-runner-output" && !column.columns && (
}
- onClick={() => column.headerCellClickCallback?.()}
+ onClick={() => onHeaderClick?.(column.originalId ?? "")}
/>
)}
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index 234b9ac9620..7e880790f62 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -261,7 +261,7 @@ function OutputsBeeTable({
);
return [
{
- originalId: `${outputProperties?.name}-` + generateUuid(),
+ originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType,
@@ -275,10 +275,7 @@ function OutputsBeeTable({
return deepFlattenObjectColumn(collectedOutput, outputProperties?.properties);
}
return {
- headerCellClickCallback: () => {
- openBoxedExpressionEditor?.(decisionId);
- },
- originalId: "context-" + generateUuid(),
+ originalId: `context-${generateUuid()}-${decisionId}`,
label: "context",
accessor: (`output-context-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Any,
@@ -305,7 +302,7 @@ function OutputsBeeTable({
if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null) {
return [
{
- originalId: `parent-${outputProperties?.name}-` + generateUuid(),
+ originalId: `parent-${outputProperties?.name}-${generateUuid()}-${decisionId}`,
label: "",
accessor: (`output-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: undefined as any,
@@ -314,10 +311,7 @@ function OutputsBeeTable({
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
- headerCellClickCallback: () => {
- openBoxedExpressionEditor?.(decisionId);
- },
- originalId: `${outputProperties?.name}-` + generateUuid() + `${outputProperties?.properties?.id}`,
+ originalId: `${outputProperties?.name}-${generateUuid()}-${outputProperties?.properties?.id}-${decisionId}`,
label: outputProperties?.name ?? "",
accessor: (`output-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
@@ -334,17 +328,14 @@ function OutputsBeeTable({
if (Array.isArray(result)) {
return [
{
- headerCellClickCallback: () => {
- openBoxedExpressionEditor?.(decisionId);
- },
- originalId: `${outputProperties?.name}-` + generateUuid(),
+ originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
label: `${outputProperties?.name}`,
accessor: (`output-array-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
isRowIndexColumn: false,
groupType: "dmn-runner-output",
columns: result.map((entry, entryIndex) => ({
- originalId: `${entryIndex}-` + generateUuid(),
+ originalId: `${entryIndex}-${generateUuid()}-${decisionId}`,
label: `[${entryIndex}]`,
accessor: (`output-array-${entryIndex}-` + generateUuid()) as any,
dataType: undefined as any,
@@ -361,10 +352,7 @@ function OutputsBeeTable({
if (typeof result === "object") {
return [
{
- headerCellClickCallback: () => {
- openBoxedExpressionEditor?.(decisionId);
- },
- originalId: `${outputProperties?.name}-` + generateUuid(),
+ originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
@@ -427,6 +415,17 @@ function OutputsBeeTable({
return [BeeTableOperation.SelectionCopy];
}, []);
+ const onOpenBoxedExpressionHeaderButtonClick = useCallback(
+ (columnKey: string) => {
+ (results?.[0] ?? []).flatMap(({ decisionId }) => {
+ if (columnKey.includes(decisionId)) {
+ openBoxedExpressionEditor?.(decisionId);
+ }
+ });
+ },
+ [openBoxedExpressionEditor, results]
+ );
+
return (
Date: Fri, 24 Jan 2025 11:49:52 +0100
Subject: [PATCH 22/25] refactor props
---
.../src/@types/react-table.ts | 2 +
.../src/table/BeeTable/BeeTableHeader.tsx | 11 +----
.../src/DmnRunnerOutputsTable.tsx | 45 +++++++++++++------
3 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index 0b73090593c..e09a14dff12 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -50,6 +50,8 @@ declare module "react-table" {
label: string;
/** Custom Element to be rendered in place of the column label */
headerCellElement?: JSX.Element;
+ /** Additional Element to be rendered next to the Header Cell Element */
+ headerCellElementExtension?: JSX.Element;
/** It makes this column header inline editable (with double-click) */
isInlineEditable?: boolean;
/** Column data type */
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index d38f0e0bfe9..eee193f044d 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -30,8 +30,6 @@ import { BeeTableThController } from "./BeeTableThController";
import { assertUnreachable } from "../../expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector";
import { InlineEditableTextInput } from "./InlineEditableTextInput";
import { DEFAULT_EXPRESSION_VARIABLE_NAME } from "../../expressionVariable/ExpressionVariableMenu";
-import { Button } from "@patternfly/react-core/dist/js/components/Button";
-import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
export interface BeeTableColumnUpdate {
@@ -270,14 +268,9 @@ export function BeeTableHeader({
) : null}
- {column.groupType === "dmn-runner-output" && !column.columns && (
+ {column.headerCellElementExtension !== undefined && (
- }
- onClick={() => onHeaderClick?.(column.originalId ?? "")}
- />
+ {column.headerCellElementExtension}
)}
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index 7e880790f62..ef830d76b62 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -44,6 +44,8 @@ import "@kie-tools/boxed-expression-component/dist/@types/react-table";
import { ResizerStopBehavior } from "@kie-tools/boxed-expression-component/dist/resizing/ResizingWidthsContext";
import "./DmnRunnerOutputsTable.css";
import { DecisionResult, DmnEvaluationResult } from "@kie-tools/extended-services-api";
+import { Button } from "@patternfly/react-core/dist/js/components/Button";
+import { ArrowUpIcon } from "@patternfly/react-icons/dist/js/icons/arrow-up-icon";
interface Props {
i18n: DmnUnitablesI18n;
@@ -244,6 +246,31 @@ function OutputsBeeTable({
[getRowValue]
);
+ const onOpenBoxedExpressionHeaderButtonClick = useCallback(
+ (columnKey: string) => {
+ (results?.[0] ?? []).flatMap(({ decisionId }) => {
+ if (columnKey.includes(decisionId)) {
+ openBoxedExpressionEditor?.(decisionId);
+ }
+ });
+ },
+ [openBoxedExpressionEditor, results]
+ );
+
+ const openBoxedExpressionHeaderButton = useCallback(
+ ({ decisionId, decisionName }) => {
+ return (
+ }
+ onClick={() => onOpenBoxedExpressionHeaderButtonClick(decisionId)}
+ />
+ );
+ },
+ [onOpenBoxedExpressionHeaderButtonClick]
+ );
+
const beeTableColumns = useMemo[]>(() => {
return (results?.[0] ?? []).flatMap(({ result, decisionName, decisionId }) => {
const outputProperties = outputsPropertiesMap.get(decisionName);
@@ -262,6 +289,7 @@ function OutputsBeeTable({
return [
{
originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType,
@@ -312,6 +340,7 @@ function OutputsBeeTable({
columns: [
{
originalId: `${outputProperties?.name}-${generateUuid()}-${outputProperties?.properties?.id}-${decisionId}`,
+ headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
@@ -329,6 +358,7 @@ function OutputsBeeTable({
return [
{
originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: `${outputProperties?.name}`,
accessor: (`output-array-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
@@ -353,6 +383,7 @@ function OutputsBeeTable({
return [
{
originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Undefined,
@@ -365,7 +396,7 @@ function OutputsBeeTable({
}
return [] as ReactTable.Column[];
});
- }, [deepFlattenObjectColumn, outputsPropertiesMap, results]);
+ }, [deepFlattenObjectColumn, openBoxedExpressionHeaderButton, outputsPropertiesMap, results]);
const beeTableRows = useMemo(() => {
return (results ?? []).map((decisionResult, rowIndex) => {
@@ -415,17 +446,6 @@ function OutputsBeeTable({
return [BeeTableOperation.SelectionCopy];
}, []);
- const onOpenBoxedExpressionHeaderButtonClick = useCallback(
- (columnKey: string) => {
- (results?.[0] ?? []).flatMap(({ decisionId }) => {
- if (columnKey.includes(decisionId)) {
- openBoxedExpressionEditor?.(decisionId);
- }
- });
- },
- [openBoxedExpressionEditor, results]
- );
-
return (
Date: Fri, 24 Jan 2025 12:32:54 +0100
Subject: [PATCH 23/25] do not use decisionId in columnKey
---
.../unitables-dmn/src/DmnRunnerOutputsTable.tsx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index ef830d76b62..ad953eba7c7 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -288,7 +288,7 @@ function OutputsBeeTable({
);
return [
{
- originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ originalId: `${outputProperties?.name}-${generateUuid()}`,
headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
@@ -303,7 +303,7 @@ function OutputsBeeTable({
return deepFlattenObjectColumn(collectedOutput, outputProperties?.properties);
}
return {
- originalId: `context-${generateUuid()}-${decisionId}`,
+ originalId: `context-${generateUuid()}`,
label: "context",
accessor: (`output-context-` + generateUuid()) as any,
dataType: outputProperties?.dataType ?? DmnBuiltInDataType.Any,
@@ -330,7 +330,7 @@ function OutputsBeeTable({
if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null) {
return [
{
- originalId: `parent-${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ originalId: `parent-${outputProperties?.name}-${generateUuid()}`,
label: "",
accessor: (`output-parent-${outputProperties?.name}-` + generateUuid()) as any,
dataType: undefined as any,
@@ -339,7 +339,7 @@ function OutputsBeeTable({
minWidth: DMN_RUNNER_OUTPUT_COLUMN_MIN_WIDTH,
columns: [
{
- originalId: `${outputProperties?.name}-${generateUuid()}-${outputProperties?.properties?.id}-${decisionId}`,
+ originalId: `${outputProperties?.name}-${generateUuid()}-${outputProperties?.properties?.id}`,
headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-${outputProperties?.name}-` + generateUuid()) as any,
@@ -357,7 +357,7 @@ function OutputsBeeTable({
if (Array.isArray(result)) {
return [
{
- originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ originalId: `${outputProperties?.name}-${generateUuid()}`,
headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: `${outputProperties?.name}`,
accessor: (`output-array-parent-${outputProperties?.name}-` + generateUuid()) as any,
@@ -365,7 +365,7 @@ function OutputsBeeTable({
isRowIndexColumn: false,
groupType: "dmn-runner-output",
columns: result.map((entry, entryIndex) => ({
- originalId: `${entryIndex}-${generateUuid()}-${decisionId}`,
+ originalId: `${entryIndex}-${generateUuid()}`,
label: `[${entryIndex}]`,
accessor: (`output-array-${entryIndex}-` + generateUuid()) as any,
dataType: undefined as any,
@@ -382,7 +382,7 @@ function OutputsBeeTable({
if (typeof result === "object") {
return [
{
- originalId: `${outputProperties?.name}-${generateUuid()}-${decisionId}`,
+ originalId: `${outputProperties?.name}-${generateUuid()}`,
headerCellElementExtension: openBoxedExpressionHeaderButton({ decisionId, decisionName }),
label: outputProperties?.name ?? "",
accessor: (`output-object-parent-${outputProperties?.name}-` + generateUuid()) as any,
From fab6f0a76a6048b0ab70e3ae5d3e3d131dc71472 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Fri, 24 Jan 2025 13:13:06 +0100
Subject: [PATCH 24/25] better callback parameters names
---
packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
index ad953eba7c7..ce191bd3df1 100644
--- a/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
+++ b/packages/unitables-dmn/src/DmnRunnerOutputsTable.tsx
@@ -247,10 +247,10 @@ function OutputsBeeTable({
);
const onOpenBoxedExpressionHeaderButtonClick = useCallback(
- (columnKey: string) => {
- (results?.[0] ?? []).flatMap(({ decisionId }) => {
- if (columnKey.includes(decisionId)) {
- openBoxedExpressionEditor?.(decisionId);
+ (clickedDecisionId: string) => {
+ (results?.[0] ?? []).flatMap(({ decisionId: resultDecisionId }) => {
+ if (clickedDecisionId === resultDecisionId) {
+ openBoxedExpressionEditor?.(resultDecisionId);
}
});
},
From ed1d20b765a31c8c71551f09569a2c88aa8240a9 Mon Sep 17 00:00:00 2001
From: Jozef Marko
Date: Mon, 27 Jan 2025 12:31:06 +0100
Subject: [PATCH 25/25] use position absolute top right
---
.../src/@types/react-table.ts | 2 +-
.../src/BoxedExpressionEditorContext.css | 6 ++
.../src/table/BeeTable/BeeTableHeader.tsx | 81 +++++++++----------
3 files changed, 46 insertions(+), 43 deletions(-)
diff --git a/packages/boxed-expression-component/src/@types/react-table.ts b/packages/boxed-expression-component/src/@types/react-table.ts
index e09a14dff12..e122fa95fa8 100644
--- a/packages/boxed-expression-component/src/@types/react-table.ts
+++ b/packages/boxed-expression-component/src/@types/react-table.ts
@@ -50,7 +50,7 @@ declare module "react-table" {
label: string;
/** Custom Element to be rendered in place of the column label */
headerCellElement?: JSX.Element;
- /** Additional Element to be rendered next to the Header Cell Element */
+ /** Additional Element to be rendered in the Header Cell top right corner */
headerCellElementExtension?: JSX.Element;
/** It makes this column header inline editable (with double-click) */
isInlineEditable?: boolean;
diff --git a/packages/boxed-expression-component/src/BoxedExpressionEditorContext.css b/packages/boxed-expression-component/src/BoxedExpressionEditorContext.css
index b94775fdf86..1147841c52c 100644
--- a/packages/boxed-expression-component/src/BoxedExpressionEditorContext.css
+++ b/packages/boxed-expression-component/src/BoxedExpressionEditorContext.css
@@ -99,3 +99,9 @@
font-size: smaller;
color: #1b515f;
}
+
+.kie-tools--bee--header-cell-element-extension {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index eee193f044d..af870ac7264 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -30,7 +30,6 @@ import { BeeTableThController } from "./BeeTableThController";
import { assertUnreachable } from "../../expressions/ExpressionDefinitionRoot/ExpressionDefinitionLogicTypeSelector";
import { InlineEditableTextInput } from "./InlineEditableTextInput";
import { DEFAULT_EXPRESSION_VARIABLE_NAME } from "../../expressionVariable/ExpressionVariableMenu";
-import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
export interface BeeTableColumnUpdate {
typeRef: string | undefined;
@@ -230,50 +229,48 @@ export function BeeTableHeader({
}
}}
headerCellInfo={
-
-
- {column.headerCellElement ? (
- column.headerCellElement
- ) : column.isInlineEditable && !isReadOnly ? (
-
{
- onExpressionHeaderUpdated(
- column,
- columnIndex
- )({ "@_label": value, "@_typeRef": column.dataType });
- }}
- isReadOnly={isReadOnly}
- />
- ) : (
-
- {column.label}
-
- )}
- {column.dataType ? (
-
- ({column.dataType})
-
- ) : null}
-
+
+ {column.headerCellElement ? (
+ column.headerCellElement
+ ) : column.isInlineEditable && !isReadOnly ? (
+
{
+ onExpressionHeaderUpdated(
+ column,
+ columnIndex
+ )({ "@_label": value, "@_typeRef": column.dataType });
+ }}
+ isReadOnly={isReadOnly}
+ />
+ ) : (
+
+ {column.label}
+
+ )}
+ {column.dataType ? (
+
+ ({column.dataType})
+
+ ) : null}
{column.headerCellElementExtension !== undefined && (
-
+
{column.headerCellElementExtension}
-
+
)}
-
+
}
/>
)}