@@ -39,22 +39,35 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
3939 studyItem . setOpacity ( 0.2 ) ;
4040 } ,
4141
42- dragOver : function ( event , folderDest , folderItem ) {
42+ dragOver : function ( event , folderItem , workspaceDestId ) {
4343 let compatible = false ;
4444 const studyDataOrigin = event . getData ( "osparc-moveStudy" ) [ "studyDataOrigin" ] ;
45+ const workspaceIdOrigin = studyDataOrigin [ "workspaceId" ] ;
46+ const workspaceOrigin = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceIdOrigin ) ;
47+ const workspaceDest = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceDestId ) ;
4548 // Compatibility checks:
46- // - My workspace
49+ // - Drag over "Shared Workspaces" (0)
50+ // - No
51+ // - My Workspace -> My Workspace (1)
4752 // - None
48- // - Shared workspace
49- // - write access on workspace
50- const workspaceId = studyDataOrigin [ "workspaceId" ] ;
51- if ( workspaceId ) {
52- const workspace = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceId ) ;
53- if ( workspace ) {
54- compatible = workspace . getMyAccessRights ( ) [ "write" ] ;
55- }
56- } else {
53+ // - My Workspace -> Shared Workspace (2)
54+ // - Delete on Study
55+ // - Write on dest Workspace
56+ // - Shared Workspace -> My Workspace (3)
57+ // - Delete on origin Workspace
58+ // - Shared Workspace -> Shared Workspace (4)
59+ // - Delete on origin Workspace
60+ // - Write on dest Workspace
61+ if ( workspaceDestId === - 1 ) { // (0)
62+ compatible = false ;
63+ } else if ( studyDataOrigin [ "workspaceId" ] === null && workspaceDest === null ) { // (1)
5764 compatible = true ;
65+ } else if ( studyDataOrigin [ "workspaceId" ] === null && workspaceDest ) { // (2)
66+ compatible = osparc . data . model . Study . canIDelete ( studyDataOrigin [ "accessRights" ] ) && workspaceDest . getMyAccessRights ( ) [ "write" ] ;
67+ } else if ( workspaceOrigin && workspaceDest === null ) { // (3)
68+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] ;
69+ } else if ( workspaceOrigin && workspaceDest ) { // (4)
70+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] && workspaceDest . getMyAccessRights ( ) [ "write" ] ;
5871 }
5972 if ( compatible ) {
6073 folderItem . getChildControl ( "icon" ) . setTextColor ( "strong-main" ) ;
@@ -97,7 +110,7 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
97110 folderItem . setOpacity ( 0.2 ) ;
98111 } ,
99112
100- dragOver : function ( event , folderDest , folderItem ) {
113+ dragOver : function ( event , folderItem , folderDest ) {
101114 let compatible = false ;
102115 // Compatibility checks:
103116 // - It's not the same folder
0 commit comments