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