@@ -6,6 +6,9 @@ import { getAllFlowTests } from 'stores/utils';
66import useCollectionStore from 'stores/CollectionStore' ;
77import Tippy from '@tippyjs/react' ;
88import 'tippy.js/dist/tippy.css' ;
9+ import { useKeyPress } from 'reactflow' ;
10+ import { readFlowTest } from 'service/collection' ;
11+ import { toast } from 'react-toastify' ;
912
1013// ToDo: Change standard select element(s) with headless list element
1114const ComplexNode = ( { id, data } ) => {
@@ -24,45 +27,64 @@ const ComplexNode = ({ id, data }) => {
2427 }
2528 }
2629
30+ const cmdPressed = useKeyPress ( 'Meta' ) ; // 'Meta' key for Cmd on Mac
31+
32+ const handleMouseClick = ( event , relativePath ) => {
33+ if ( cmdPressed && event . type === 'click' ) {
34+ if ( relativePath && relativePath . trim ( ) != '' ) {
35+ readFlowTest ( ipcRenderer . join ( collection . pathname , relativePath ) , collectionId )
36+ . then ( ( result ) => {
37+ console . log ( `Read flowtest: path = ${ relativePath } , collectionId = ${ collectionId } ` ) ;
38+ } )
39+ . catch ( ( error ) => {
40+ console . log ( `Error reading flowtest: ${ error } ` ) ;
41+ toast . error ( `Error reading flowtest` ) ;
42+ } ) ;
43+ }
44+ }
45+ } ;
46+
2747 return (
28- < FlowNode
29- title = 'Flow Node'
30- handleLeft = { true }
31- handleLeftData = { { type : 'target' } }
32- handleRight = { true }
33- handleRightData = { { type : 'source' } }
34- >
35- < div >
36- < Tippy
37- content = { data . relativePath && data . relativePath !== '' ? data . relativePath : 'Select a flow' }
38- placement = 'top'
39- maxWidth = 'none'
40- >
41- < select
42- onChange = { ( event ) => {
43- const value = event . target ?. value ;
44- setFlowForComplexNode ( id , value ) ;
45- } }
46- name = 'flow'
47- value = { data . relativePath ? data . relativePath : '' }
48- className = 'h-12 p-2 border rounded outline-none cursor-default bg-background-light max-w-48 border-cyan-950'
48+ < div onClick = { ( e ) => handleMouseClick ( e , data . relativePath ) } >
49+ < FlowNode
50+ title = 'Flow Node'
51+ handleLeft = { true }
52+ handleLeftData = { { type : 'target' } }
53+ handleRight = { true }
54+ handleRightData = { { type : 'source' } }
55+ >
56+ < div >
57+ < Tippy
58+ content = { data . relativePath && data . relativePath !== '' ? data . relativePath : 'Select a flow' }
59+ placement = 'top'
60+ maxWidth = 'none'
4961 >
50- < option key = 'None' value = '' >
51- Select a flow
52- </ option >
53- { flowTests . map ( ( flowTestPath ) => {
54- return (
55- < option key = { flowTestPath } value = { flowTestPath } className = 'overflow-scroll' >
56- { flowTestPath }
57- </ option >
58- ) ;
59- } ) }
60- </ select >
61- </ Tippy >
62+ < select
63+ onChange = { ( event ) => {
64+ const value = event . target ?. value ;
65+ setFlowForComplexNode ( id , value ) ;
66+ } }
67+ name = 'flow'
68+ value = { data . relativePath ? data . relativePath : '' }
69+ className = 'h-12 p-2 border rounded outline-none cursor-default bg-background-light max-w-48 border-cyan-950'
70+ >
71+ < option key = 'None' value = '' >
72+ Select a flow
73+ </ option >
74+ { flowTests . map ( ( flowTestPath ) => {
75+ return (
76+ < option key = { flowTestPath } value = { flowTestPath } className = 'overflow-scroll' >
77+ { flowTestPath }
78+ </ option >
79+ ) ;
80+ } ) }
81+ </ select >
82+ </ Tippy >
6283
63- < p className = 'hidden' > </ p >
64- </ div >
65- </ FlowNode >
84+ < p className = 'hidden' > </ p >
85+ </ div >
86+ </ FlowNode >
87+ </ div >
6688 ) ;
6789} ;
6890
0 commit comments