@@ -13,7 +13,7 @@ import {
13
13
networkModificationTreeNodesUpdated ,
14
14
removeNotificationByNode ,
15
15
networkModificationHandleSubtree ,
16
- setSelectionForCopy ,
16
+ setNodeSelectionForCopy ,
17
17
resetLogsFilter ,
18
18
} from '../redux/actions' ;
19
19
import { useDispatch , useSelector } from 'react-redux' ;
@@ -65,11 +65,11 @@ const usePreviousTreeDisplay = (display, width) => {
65
65
return ref . current ;
66
66
} ;
67
67
68
- const noSelectionForCopy = {
68
+ const noNodeSelectionForCopy = {
69
69
sourceStudyUuid : null ,
70
70
nodeId : null ,
71
71
copyType : null ,
72
- allChilddrenIds : null ,
72
+ allChildrenIds : null ,
73
73
} ;
74
74
75
75
const HTTP_MAX_NODE_BUILDS_EXCEEDED_MESSAGE = 'MAX_NODE_BUILDS_EXCEEDED' ;
@@ -82,10 +82,10 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
82
82
const isInitiatingCopyTab = useRef ( false ) ;
83
83
const [ nodesToRestore , setNodesToRestore ] = useState ( [ ] ) ;
84
84
85
- const dispatchSelectionForCopy = useCallback (
85
+ const dispatchNodeSelectionForCopy = useCallback (
86
86
( sourceStudyUuid , nodeId , copyType ) => {
87
87
dispatch (
88
- setSelectionForCopy ( {
88
+ setNodeSelectionForCopy ( {
89
89
sourceStudyUuid : sourceStudyUuid ,
90
90
nodeId : nodeId ,
91
91
copyType : copyType ,
@@ -101,13 +101,13 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
101
101
console . info ( 'message received from broadcast channel' ) ;
102
102
console . info ( event . data ) ;
103
103
isInitiatingCopyTab . current = false ;
104
- if ( JSON . stringify ( noSelectionForCopy ) === JSON . stringify ( event . data ) ) {
105
- dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
104
+ if ( JSON . stringify ( noNodeSelectionForCopy ) === JSON . stringify ( event . data ) ) {
105
+ dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
106
106
snackInfo ( {
107
107
messageId : 'CopiedNodeInvalidationMessage' ,
108
108
} ) ;
109
109
} else {
110
- dispatchSelectionForCopy ( event . data . sourceStudyUuid , event . data . nodeId , event . data . copyType ) ;
110
+ dispatchNodeSelectionForCopy ( event . data . sourceStudyUuid , event . data . nodeId , event . data . copyType ) ;
111
111
}
112
112
} ;
113
113
return broadcast ;
@@ -121,7 +121,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
121
121
//If the tab is closed we want to invalidate the copy on all tabs because we won't able to track the node modification
122
122
window . addEventListener ( 'beforeunload' , ( event ) => {
123
123
if ( true === isInitiatingCopyTab . current ) {
124
- broadcastChannel . postMessage ( noSelectionForCopy ) ;
124
+ broadcastChannel . postMessage ( noNodeSelectionForCopy ) ;
125
125
}
126
126
} ) ;
127
127
//broadcastChannel doesn't change
@@ -133,9 +133,9 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
133
133
const currentNodeRef = useRef ( ) ;
134
134
currentNodeRef . current = currentNode ;
135
135
136
- const selectionForCopy = useSelector ( ( state ) => state . selectionForCopy ) ;
137
- const selectionForCopyRef = useRef ( ) ;
138
- selectionForCopyRef . current = selectionForCopy ;
136
+ const selectionForCopy = useSelector ( ( state ) => state . nodeSelectionForCopy ) ;
137
+ const nodeSelectionForCopyRef = useRef ( ) ;
138
+ nodeSelectionForCopyRef . current = selectionForCopy ;
139
139
140
140
const isModificationsDrawerOpen = useSelector ( ( state ) => state . isModificationsDrawerOpen ) ;
141
141
const isEventScenarioDrawerOpen = useSelector ( ( state ) => state . isEventScenarioDrawerOpen ) ;
@@ -158,26 +158,26 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
158
158
159
159
const isSubtreeImpacted = useCallback (
160
160
( nodes ) =>
161
- ( selectionForCopyRef . current . copyType === CopyType . SUBTREE_COPY ||
162
- selectionForCopyRef . current . copyType === CopyType . SUBTREE_CUT ) &&
161
+ ( nodeSelectionForCopyRef . current . copyType === CopyType . SUBTREE_COPY ||
162
+ nodeSelectionForCopyRef . current . copyType === CopyType . SUBTREE_CUT ) &&
163
163
nodes . some (
164
164
( nodeId ) =>
165
- nodeId === selectionForCopyRef . current . nodeId ||
166
- selectionForCopyRef . current . allChildrenIds ?. includes ( nodeId )
165
+ nodeId === nodeSelectionForCopyRef . current . nodeId ||
166
+ nodeSelectionForCopyRef . current . allChildrenIds ?. includes ( nodeId )
167
167
) ,
168
168
169
169
[ ]
170
170
) ;
171
171
172
172
const resetNodeClipboard = useCallback ( ( ) => {
173
- dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
173
+ dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
174
174
snackInfo ( {
175
175
messageId : 'CopiedNodeInvalidationMessage' ,
176
176
} ) ;
177
177
178
178
//only the tab that initiated the copy should update through the websocket, all the other tabs will get the info through broadcast
179
179
if ( true === isInitiatingCopyTab . current ) {
180
- broadcastChannel . postMessage ( noSelectionForCopy ) ;
180
+ broadcastChannel . postMessage ( noNodeSelectionForCopy ) ;
181
181
182
182
//we need to reset isInitiatingCopyTab here otherwise it won't in the current tab thus next unrelated pasting actions will reset other tabs clipboard
183
183
isInitiatingCopyTab . current = false ;
@@ -238,7 +238,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
238
238
} else if ( studyUpdatedForce . eventData . headers [ 'updateType' ] === UpdateType . NODE_DELETED ) {
239
239
if (
240
240
studyUpdatedForce . eventData . headers [ 'nodes' ] . some (
241
- ( nodeId ) => nodeId === selectionForCopyRef . current . nodeId
241
+ ( nodeId ) => nodeId === nodeSelectionForCopyRef . current . nodeId
242
242
) ||
243
243
isSubtreeImpacted ( studyUpdatedForce . eventData . headers [ 'nodes' ] )
244
244
) {
@@ -257,7 +257,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
257
257
}
258
258
if (
259
259
studyUpdatedForce . eventData . headers [ 'nodes' ] . some (
260
- ( nodeId ) => nodeId === selectionForCopyRef . current . nodeId
260
+ ( nodeId ) => nodeId === nodeSelectionForCopyRef . current . nodeId
261
261
) ||
262
262
isSubtreeImpacted ( studyUpdatedForce . eventData . headers [ 'nodes' ] )
263
263
) {
@@ -277,7 +277,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
277
277
//creating, updating or deleting modifications must invalidate the node clipboard
278
278
} else if ( UPDATE_TYPE . includes ( studyUpdatedForce . eventData . headers [ 'updateType' ] ) ) {
279
279
if (
280
- studyUpdatedForce . eventData . headers [ 'parentNode' ] === selectionForCopyRef . current . nodeId ||
280
+ studyUpdatedForce . eventData . headers [ 'parentNode' ] === nodeSelectionForCopyRef . current . nodeId ||
281
281
isSubtreeImpacted ( [ studyUpdatedForce . eventData . headers [ 'parentNode' ] ] )
282
282
) {
283
283
resetNodeClipboard ( ) ;
@@ -324,7 +324,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
324
324
const handleCopyNode = ( nodeId ) => {
325
325
console . info ( 'node with id ' + nodeId + ' from study ' + studyUuid + ' selected for copy' ) ;
326
326
isInitiatingCopyTab . current = true ;
327
- dispatchSelectionForCopy ( studyUuid , nodeId , CopyType . NODE_COPY ) ;
327
+ dispatchNodeSelectionForCopy ( studyUuid , nodeId , CopyType . NODE_COPY ) ;
328
328
broadcastChannel . postMessage ( {
329
329
sourceStudyUuid : studyUuid ,
330
330
nodeId : nodeId ,
@@ -334,14 +334,14 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
334
334
335
335
const handleCutNode = ( nodeId ) => {
336
336
nodeId
337
- ? dispatchSelectionForCopy ( studyUuid , nodeId , CopyType . NODE_CUT )
338
- : dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
337
+ ? dispatchNodeSelectionForCopy ( studyUuid , nodeId , CopyType . NODE_CUT )
338
+ : dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
339
339
} ;
340
340
341
341
const handlePasteNode = useCallback (
342
342
( referenceNodeId , insertMode ) => {
343
- if ( CopyType . NODE_CUT === selectionForCopyRef . current . copyType ) {
344
- cutTreeNode ( studyUuid , selectionForCopyRef . current . nodeId , referenceNodeId , insertMode ) . catch (
343
+ if ( CopyType . NODE_CUT === nodeSelectionForCopyRef . current . copyType ) {
344
+ cutTreeNode ( studyUuid , nodeSelectionForCopyRef . current . nodeId , referenceNodeId , insertMode ) . catch (
345
345
( error ) => {
346
346
snackError ( {
347
347
messageTxt : error . message ,
@@ -350,12 +350,12 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
350
350
}
351
351
) ;
352
352
//Do not wait for the response, after the first CUT / PASTE operation, we can't paste anymore
353
- dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
354
- } else if ( CopyType . NODE_COPY === selectionForCopyRef . current . copyType ) {
353
+ dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
354
+ } else if ( CopyType . NODE_COPY === nodeSelectionForCopyRef . current . copyType ) {
355
355
copyTreeNode (
356
- selectionForCopyRef . current . sourceStudyUuid ,
356
+ nodeSelectionForCopyRef . current . sourceStudyUuid ,
357
357
studyUuid ,
358
- selectionForCopyRef . current . nodeId ,
358
+ nodeSelectionForCopyRef . current . nodeId ,
359
359
referenceNodeId ,
360
360
insertMode
361
361
) . catch ( ( error ) => {
@@ -466,7 +466,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
466
466
const handleCopySubtree = ( nodeId ) => {
467
467
console . info ( 'node with id ' + nodeId + ' from study ' + studyUuid + ' selected for copy' ) ;
468
468
isInitiatingCopyTab . current = true ;
469
- dispatchSelectionForCopy ( studyUuid , nodeId , CopyType . SUBTREE_COPY ) ;
469
+ dispatchNodeSelectionForCopy ( studyUuid , nodeId , CopyType . SUBTREE_COPY ) ;
470
470
broadcastChannel . postMessage ( {
471
471
sourceStudyUuid : studyUuid ,
472
472
nodeId : nodeId ,
@@ -476,26 +476,26 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
476
476
477
477
const handleCutSubtree = ( nodeId ) => {
478
478
nodeId
479
- ? dispatchSelectionForCopy ( studyUuid , nodeId , CopyType . SUBTREE_CUT )
480
- : dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
479
+ ? dispatchNodeSelectionForCopy ( studyUuid , nodeId , CopyType . SUBTREE_CUT )
480
+ : dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
481
481
} ;
482
482
483
483
const handlePasteSubtree = useCallback (
484
484
( referenceNodeId ) => {
485
- if ( CopyType . SUBTREE_CUT === selectionForCopyRef . current . copyType ) {
486
- cutSubtree ( studyUuid , selectionForCopyRef . current . nodeId , referenceNodeId ) . catch ( ( error ) => {
485
+ if ( CopyType . SUBTREE_CUT === nodeSelectionForCopyRef . current . copyType ) {
486
+ cutSubtree ( studyUuid , nodeSelectionForCopyRef . current . nodeId , referenceNodeId ) . catch ( ( error ) => {
487
487
snackError ( {
488
488
messageTxt : error . message ,
489
489
headerId : 'NodeCreateError' ,
490
490
} ) ;
491
491
} ) ;
492
492
//Do not wait for the response, after the first CUT / PASTE operation, we can't paste anymore
493
- dispatch ( setSelectionForCopy ( noSelectionForCopy ) ) ;
494
- } else if ( CopyType . SUBTREE_COPY === selectionForCopyRef . current . copyType ) {
493
+ dispatch ( setNodeSelectionForCopy ( noNodeSelectionForCopy ) ) ;
494
+ } else if ( CopyType . SUBTREE_COPY === nodeSelectionForCopyRef . current . copyType ) {
495
495
copySubtree (
496
- selectionForCopyRef . current . sourceStudyUuid ,
496
+ nodeSelectionForCopyRef . current . sourceStudyUuid ,
497
497
studyUuid ,
498
- selectionForCopyRef . current . nodeId ,
498
+ nodeSelectionForCopyRef . current . nodeId ,
499
499
referenceNodeId
500
500
) . catch ( ( error ) => {
501
501
snackError ( {
@@ -537,7 +537,7 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay })
537
537
handleNodeRemoval = { handleRemoveNode }
538
538
handleExportCaseOnNode = { handleExportCaseOnNode }
539
539
handleClose = { closeCreateNodeMenu }
540
- selectionForCopy = { selectionForCopyRef . current }
540
+ nodeSelectionForCopy = { nodeSelectionForCopyRef . current }
541
541
handleCopyNode = { handleCopyNode }
542
542
handleCutNode = { handleCutNode }
543
543
handlePasteNode = { handlePasteNode }
0 commit comments