Skip to content

Commit

Permalink
Do not show button for legacy editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Jan 7, 2025
1 parent 77be060 commit 3cba7d8
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
6 changes: 1 addition & 5 deletions packages/dmn-editor-envelope/src/DmnEditorFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DmnEditorFactory implements EditorFactory<Editor, KogitoEditorChann
}

export class DmnEditorInterface implements Editor {
private self: DmnEditorRoot;
protected self: DmnEditorRoot;
public af_isReact = true;
public af_componentId: "dmn-editor";
public af_componentTitle: "DMN Editor";
Expand All @@ -68,10 +68,6 @@ export class DmnEditorInterface implements Editor {
return Promise.resolve(); // No-op for now. The DMN Editor only has the LIGHT theme.
}

public openBoxedExpressionEditor(nodeId: string): void {
this.self.openBoxedExpressionEditor(nodeId);
}

public async undo(): Promise<void> {
return this.self.undo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
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";

export type NewDmnEnvelopeApiFactoryArgs = EnvelopeApiFactoryArgs<
NewDmnEditorEnvelopeApi,
NewDmnEditorChannelApi,
EditorEnvelopeViewApi<DmnEditorInterface>,
EditorEnvelopeViewApi<NewDmnEditorInterface>,
KogitoEditorEnvelopeContextType<NewDmnEditorChannelApi>
>;

export class NewDmnEditorEnvelopeApiImpl
extends KogitoEditorEnvelopeApiImpl<DmnEditorInterface, NewDmnEditorEnvelopeApi, NewDmnEditorChannelApi>
extends KogitoEditorEnvelopeApiImpl<NewDmnEditorInterface, NewDmnEditorEnvelopeApi, NewDmnEditorChannelApi>
implements NewDmnEditorEnvelopeApi
{
constructor(readonly dmnArgs: NewDmnEnvelopeApiFactoryArgs) {
Expand Down
12 changes: 9 additions & 3 deletions packages/dmn-editor-envelope/src/NewDmnEditorFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ import { EditorFactory, EditorInitArgs, KogitoEditorEnvelopeContextType } from "
import { NewDmnEditorChannelApi } from "./NewDmnEditorChannelApi";
import { DmnEditorInterface } from "./DmnEditorFactory";

export class NewDmnEditorFactory implements EditorFactory<DmnEditorInterface, NewDmnEditorChannelApi> {
export class NewDmnEditorFactory implements EditorFactory<NewDmnEditorInterface, NewDmnEditorChannelApi> {
public createEditor(
envelopeContext: KogitoEditorEnvelopeContextType<NewDmnEditorChannelApi>,
initArgs: EditorInitArgs
): Promise<DmnEditorInterface> {
return Promise.resolve(new DmnEditorInterface(envelopeContext, initArgs));
): Promise<NewDmnEditorInterface> {
return Promise.resolve(new NewDmnEditorInterface(envelopeContext, initArgs));
}
}

export class NewDmnEditorInterface extends DmnEditorInterface {
public openBoxedExpressionEditor(nodeId: string): void {
this.self.openBoxedExpressionEditor(nodeId);
}
}
16 changes: 9 additions & 7 deletions packages/form-dmn/src/FormDmnOutputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,15 @@ export function FormDmnOutputs({ openExecutionTab, ...props }: FormDmnOutputsPro
<CardTitle>
<Flex justifyContent={{ default: "justifyContentSpaceBetween" }}>
<Title headingLevel={"h2"}>{dmnFormResult.decisionName}</Title>
<Button
variant={"plain"}
title={`Open ${dmnFormResult.decisionName} expression`}
icon={<ArrowUpIcon />}
data-navigate-to-expression-id={dmnFormResult.decisionId}
onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
/>
{props.openBoxedExpressionEditor !== undefined && (
<Button
variant={"plain"}
title={`Open ${dmnFormResult.decisionName} expression`}
icon={<ArrowUpIcon />}
data-navigate-to-expression-id={dmnFormResult.decisionId}
onClick={() => props.openBoxedExpressionEditor?.(dmnFormResult.decisionId)}
/>
)}
</Flex>
</CardTitle>
<CardBody isFilled={true}>{result(dmnFormResult.result)}</CardBody>
Expand Down
6 changes: 4 additions & 2 deletions packages/online-editor/src/dmnRunner/DmnRunnerDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Drawer
Expand All @@ -39,7 +41,7 @@ export function DmnRunnerDrawer(props: React.PropsWithChildren<{ editor: Embedde
}
panelContent={
<DmnRunnerErrorBoundary>
<DmnRunnerDrawerPanelContent editor={props.editor} />
<DmnRunnerDrawerPanelContent {...props} />
</DmnRunnerErrorBoundary>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false);
const [dmnRunnerStylesConfig, setDmnRunnerStylesConfig] = useState<DmnRunnerStylesConfig>({
Expand Down Expand Up @@ -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>;

newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
}}
openBoxedExpressionEditor={
!props.isLegacyDmnEditor
? (nodeId: string) => {
const newDmnEditorEnvelopeApi = props.editor?.getEnvelopeServer()
.envelopeApi as unknown as MessageBusClientApi<NewDmnEditorEnvelopeApi>;
newDmnEditorEnvelopeApi.notifications.dmnEditor_openBoxedExpressionEditor.send(nodeId);
}
: undefined
}
/>
</PageSection>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/online-editor/src/editor/EditorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Error details: ${err}`);
<EditorToolbar workspaceFile={file.workspaceFile} editor={editor} />
<Divider />
<PageSection hasOverflowScroll={true} padding={{ default: "noPadding" }} aria-label="Editor section">
<DmnRunnerDrawer editor={editor}>
<DmnRunnerDrawer editor={editor} isLegacyDmnEditor={settings.editors.useLegacyDmnEditor}>
<EditorPageDockDrawer>
{embeddedEditorFile && (
<EmbeddedEditor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import * as EditorEnvelope from "@kie-tools-core/editor/dist/envelope";
import { DmnEditorInterface } from "@kie-tools/dmn-editor-envelope/dist/DmnEditorFactory";
import { NewDmnEditorInterface } from "@kie-tools/dmn-editor-envelope/dist/NewDmnEditorFactory";
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.initCustom<DmnEditorInterface, NewDmnEditorEnvelopeApi, NewDmnEditorChannelApi>({
EditorEnvelope.initCustom<NewDmnEditorInterface, NewDmnEditorEnvelopeApi, NewDmnEditorChannelApi>({
container: document.getElementById("envelope-app")!,
bus: { postMessage: (message, targetOrigin, _) => window.parent.postMessage(message, targetOrigin!, _) },
apiImplFactory: {
Expand Down

0 comments on commit 3cba7d8

Please sign in to comment.