hise-flow-graphs 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hise-flow-graphs",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "This package manages ReactFlow graphs for HISE.",
5
5
  "main": "dist/main.js",
6
6
  "repository": "git@github.com:aifimmunology/hise-flow-graphs.git",
@@ -7,7 +7,7 @@ export const Description = (props: {
7
7
  }) => {
8
8
  const nodeDescription = getNodeDescription(props.label, props.description);
9
9
 
10
- if (!Object.keys(props.description).length || !nodeDescription) return null;
10
+ if (!nodeDescription || !Object.keys(props.description).length) return null;
11
11
 
12
12
  return (
13
13
  <div className="node-description text-center text-break">
@@ -55,7 +55,7 @@ const getNodes = (
55
55
  id: vertex,
56
56
  position,
57
57
  type: label !== 'FileLayer' ? type : 'fileLayerNode',
58
- data: data[vertex],
58
+ data: data[vertex] || {},
59
59
  style: getNodeStyle(type, label, assetReview),
60
60
  });
61
61
  });
@@ -181,13 +181,21 @@ export const getStyle = (type: string) => {
181
181
  return style;
182
182
  };
183
183
 
184
- export const getSchemes = (vertex: string, labels: Certificate['serviceLabels'], schemes: Certificate['schemes']) => {
184
+ export const getSchemes = (
185
+ label: string,
186
+ vertex: string,
187
+ labels: Certificate['serviceLabels'],
188
+ schemes: Certificate['schemes'],
189
+ ) => {
185
190
  const nodeSchemes: { [key: string]: object } = {};
186
191
 
192
+ if (!['Sample', 'Subject'].includes(label)) return nodeSchemes;
187
193
  if (!labels || !schemes) return nodeSchemes;
188
194
 
189
195
  const schemeLabels = labels[vertex];
190
196
 
197
+ if (!schemeLabels) return nodeSchemes;
198
+
191
199
  Object.entries(schemeLabels).forEach(([key, val]: any) => {
192
200
  if (key === 'Survey Data Scheme Key') {
193
201
  nodeSchemes.surveyData = schemes[val];
@@ -205,7 +213,15 @@ export const getSchemes = (vertex: string, labels: Certificate['serviceLabels'],
205
213
  return nodeSchemes;
206
214
  };
207
215
 
216
+ // export const getNodeData = (certificate, vertex) => {
217
+ // const data = {
218
+
219
+ // }
220
+ // };
221
+
208
222
  export const getNodeLabel = (type: string, desc: any) => {
223
+ if (!desc) return type;
224
+
209
225
  switch (type) {
210
226
  case 'FileSet':
211
227
  return (
@@ -254,6 +270,8 @@ export const getNodeLabel = (type: string, desc: any) => {
254
270
  };
255
271
 
256
272
  export const getNodeDescription = (type: string, desc: any) => {
273
+ if (!desc) return null;
274
+
257
275
  switch (type) {
258
276
  case 'Cohort':
259
277
  case 'FileSet':
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useMemo } from 'react';
2
2
  import dagre from 'dagre';
3
3
  import * as R from 'ramda';
4
4
  import ReactFlow, {
@@ -24,19 +24,6 @@ import 'react-toastify/dist/ReactToastify.css';
24
24
  import 'reactflow/dist/style.css';
25
25
  import './style.css';
26
26
 
27
- const nodeTypes = {
28
- readNode: ReadNode,
29
- fileLayerNode: FileLayerNode,
30
- fileNode: ReadNode,
31
- pipelineNode: ReadNode,
32
- IDENode: ReadNode,
33
- editNode: EditNode,
34
- reviewNode: ReviewNode,
35
- workspaceFileNode: WorkspaceFileNode,
36
- workspacePipelineNode: WorkspacePipelineNode,
37
- workspaceIDENode: WorkspaceIDENode,
38
- };
39
-
40
27
  const dagreGraph = new dagre.graphlib.Graph();
41
28
  dagreGraph.setDefaultEdgeLabel(() => ({}));
42
29
 
@@ -60,6 +47,19 @@ const Graph = ({ type, certificate, replica, graph, children }: {
60
47
  setNodeLayers,
61
48
  } = useGraph();
62
49
 
50
+ const nodeTypes = useMemo(() => ({
51
+ readNode: ReadNode,
52
+ fileLayerNode: FileLayerNode,
53
+ fileNode: ReadNode,
54
+ pipelineNode: ReadNode,
55
+ IDENode: ReadNode,
56
+ editNode: EditNode,
57
+ reviewNode: ReviewNode,
58
+ workspaceFileNode: WorkspaceFileNode,
59
+ workspacePipelineNode: WorkspacePipelineNode,
60
+ workspaceIDENode: WorkspaceIDENode,
61
+ }), []);
62
+
63
63
  const [nodes, setNodes, onNodesChange] = nodesState;
64
64
  const [edges, setEdges, onEdgesChange] = edgesState;
65
65
 
@@ -95,7 +95,9 @@ const Graph = ({ type, certificate, replica, graph, children }: {
95
95
  onEdgesChange={onEdgesChange}
96
96
  connectionLineType={ConnectionLineType.SmoothStep}
97
97
  nodeTypes={nodeTypes}
98
- fitView
98
+ onlyRenderVisibleElements
99
+ edgesUpdatable={false}
100
+ defaultViewport={{ x: 0, y: 0, zoom: 0.6 }}
99
101
  >
100
102
  <Controls />
101
103
  <Background />
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import { Handle, Position, NodeProps } from 'reactflow';
3
+ import { useGraph } from '../../../state/GraphContext';
3
4
  import { MaskMetadataButton } from './MaskMetadataModal';
4
5
  import { Description, Label } from '../CertificateGraph/NodeAttributes';
5
6
  import { EditNodeModalBtn } from './EditNodeModal';
6
7
  import { getLabelLink } from '../CertificateGraph/helpers';
7
8
 
8
9
  const EditNode = ({ data }: NodeProps) => {
9
- const { vertex, description, metadata, isExecutable } = data;
10
+ const { certificate } = useGraph();
11
+ const { vertex, description, metadata } = data;
10
12
 
11
13
  const [label, guid] = vertex.split('/');
12
- const link = getLabelLink(label, guid, isExecutable);
14
+ const link = getLabelLink(label, guid, certificate.isExecutable);
13
15
 
14
16
  return (
15
17
  <>
@@ -12,7 +12,6 @@ export const getEditNodeData = (
12
12
  const data: { [key: string]: Node['data'] } = {};
13
13
 
14
14
  const {
15
- isExecutable,
16
15
  generatedLabels,
17
16
  customLabels,
18
17
  serviceLabels,
@@ -32,8 +31,7 @@ export const getEditNodeData = (
32
31
  description,
33
32
  customLabels,
34
33
  metadata,
35
- schemes: getSchemes(vertex, serviceLabels, schemes),
36
- isExecutable,
34
+ schemes: getSchemes(label, vertex, serviceLabels, schemes),
37
35
  toggleEditModal,
38
36
  toggleMaskModal,
39
37
  };
@@ -43,6 +41,8 @@ export const getEditNodeData = (
43
41
  };
44
42
 
45
43
  export const getFormControls = (label: string, description: object) => {
44
+ if (!description) return null;
45
+
46
46
  switch (label) {
47
47
  case 'Cohort':
48
48
  case 'IDE':
@@ -29,7 +29,7 @@ export const getReadNodeData = (
29
29
  description,
30
30
  customLabels,
31
31
  metadata: metadata ? metadata[vertex] : null,
32
- schemes: getSchemes(vertex, serviceLabels, schemes),
32
+ schemes: getSchemes(label, vertex, serviceLabels, schemes),
33
33
  toggleMetadataModal,
34
34
  };
35
35
  });
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import { Handle, Position, NodeProps } from 'reactflow';
3
+ import { useGraph } from '../../../state/GraphContext';
3
4
  import { ReviewBtn } from './ReviewNodes';
4
5
  import { Description, Label } from '../CertificateGraph/NodeAttributes';
5
6
  import { MetadataButton } from '../ReadCertificate/MetadataModal';
6
7
  import { getLabelLink } from '../CertificateGraph/helpers';
7
8
 
8
9
  const ReviewNode = (props: NodeProps) => {
9
- const { vertex, description, isExecutable } = props.data;
10
+ const { certificate } = useGraph();
11
+ const { vertex, description } = props.data;
10
12
 
11
13
  const [label, guid] = vertex.split('/');
12
- const link = getLabelLink(label, guid, isExecutable);
14
+ const link = getLabelLink(label, guid, certificate.isExecutable);
13
15
 
14
16
  return (
15
17
  <>
@@ -13,8 +13,6 @@ export const getReviewNodeData = (
13
13
  const data: { [key: string]: Node['data'] } = {};
14
14
 
15
15
  const {
16
- id,
17
- isExecutable,
18
16
  generatedLabels,
19
17
  customLabels,
20
18
  serviceLabels,
@@ -40,12 +38,10 @@ export const getReviewNodeData = (
40
38
  assetReview,
41
39
  otherReviews,
42
40
  certificate,
43
- schemes: getSchemes(vertex, serviceLabels, schemes),
41
+ schemes: getSchemes(label, vertex, serviceLabels, schemes),
44
42
  metadata: metadata ? metadata[vertex] : null,
45
- certId: id,
46
43
  toggleReviewModal,
47
44
  toggleMetadataModal,
48
- isExecutable,
49
45
  };
50
46
  });
51
47
 
@@ -66,7 +66,7 @@ export const getWorkspaceData = (
66
66
  description,
67
67
  customLabels,
68
68
  metadata: metadata ? metadata[vertex] : null,
69
- schemes: getSchemes(vertex, serviceLabels, schemes),
69
+ schemes: getSchemes(label, vertex, serviceLabels, schemes),
70
70
  isReplicated,
71
71
  refresh,
72
72
  };
@@ -2,6 +2,7 @@ import React, {
2
2
  useState,
3
3
  useContext,
4
4
  createContext,
5
+ useMemo,
5
6
  } from 'react';
6
7
  import { useNodesState, useEdgesState, Node } from 'reactflow';
7
8
  import { Certificate, Replica, NodeLayers } from '../@types/CertificateTypes';
@@ -67,7 +68,7 @@ const GraphProvider = ({ children }: any) => {
67
68
  const nodesState = useNodesState([]); // [nodes, setNodes, onNodesChange]
68
69
  const edgesState = useEdgesState([]); // [edges, setEdges, onEdgesChange]
69
70
 
70
- const contextValue = {
71
+ const contextValue = useMemo(() => ({
71
72
  node,
72
73
  setNode,
73
74
  type,
@@ -80,7 +81,20 @@ const GraphProvider = ({ children }: any) => {
80
81
  setNodeLayers,
81
82
  nodesState,
82
83
  edgesState,
83
- };
84
+ }), [
85
+ node,
86
+ setNode,
87
+ type,
88
+ setType,
89
+ certificate,
90
+ setCertificate,
91
+ replica,
92
+ setReplica,
93
+ nodeLayers,
94
+ setNodeLayers,
95
+ nodesState,
96
+ edgesState,
97
+ ]);
84
98
 
85
99
  return (
86
100
  <GraphContext.Provider value={contextValue}>