Skip to content
Snippets Groups Projects

Put common graph saving behaviour in a function to remove label filling

Merged Loic Huder requested to merge workflow-save into main
6 unresolved threads

Each time a graph must be saved as an Ewoks workflow, the same process must be done:

  • Curate node/link data to remove default values/unspecified values
  • Enrich the react-flow nodes/links with the curated data
  • Deal with special nodes: graph inputs/outputs (calcEwoksGraphProp), note nodes calcNoteNodes
  • Convert the enriched nodes/links in ewoks nodes/links

This process was inconsistently done depending on the saving method (download, saving to server through the dialog, saving to server without dialog).

In this MR, I introduce a method prepareEwoksGraph that takes care of all this process and is called whatever the saving method. This notably allows me to remove the fallback of label to id, putting the finishing touch to the test in !387 (merged).

Edited by Loic Huder

Merge request reports

Merge request pipeline #137057 passed

Merge request pipeline passed for d8607a63

Approved by

Merged by Loic HuderLoic Huder 1 year ago (Oct 3, 2023 12:58pm UTC)

Merge details

  • Changes merged into main with c33631c7.
  • Deleted the source branch.
  • Auto-merge enabled

Pipeline #137161 passed

Pipeline passed for c33631c7 on main

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
93 83 return;
94 84 }
95 85
96 // DOC: Remove empty lines if any in DataMapping, Conditions, DefaultValues
97 86 try {
98 const newNodesData = curateNodeData(getNodesData());
99 const newEdgesData = curateEdgeData(getEdgesData());
100 setNodesData(newNodesData);
101 setEdgesData(newEdgesData);
  • When saving to the server, the nodes/edges data were updated to the curated ones. I no longer do it since the curation is now encapsulated in prepareEwoksGraph.

    I think this is fine :shrug: ? But I can rework if needed.

  • Yes, as long as one-way data flow is happening as expected:

    save to server => invalidate cache => refetch => parse and store nodes/edges data
  • Please register or sign in to reply
  • 22 22 return <SubgraphStack />;
    23 23 }
    24 24
    25 return (
    26 <span data-cy={displayedWorkflowInfo.label}>
    27 {displayedWorkflowInfo.label || displayedWorkflowInfo.id}
    28 </span>
    29 );
    25 const { id, label = id } = displayedWorkflowInfo;
    26 return <span data-cy={label}>{label}</span>;
  • Loic Huder
  • 99 graph: displayedWorkflowInfo,
    100 nodes: getNodes().map((nod) => {
    101 return { ...nod, data: getNodesData().get(nod.id) as EwoksRFNodeData };
    102 }),
    103 links: getEdges().map((edge) => {
    104 return {
    105 ...edge,
    106 data: getEdgesData().get(edge.id) as EwoksRFLinkData,
    107 };
    108 }),
    109 };
    110 setSelection(newSelection);
    111 setTitle(newSelection === 'ewoks' ? 'Ewoks Graph' : 'RF Graph');
    112 setGraph(newSelection === 'ewoks' ? rfToEwoks(graphRf) : graphRf);
    113 setIsOpen(true);
    114 };
  • 49 49
    50 50 return {
    51 51 id: graph.graph.id,
    52 label: graph.graph.label || graph.graph.id,
  • 15 15 export const EMPTY_RF_GRAPH: GraphRF = {
    16 16 graph: {
    17 17 id: '',
    18 label: '',
  • 58 edgesWithoutData: Edge[],
    59 rawNodeData: Map<string, EwoksRFNodeData>,
    60 rawLinkData: Map<string, EwoksRFLinkData>
    61 ): GraphEwoks {
    62 const nodeData = curateNodeData(rawNodeData);
    63 const nodes = nodesWithoutData.map((node) => enrichWithData(node, nodeData));
    64
    65 const linkData = curateEdgeData(rawLinkData);
    66 const links = edgesWithoutData.map((edge) => enrichWithData(edge, linkData));
    67
    68 let graph = calcEwoksGraphProp({ graph: graphInfo, nodes, links });
    69 const noteNodes = calcNoteNodes(nodes);
    70 const uiprops =
    71 noteNodes.length > 0
    72 ? { ...graph.uiProps, notes: noteNodes }
    73 : graph.uiProps;
  • Loic Huder requested review from @bocciare

    requested review from @bocciare

  • Loic Huder marked this merge request as ready

    marked this merge request as ready

  • Nicely done again!

  • Axel Bocciarelli approved this merge request

    approved this merge request

  • Loic Huder added 8 commits

    added 8 commits

    Compare with previous version

  • Loic Huder enabled an automatic merge when the pipeline for d8607a63 succeeds

    enabled an automatic merge when the pipeline for d8607a63 succeeds

  • Loic Huder mentioned in commit c33631c7

    mentioned in commit c33631c7

  • merged

  • Please register or sign in to reply
    Loading