Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#1773: DMN Editor: Render badges with evaluation status on Decision nodes #2868

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/dmn-editor/src/DmnEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,39 @@
}
/* (end) nodes */

/* (begin) decision node evaluation status */
.kie-dmn-editor--decision-node--evaluation-status-failure::before {
content: " \2716";
font-size: 0.8em;
text-align: left;
color: white;
background-color: rgb(134, 106, 212);
position: absolute;
top: 0px;
left: 0px;
height: 40px;
width: 40px;
clip-path: polygon(0% 100%, 100% 0%, 0% 0%);
padding-left: 0.2em;
}

.kie-dmn-editor--decision-node--evaluation-status-success::before {
content: " \2714";
font-size: 0.8em;
text-align: left;
color: white;
background-color: rgb(134, 106, 212);
position: absolute;
top: 0px;
left: 0px;
height: 40px;
width: 40px;
clip-path: polygon(0% 100%, 100% 0%, 0% 0%);
padding-left: 0.2em;
}

/* (end) decision node evaluation status */

/* (begin) decisionService and group nodes */
/* DECISION SERVICES AND GROUPS HAVE A SPECIFIC SELECTION MECHANISM TO ALLOW EDITING EDGES INSIDE THEM */
.kie-dmn-editor--node-decisionService-visibleRect {
Expand Down
4 changes: 4 additions & 0 deletions packages/dmn-editor/src/DmnEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export type DmnEditorProps = {
* Notifies the caller when the DMN Editor performs a new edit after the debounce time.
*/
onModelDebounceStateChanged?: (changed: boolean) => void;
/**
* Its a map telling if given key (decisionId) was evaluated with value ("success" or "failure")
*/
evaluationStatus?: Map<string, "success" | "failure">;
};

export const DmnEditorInternal = ({
Expand Down
4 changes: 4 additions & 0 deletions packages/dmn-editor/src/DmnEditorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type DmnEditorContextProviderProps = Pick<
| "model"
| "onRequestToJumpToPath"
| "onRequestToResolvePath"
| "evaluationStatus"
>;

export type DmnModelBeforeEditing = DmnLatestModel;
Expand All @@ -41,6 +42,7 @@ export type DmnEditorContextType = Pick<
| "issueTrackerHref"
| "onRequestToJumpToPath"
| "onRequestToResolvePath"
| "evaluationStatus"
> & {
dmnModelBeforeEditingRef: React.MutableRefObject<DmnModelBeforeEditing>;
dmnEditorRootElementRef: React.RefObject<HTMLDivElement>;
Expand All @@ -65,13 +67,15 @@ export function DmnEditorContextProvider(props: React.PropsWithChildren<DmnEdito
issueTrackerHref: props.issueTrackerHref,
onRequestToJumpToPath: props.onRequestToJumpToPath,
onRequestToResolvePath: props.onRequestToResolvePath,
evaluationStatus: props.evaluationStatus,
}),
[
props.externalContextDescription,
props.externalContextName,
props.issueTrackerHref,
props.onRequestToJumpToPath,
props.onRequestToResolvePath,
props.evaluationStatus,
]
);
return <DmnEditorContext.Provider value={value}>{props.children}</DmnEditorContext.Provider>;
Expand Down
10 changes: 9 additions & 1 deletion packages/dmn-editor/src/diagram/nodes/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { propsHaveSameValuesDeep } from "../memoization/memoization";
import { useExternalModels } from "../../includedModels/DmnEditorDependenciesContext";
import { NODE_LAYERS } from "../../store/computed/computeDiagramData";
import { useSettings } from "../../settings/DmnEditorSettingsContext";
import { useDmnEditor } from "../../DmnEditorContext";

export type ElementFilter<E extends { __$$element: string }, Filter extends string> = E extends any
? E["__$$element"] extends Filter
Expand Down Expand Up @@ -402,6 +403,13 @@ export const DecisionNode = React.memo(
);
});

const isEvaluationHighlightsEnabled = useDmnEditorStore((s) => s.diagram.overlays.enableEvaluationHighlights);
const { evaluationStatus } = useDmnEditor();
const evaluationStatusClassName =
isEvaluationHighlightsEnabled && evaluationStatus!.has(decision["@_id"])
? `kie-dmn-editor--decision-node--evaluation-status-${evaluationStatus!.get(decision["@_id"])}`
: "";

return (
<>
<svg className={`kie-dmn-editor--node-shape ${className}`}>
Expand All @@ -421,7 +429,7 @@ export const DecisionNode = React.memo(

<div
ref={ref}
className={`kie-dmn-editor--node kie-dmn-editor--decision-node ${className}`}
className={`kie-dmn-editor--node kie-dmn-editor--decision-node ${className} ${evaluationStatusClassName}`}
tabIndex={-1}
onDoubleClick={triggerEditing}
onKeyDown={triggerEditingIfEnter}
Expand Down
1 change: 1 addition & 0 deletions packages/dmn-editor/stories/dmnEditorStoriesWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function DmnEditorWrapper(props?: Partial<StorybookDmnEditorProps>) {
issueTrackerHref={props?.issueTrackerHref ?? args.issueTrackerHref}
onRequestToJumpToPath={props?.onRequestToJumpToPath ?? args.onRequestToJumpToPath}
onModelDebounceStateChanged={onModelDebounceStateChanged}
evaluationStatus={props?.evaluationStatus || args.evaluationStatus}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
/\*

- 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.
\*/
{/* 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 EmptyWithAvailableExternalModelsStories from "./EmptyWithAvailableExternalModels.stories";
import { Meta } from "@storybook/blocks";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{/* 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 EvaluationStatus from "./EvaluationStatus.stories";
import { Meta } from "@storybook/blocks";

<Meta title="MDX/Misc/EvaluationStatus" of={EvaluationStatus} />

## Evaluation Status Demo

Please use `Enable evaluation highlights` toggle to activate and deactivate the evaluation highlight feature. In this story you can see the evaluation status directly on the Decision node shape.
Loading
Loading