@@ -49,6 +49,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
4949 } ,
5050
5151 properties : {
52+ currentContext : {
53+ check : [ "studiesAndFolders" , "workspaces" , "search" , "bin" ] ,
54+ nullable : false ,
55+ init : "studiesAndFolders" ,
56+ event : "changeCurrentContext"
57+ } ,
58+
5259 currentWorkspaceId : {
5360 check : "Number" ,
5461 nullable : true ,
@@ -101,7 +108,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
101108
102109 members : {
103110 __dontShowTutorial : null ,
104- __workspaceHeader : null ,
111+ __header : null ,
105112 __workspacesList : null ,
106113 __foldersList : null ,
107114
@@ -177,7 +184,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
177184 if ( osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ) {
178185 const folderId = this . getCurrentFolderId ( ) ;
179186 const workspaceId = this . getCurrentWorkspaceId ( ) ;
180- if ( workspaceId === - 1 || workspaceId === - 2 ) {
187+ if ( this . getCurrentContext ( ) !== "studiesAndFolders" ) {
181188 return ;
182189 }
183190 this . __setFoldersToList ( [ ] ) ;
@@ -412,7 +419,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
412419 __addNewFolderButton : function ( ) {
413420 const currentWorkspaceId = this . getCurrentWorkspaceId ( ) ;
414421 if ( currentWorkspaceId ) {
415- if ( currentWorkspaceId === - 1 || currentWorkspaceId === - 2 ) {
422+ if ( this . getCurrentContext ( ) !== "studiesAndFolders" ) {
416423 return ;
417424 }
418425 const currentWorkspace = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( this . getCurrentWorkspaceId ( ) ) ;
@@ -697,11 +704,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
697704 } ,
698705
699706 __addNewStudyButtons : function ( ) {
707+ if ( this . getCurrentContext ( ) !== "studiesAndFolders" ) {
708+ return ;
709+ }
700710 const currentWorkspaceId = this . getCurrentWorkspaceId ( ) ;
701711 if ( currentWorkspaceId ) {
702- if ( currentWorkspaceId === - 2 ) {
703- return ;
704- }
705712 const currentWorkspace = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( currentWorkspaceId ) ;
706713 if ( currentWorkspace && ! currentWorkspace . getMyAccessRights ( ) [ "write" ] ) {
707714 // If user can't write in workspace, do not show plus buttons
@@ -827,8 +834,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
827834 this . _createSearchBar ( ) ;
828835
829836 if ( osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ) {
830- const workspaceHeader = this . __workspaceHeader = new osparc . dashboard . WorkspaceHeader ( ) ;
831- this . _addToLayout ( workspaceHeader ) ;
837+ const header = this . __header = new osparc . dashboard . StudyBrowserHeader ( ) ;
838+ this . _addToLayout ( header ) ;
832839 }
833840
834841 this . _createResourcesLayout ( ) ;
@@ -900,7 +907,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
900907
901908 __connectContexts : function ( ) {
902909 if ( osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ) {
903- const workspaceHeader = this . __workspaceHeader ;
910+ const workspaceHeader = this . __header ;
904911 workspaceHeader . addListener ( "contextChanged" , ( ) => {
905912 const workspaceId = workspaceHeader . getCurrentWorkspaceId ( ) ;
906913 const folderId = workspaceHeader . getCurrentFolderId ( ) ;
@@ -940,31 +947,41 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
940947
941948 this . resetSelection ( ) ;
942949 this . setMultiSelection ( false ) ;
950+ let currentContext = null ;
951+ switch ( workspaceId ) {
952+ case - 2 :
953+ currentContext = "search" ;
954+ break ;
955+ case - 1 :
956+ currentContext = "workspaces" ;
957+ break ;
958+ default :
959+ currentContext = "studiesAndFolders" ;
960+ break ;
961+ }
943962 this . set ( {
963+ currentContext,
944964 currentWorkspaceId : workspaceId ,
945965 currentFolderId : folderId ,
946966 } ) ;
947967 this . invalidateStudies ( ) ;
948968 this . _resourcesContainer . setResourcesToList ( [ ] ) ;
949969
950- if ( workspaceId === - 2 ) {
951- // Search result: no folders, just studies
970+ if ( currentContext === "search" ) {
952971 this . __setFoldersToList ( [ ] ) ;
953972 this . __reloadStudies ( ) ;
954- } else if ( workspaceId === - 1 ) {
955- // Workspaces
973+ } else if ( currentContext === "workspaces" ) {
956974 this . _searchBarFilter . resetFilters ( ) ;
957975 this . __reloadWorkspaces ( ) ;
958- } else {
959- // Actual workspace
976+ } else if ( currentContext === "studiesAndFolders" ) {
960977 this . _searchBarFilter . resetFilters ( ) ;
961978 this . __reloadFolders ( ) ;
962979 this . __reloadStudies ( ) ;
963980 }
964981
965- // notify workspaceHeader
966- const workspaceHeader = this . __workspaceHeader ;
967- workspaceHeader . set ( {
982+ // notify header
983+ const header = this . __header ;
984+ header . set ( {
968985 currentWorkspaceId : workspaceId ,
969986 currentFolderId : folderId ,
970987 } ) ;
0 commit comments