Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Click on workflow node navigates to the node definition #3062

Merged
merged 4 commits into from
Aug 23, 2022
Merged
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
24 changes: 23 additions & 1 deletion ui/src/pages/definition/WorkflowDefinition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const useStyles = makeStyles({
justifyContent: "flex-end",
gap: 8,
},
editorLineDecorator: {
backgroundColor: "rgb(45, 45, 45, 0.1)"
}
});

const actions = {
Expand Down Expand Up @@ -108,6 +111,7 @@ export default function Workflow() {
const [isModified, setIsModified] = useState(false);
const [dag, setDag] = useState(null);
const [jsonErrors, setJsonErrors] = useState([]);
const [decorations, setDecorations] = useState([]);

const workflowName = _.get(match, "params.name");
const workflowVersion = _.get(match, "params.version"); // undefined for latest
Expand Down Expand Up @@ -235,6 +239,23 @@ export default function Workflow() {
setIsModified(v !== workflowJson);
};

const handleWorkflowNodeClick = (node) => {
let editor = editorRef.current.getModel()
let searchResult = editor.findMatches(`"taskReferenceName": "${node.ref}"`)
if (searchResult.length){
editorRef.current.revealLineInCenter(searchResult[0]?.range?.startLineNumber, 0);
setDecorations(editorRef.current.deltaDecorations(decorations, [
{
range: searchResult[0]?.range,
options: {
isWholeLine: true,
inlineClassName: classes.editorLineDecorator
}
}
]))
}
}

return (
<>
<Helmet>
Expand Down Expand Up @@ -335,6 +356,7 @@ export default function Workflow() {
onValidate={handleValidate}
onChange={handleChange}
options={{
smoothScrolling: true,
selectOnLineNumbers: true,
minimap: {
enabled: false,
Expand All @@ -348,7 +370,7 @@ export default function Workflow() {
onMouseDown={(e) => handleMouseDown(e)}
/>
<div className={classes.workflowGraph}>
{dag && <WorkflowGraph dag={dag} />}
{dag && <WorkflowGraph dag={dag} onClick={handleWorkflowNodeClick} />}
</div>
</div>
</>
Expand Down