6
6
CollapseTitle as Title ,
7
7
CopyTextButton ,
8
8
FoldedIcon ,
9
- LeftClose ,
10
9
LeftCommon ,
11
- LeftOpen ,
10
+ LeftInfoFill ,
11
+ LeftInfoLine ,
12
12
PadDiv ,
13
13
ScrollBar ,
14
14
Tooltip ,
@@ -36,6 +36,7 @@ import cloneDeep from 'lodash/cloneDeep';
36
36
import { useDispatch } from "react-redux" ;
37
37
import { useApplicationId } from "util/hooks" ;
38
38
import { updateApplication } from "redux/reduxActions/applicationActions" ;
39
+ import { Divider } from "antd" ;
39
40
40
41
const CollapseTitleWrapper = styled . div `
41
42
display: flex;
@@ -195,6 +196,8 @@ const CollapseView = React.memo(
195
196
196
197
interface LeftContentProps {
197
198
uiComp : InstanceType < typeof UIComp > ;
199
+ checkable ?: boolean ;
200
+ isDraggable ?: boolean ;
198
201
}
199
202
200
203
enum LeftTabKey {
@@ -250,6 +253,8 @@ export const LeftContent = (props: LeftContentProps) => {
250
253
const [ showData , setShowData ] = useState < NodeInfo [ ] > ( [ ] ) ;
251
254
const dispatch = useDispatch ( ) ;
252
255
const applicationId = useApplicationId ( ) ;
256
+ const checkable = props . checkable || false ;
257
+ const isDraggable = props . isDraggable || false ;
253
258
254
259
const getTree = ( tree : CompTree , result : NodeItem [ ] , key ?: string ) => {
255
260
const { items, children } = tree ;
@@ -362,7 +367,7 @@ export const LeftContent = (props: LeftContentProps) => {
362
367
setShowData ( newData ) ;
363
368
} }
364
369
>
365
- < LeftOpen />
370
+ < LeftInfoLine />
366
371
</ div >
367
372
</ Tooltip >
368
373
) : (
@@ -395,7 +400,7 @@ export const LeftContent = (props: LeftContentProps) => {
395
400
setShowData ( newData ) ;
396
401
} }
397
402
>
398
- < LeftClose />
403
+ < LeftInfoFill />
399
404
</ div >
400
405
</ Tooltip >
401
406
) ) }
@@ -438,7 +443,7 @@ export const LeftContent = (props: LeftContentProps) => {
438
443
const explorerData : NodeItem [ ] = getTree ( tree , [ ] ) ;
439
444
// TODO: handle sorting inside modals/drawers
440
445
if ( type === TreeUIKey . Modals ) return explorerData ;
441
-
446
+
442
447
const dsl = editorState . rootComp . toJsonValue ( ) ;
443
448
explorerData . forEach ( data => {
444
449
data [ 'pos' ] = dsl . ui . layout [ data . key ] . pos ;
@@ -452,85 +457,7 @@ export const LeftContent = (props: LeftContentProps) => {
452
457
} ) ;
453
458
return explorerData ;
454
459
}
455
-
456
- interface DropInfo {
457
- node : { key : string ; pos : string } ;
458
- dragNode : { key : string ; pos : string } ;
459
- }
460
-
461
- const handleDragEnter = ( info : { node ?: any ; expandedKeys ?: any ; } ) => {
462
- // Assuming 'info' has a property 'expandedKeys' which is an array of keys
463
- const { expandedKeys } = info ;
464
- if ( ! expandedKeys . includes ( info . node . key ) ) {
465
- setExpandedKeys ( expandedKeys ) ;
466
- }
467
- } ;
468
-
469
- const handleDrop = ( info : { node : { key : any ; pos : string ; } ; dragNode : { key : any ; pos : string ; } ; } , type : TreeUIKey ) => {
470
- const dropPos = info . node . pos . split ( '-' ) ;
471
- const dragPos = info . dragNode . pos . split ( '-' ) ;
472
-
473
- if ( dropPos . length === dragPos . length ) {
474
- setComponentTreeData ( prevData => {
475
- let newTreeData = cloneDeep ( prevData ) ;
476
- const dropIndex = Number ( dropPos [ dropPos . length - 1 ] ) ;
477
- const dragIndex = Number ( dragPos [ dragPos . length - 1 ] ) ;
478
- const parentNodePos = dropPos . slice ( 0 , - 1 ) . join ( '-' ) ;
479
-
480
- // TODO: handle drag and drop for childen of root (container components for example)
481
- // findNodeByPos does not work yet
482
- const parentNode = parentNodePos === "0" ? { children : newTreeData } : findNodeByPos ( newTreeData , parentNodePos ) ;
483
-
484
- console . log ( 'parentNode' , parentNode ) ;
485
-
486
- if ( parentNode && parentNode . children ) {
487
- const draggedNodeIndex = parentNode . children . findIndex ( node => node . key === info . dragNode . key ) ;
488
- if ( draggedNodeIndex !== - 1 ) {
489
- const [ draggedNode ] = parentNode . children . splice ( draggedNodeIndex , 1 ) ;
490
- parentNode . children . splice ( dropIndex > dragIndex ? dropIndex - 1 : dropIndex , 0 , draggedNode ) ;
491
- }
492
- }
493
-
494
- const dsl = editorState . rootComp . toJsonValue ( ) ;
495
- let layout : any = { } ;
496
- parentNode . children . forEach ( ( data , index ) => {
497
- layout [ data . key ] = {
498
- ...dsl . ui . layout [ data . key ] ,
499
- pos : index ,
500
- } ;
501
- } )
502
-
503
- if ( type === TreeUIKey . Modals ) return newTreeData ;
504
-
505
- dispatch (
506
- updateApplication ( {
507
- applicationId : applicationId ,
508
- editingApplicationDSL : {
509
- ...dsl ,
510
- ui : {
511
- ...dsl . ui ,
512
- layout,
513
- }
514
- } as object ,
515
- } )
516
- ) ;
517
- editorState . rootComp . children . ui . dispatchChangeValueAction ( {
518
- ...dsl . ui ,
519
- layout,
520
- } )
521
- return newTreeData ;
522
- } ) ;
523
- }
524
- } ;
525
460
526
- const findNodeByPos = ( nodes : NodeItem [ ] , pos : string ) : { children : NodeItem [ ] } => {
527
- const posArr = pos . split ( '-' ) . map ( p => Number ( p ) ) ;
528
- let currentNode = { children : nodes } ;
529
- for ( let i = 0 ; i < posArr . length ; i ++ ) {
530
- currentNode = currentNode . children [ posArr [ i ] ] ;
531
- }
532
- return currentNode ;
533
- } ;
534
461
535
462
const getTreeUI = ( type : TreeUIKey ) => {
536
463
// here the components get sorted by name
@@ -559,21 +486,22 @@ export const LeftContent = (props: LeftContentProps) => {
559
486
}
560
487
561
488
return (
562
- < DirectoryTreeStyle
563
- draggable = { type === TreeUIKey . Components ? true : false }
564
- onDragEnter = { handleDragEnter }
565
- onDrop = { ( info ) => handleDrop ( info , type ) }
489
+ < > < DirectoryTreeStyle
566
490
treeData = { type === TreeUIKey . Components ? componentTreeData : modalsTreeData }
567
- icon = { ( props : any ) => props . type && ( CompStateIcon [ props . type as UICompType ] || < LeftCommon /> ) }
568
- switcherIcon = { ( props : any ) =>
569
- props . expanded ? < FoldedIcon /> : < UnfoldIcon />
570
- }
491
+ icon = { ( props : any ) => props . type && (
492
+ < div style = { { margin : '3px 0 0 -3px' } } > { /* Adjust the margin as needed */ }
493
+ { CompStateIcon [ props . type as UICompType ] || < LeftCommon /> }
494
+ </ div >
495
+ ) }
496
+ switcherIcon = { ( props : any ) => props . expanded ? < FoldedIcon /> : < UnfoldIcon /> }
571
497
expandedKeys = { expandedKeys }
572
498
onExpand = { ( keys ) => setExpandedKeys ( keys ) }
573
499
onClick = { ( e , node ) => handleNodeClick ( e , node , uiCompInfos ) }
574
500
selectedKeys = { selectedKeys }
575
- titleRender = { ( nodeData ) => getTreeNode ( nodeData as NodeItem , uiCompInfos ) }
576
- />
501
+ titleRender = { ( nodeData ) => getTreeNode ( nodeData as NodeItem , uiCompInfos ) } />
502
+ < Divider />
503
+ < div > </ div >
504
+ </ >
577
505
) ;
578
506
} ;
579
507
@@ -623,6 +551,7 @@ export const LeftContent = (props: LeftContentProps) => {
623
551
} , [ editorState ] ) ;
624
552
625
553
const moduleLayoutComp = uiComp . getModuleLayoutComp ( ) ;
554
+
626
555
const stateContent = (
627
556
< ScrollBar >
628
557
< div style = { { paddingBottom : 80 } } >
0 commit comments