aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-12 22:26:47 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-12 22:29:46 +0200
commit238c7729eea598879e26ab77a75b12e9d2dae621 (patch)
treee4bec9859ed7c6d6af2782ab7c79c062f70ced94
parentfix: SVG clipping path in Firefox (diff)
downloadrefinery-238c7729eea598879e26ab77a75b12e9d2dae621.tar.gz
refinery-238c7729eea598879e26ab77a75b12e9d2dae621.tar.zst
refinery-238c7729eea598879e26ab77a75b12e9d2dae621.zip
refactor(frontend): hide non-existent nodes
-rw-r--r--subprojects/frontend/src/graph/GraphTheme.tsx9
-rw-r--r--subprojects/frontend/src/graph/dotSource.ts40
2 files changed, 33 insertions, 16 deletions
diff --git a/subprojects/frontend/src/graph/GraphTheme.tsx b/subprojects/frontend/src/graph/GraphTheme.tsx
index 989bd0c2..14d58b96 100644
--- a/subprojects/frontend/src/graph/GraphTheme.tsx
+++ b/subprojects/frontend/src/graph/GraphTheme.tsx
@@ -68,15 +68,6 @@ export default styled('div', {
68 '.node-exists-UNKNOWN [stroke="black"]': { 68 '.node-exists-UNKNOWN [stroke="black"]': {
69 strokeDasharray: '5 2', 69 strokeDasharray: '5 2',
70 }, 70 },
71 '.node-exists-FALSE': {
72 '& [fill="green"]': {
73 fill: theme.palette.background.default,
74 },
75 '& [stroke="black"]': {
76 strokeDasharray: '1 3',
77 stroke: theme.palette.text.secondary,
78 },
79 },
80 '.edge': { 71 '.edge': {
81 '& text': { 72 '& text': {
82 fontFamily: theme.typography.fontFamily, 73 fontFamily: theme.typography.fontFamily,
diff --git a/subprojects/frontend/src/graph/dotSource.ts b/subprojects/frontend/src/graph/dotSource.ts
index 5e0b44c8..bd358dfa 100644
--- a/subprojects/frontend/src/graph/dotSource.ts
+++ b/subprojects/frontend/src/graph/dotSource.ts
@@ -119,8 +119,11 @@ function computeNodeData(graph: GraphStore): NodeData[] {
119 return nodeData; 119 return nodeData;
120} 120}
121 121
122function createNodes(graph: GraphStore, lines: string[]): void { 122function createNodes(
123 const nodeData = computeNodeData(graph); 123 graph: GraphStore,
124 nodeData: NodeData[],
125 lines: string[],
126): void {
124 const { 127 const {
125 semantics: { nodes }, 128 semantics: { nodes },
126 scopes, 129 scopes,
@@ -128,7 +131,7 @@ function createNodes(graph: GraphStore, lines: string[]): void {
128 131
129 nodes.forEach((node, i) => { 132 nodes.forEach((node, i) => {
130 const data = nodeData[i]; 133 const data = nodeData[i];
131 if (data === undefined || data.isolated) { 134 if (data === undefined || data.isolated || data.exists === 'FALSE') {
132 return; 135 return;
133 } 136 }
134 const classList = [ 137 const classList = [
@@ -222,6 +225,7 @@ function binarySerach(
222 225
223function createRelationEdges( 226function createRelationEdges(
224 graph: GraphStore, 227 graph: GraphStore,
228 nodeData: NodeData[],
225 relation: RelationMetadata, 229 relation: RelationMetadata,
226 showUnknown: boolean, 230 showUnknown: boolean,
227 lines: string[], 231 lines: string[],
@@ -266,6 +270,17 @@ function createRelationEdges(
266 return; 270 return;
267 } 271 }
268 272
273 const fromData = nodeData[from];
274 const toData = nodeData[to];
275 if (
276 fromData === undefined ||
277 fromData.exists === 'FALSE' ||
278 toData === undefined ||
279 toData.exists === 'FALSE'
280 ) {
281 return;
282 }
283
269 let dir = 'forward'; 284 let dir = 'forward';
270 let edgeConstraint = constraint; 285 let edgeConstraint = constraint;
271 let edgeWeight = weight; 286 let edgeWeight = weight;
@@ -306,7 +321,11 @@ function createRelationEdges(
306 }); 321 });
307} 322}
308 323
309function createEdges(graph: GraphStore, lines: string[]): void { 324function createEdges(
325 graph: GraphStore,
326 nodeData: NodeData[],
327 lines: string[],
328): void {
310 const { 329 const {
311 semantics: { relations }, 330 semantics: { relations },
312 } = graph; 331 } = graph;
@@ -316,7 +335,13 @@ function createEdges(graph: GraphStore, lines: string[]): void {
316 } 335 }
317 const visibility = graph.getVisibility(relation.name); 336 const visibility = graph.getVisibility(relation.name);
318 if (visibility !== 'none') { 337 if (visibility !== 'none') {
319 createRelationEdges(graph, relation, visibility === 'all', lines); 338 createRelationEdges(
339 graph,
340 nodeData,
341 relation,
342 visibility === 'all',
343 lines,
344 );
320 } 345 }
321 }); 346 });
322} 347}
@@ -333,8 +358,9 @@ export default function dotSource(
333 `node [fontsize=12, shape=plain, fontname="OpenSans"];`, 358 `node [fontsize=12, shape=plain, fontname="OpenSans"];`,
334 'edge [fontsize=10.5, color=black, fontname="OpenSans"];', 359 'edge [fontsize=10.5, color=black, fontname="OpenSans"];',
335 ]; 360 ];
336 createNodes(graph, lines); 361 const nodeData = computeNodeData(graph);
337 createEdges(graph, lines); 362 createNodes(graph, nodeData, lines);
363 createEdges(graph, nodeData, lines);
338 lines.push('}'); 364 lines.push('}');
339 return [lines.join('\n'), lines.length]; 365 return [lines.join('\n'), lines.length];
340} 366}