@@ -90,8 +90,8 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", {
9090 this . setDroppable ( true ) ;
9191
9292 this . addListener ( "dragover" , e => {
93- let compatible = false ;
9493 if ( e . supportsType ( "osparc-moveStudy" ) ) {
94+ let compatible = false ;
9595 const studyData = e . getData ( "osparc-moveStudy" ) [ "studyDataOrigin" ] ;
9696 // Compatibility checks:
9797 // - My workspace
@@ -107,42 +107,23 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", {
107107 } else {
108108 compatible = true ;
109109 }
110+ if ( compatible ) {
111+ this . getChildControl ( "icon" ) . setTextColor ( "strong-main" ) ;
112+ } else {
113+ this . getChildControl ( "icon" ) . setTextColor ( "danger-red" ) ;
114+ // do not allow
115+ e . preventDefault ( ) ;
116+ }
117+ const dragWidget = osparc . dashboard . DragWidget . getInstance ( ) ;
118+ dragWidget . setDropAllowed ( compatible ) ;
110119 } else if ( e . supportsType ( "osparc-moveFolder" ) ) {
111- const folder = this . __getFolder ( ) ;
112- if ( folder == null ) {
120+ const folderDest = this . __getFolder ( ) ;
121+ if ( folderDest == null ) {
113122 e . preventDefault ( ) ;
114123 return ;
115124 }
116-
117- // Compatibility checks:
118- // - It's not the same folder
119- // - My workspace
120- // - None
121- // - Shared workspace
122- // - write access on workspace
123- const folderOrigin = e . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
124- compatible = folder !== folderOrigin ;
125- const workspaceId = folderOrigin . getWorkspaceId ( ) ;
126- if ( compatible ) {
127- if ( workspaceId ) {
128- const workspace = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceId ) ;
129- if ( workspace ) {
130- compatible = workspace . getMyAccessRights ( ) [ "write" ] ;
131- }
132- } else {
133- compatible = true ;
134- }
135- }
125+ osparc . dashboard . DragDropHelpers . moveFolder . dragOver ( e , folderDest , this ) ;
136126 }
137- if ( compatible ) {
138- this . getChildControl ( "icon" ) . setTextColor ( "strong-main" ) ;
139- } else {
140- this . getChildControl ( "icon" ) . setTextColor ( "danger-red" ) ;
141- // do not allow
142- e . preventDefault ( ) ;
143- }
144- const dragWidget = osparc . dashboard . DragWidget . getInstance ( ) ;
145- dragWidget . setDropAllowed ( compatible ) ;
146127 } ) ;
147128
148129 this . addListener ( "dragleave" , ( ) => {
@@ -165,17 +146,12 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", {
165146 } ;
166147 this . fireDataEvent ( "studyToFolderRequested" , studyToFolderData ) ;
167148 } else if ( e . supportsType ( "osparc-moveFolder" ) ) {
168- const folder = this . __getFolder ( ) ;
169- if ( folder == null ) {
149+ const folderDest = this . __getFolder ( ) ;
150+ if ( folderDest == null ) {
170151 e . preventDefault ( ) ;
171152 return ;
172153 }
173-
174- const folderOrigin = e . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
175- const folderToFolderData = {
176- folderId : folderOrigin . getFolderId ( ) ,
177- destFolderId : folder . getFolderId ( ) ,
178- } ;
154+ const folderToFolderData = osparc . dashboard . DragDropHelpers . moveFolder . drop ( e , folderDest ) ;
179155 this . fireDataEvent ( "folderToFolderRequested" , folderToFolderData ) ;
180156 }
181157 } ) ;
0 commit comments