@@ -30,28 +30,28 @@ import ListMenu, { ListMenuItem } from "../ListMenu";
3030import MoreButton from "../ActionButtons/More" ;
3131import "./style.css" ;
3232
33- function containsTest ( tests , test ) {
34- return tests . find ( ( currTest ) => ( currTest . id === test . id ) ) ;
35- }
36-
3733const testTarget = {
3834 canDrop ( props , monitor ) {
39- const test = monitor . getItem ( ) ;
40- return ! containsTest ( props . suite . tests , test ) ;
35+ const test = monitor . getItem ( ) . test ;
36+ return ! props . suite . containsTest ( props . suite . tests , test ) ;
4137 } ,
42- drop ( props , monitor ) {
43- if ( monitor . didDrop ( ) ) {
38+ hover ( props , monitor ) {
39+ // check if they are different suites
40+ const dragged = monitor . getItem ( ) ;
41+ if ( monitor . canDrop ( ) && props . suite !== dragged . suite ) {
42+ dragged . suite . removeTestCase ( dragged . test ) ;
43+ props . suite . insertTestCaseAt ( dragged . test , 0 ) ;
44+ dragged . suite = props . suite ;
45+ dragged . index = 0 ;
4446 return ;
4547 }
46-
47- props . moveTest ( monitor . getItem ( ) , props . suite ) ;
4848 }
4949} ;
5050
5151function collect ( connect , monitor ) {
5252 return {
5353 connectDropTarget : connect . dropTarget ( ) ,
54- isOver : monitor . isOver ( ) ,
54+ isOver : monitor . isOver ( { shallow : true } ) ,
5555 canDrop : monitor . canDrop ( )
5656 } ;
5757}
@@ -101,16 +101,18 @@ class Suite extends React.Component {
101101 //setting component of context menu.
102102 this . props . setContextMenu ( listMenu ) ;
103103
104- return this . props . connectDropTarget (
104+ return (
105105 < div onKeyDown = { this . handleKeyDown . bind ( this ) } >
106106 < div className = "project" onContextMenu = { this . props . onContextMenu } >
107- < a href = "#" tabIndex = "-1" className = { classNames ( PlaybackState . suiteState . get ( this . props . suite . id ) , { "hover" : ( this . props . isOver && this . props . canDrop ) } , { "active" : this . store . isOpen } ) } onClick = { this . handleClick } >
108- < span className = "si-caret" > </ span >
109- < span className = "title" > { this . props . suite . name } </ span >
110- </ a >
107+ { this . props . connectDropTarget (
108+ < a href = "#" tabIndex = "-1" className = { classNames ( PlaybackState . suiteState . get ( this . props . suite . id ) , { "active" : this . store . isOpen } ) } onClick = { this . handleClick } >
109+ < span className = "si-caret" > </ span >
110+ < span className = "title" > { this . props . suite . name } </ span >
111+ </ a >
112+ ) }
111113 { listMenu }
112114 </ div >
113- < TestList collapsed = { ! this . store . isOpen } suite = { this . props . suite } tests = { this . store . filteredTests . get ( ) } removeTest = { ( test ) => {
115+ < TestList collapsed = { this . store . isOpen } suite = { this . props . suite } tests = { this . store . filteredTests . get ( ) } removeTest = { ( test ) => {
114116 this . props . suite . removeTestCase ( test ) ;
115117 UiState . selectTest ( ) ;
116118 } } />
0 commit comments