@@ -99,6 +99,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
9999 __workspacesList : null ,
100100 __foldersList : null ,
101101 __loadingFolders : null ,
102+ __loadingWorkspaces : null ,
102103
103104 // overridden
104105 initResources : function ( ) {
@@ -163,11 +164,40 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
163164 } ,
164165
165166 __reloadWorkspaces : function ( ) {
167+ if (
168+ ! osparc . auth . Manager . getInstance ( ) . isLoggedIn ( ) ||
169+ ! osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ||
170+ this . getCurrentContext ( ) === "studiesAndFolders" ||
171+ this . __loadingWorkspaces
172+ ) {
173+ return ;
174+ }
175+
176+ let request = null ;
177+ switch ( this . getCurrentContext ( ) ) {
178+ case "search" : {
179+ const filterData = this . _searchBarFilter . getFilterData ( ) ;
180+ const text = filterData . text ? encodeURIComponent ( filterData . text ) : "" ;
181+ request = osparc . store . Workspaces . getInstance ( ) . searchWorkspaces ( text ) ;
182+ break ;
183+ }
184+ case "workspaces" : {
185+ request = osparc . store . Workspaces . getInstance ( ) . fetchWorkspaces ( ) ;
186+ break ;
187+ }
188+ case "trash" :
189+ request = osparc . store . Workspaces . getInstance ( ) . fetchTrashedWorkspaces ( ) ;
190+ break ;
191+ }
192+
193+ this . __loadingWorkspaces = true ;
166194 this . __setWorkspacesToList ( [ ] ) ;
167- osparc . store . Workspaces . getInstance ( ) . fetchWorkspaces ( )
195+ request
168196 . then ( workspaces => {
169197 this . __setWorkspacesToList ( workspaces ) ;
170- } ) ;
198+ } )
199+ . catch ( console . error )
200+ . finally ( ( ) => this . __loadingWorkspaces = null ) ;
171201 } ,
172202
173203 __reloadFolders : function ( ) {
@@ -180,7 +210,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
180210 return ;
181211 }
182212
183- this . __loadingFolders = true ;
184213 let request = null ;
185214 switch ( this . getCurrentContext ( ) ) {
186215 case "search" : {
@@ -200,6 +229,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
200229 break ;
201230 }
202231
232+ this . __loadingFolders = true ;
203233 this . __setFoldersToList ( [ ] ) ;
204234 request
205235 . then ( folders => {
@@ -1032,10 +1062,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10321062
10331063 this . _toolbar . show ( ) ;
10341064 if ( context === "search" ) {
1065+ this . __reloadWorkspaces ( ) ;
10351066 this . __reloadFolders ( ) ;
10361067 this . __reloadStudies ( ) ;
10371068 } else if ( context === "trash" ) {
1038- // for now, studies only
1069+ this . _searchBarFilter . resetFilters ( ) ;
1070+ this . __reloadWorkspaces ( ) ;
10391071 this . __reloadFolders ( ) ;
10401072 this . __reloadStudies ( ) ;
10411073 } else if ( context === "workspaces" ) {
0 commit comments