@@ -77,12 +77,14 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
7777    } ) ; 
7878
7979    this . __categoryHeaders  =  [ ] ; 
80+     this . __itemIdx  =  0 ; 
8081
8182    this . __addItems ( ) ; 
8283  } , 
8384
8485  events : { 
8586    "createFolder" : "qx.event.type.Data" , 
87+     "changeTab" : "qx.event.type.Data" , 
8688    "newEmptyStudyClicked" : "qx.event.type.Data" , 
8789    "newStudyFromTemplateClicked" : "qx.event.type.Data" , 
8890    "newStudyFromServiceClicked" : "qx.event.type.Data" , 
@@ -137,13 +139,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
137139
138140  members : { 
139141    __categoryHeaders : null , 
142+     __itemIdx : null , 
140143
141144    _createChildControlImpl : function ( id )  { 
142145      let  control ; 
143146      switch  ( id )  { 
144147        case  "new-folder" :
148+           this . addSeparator ( ) ; 
145149          control  =  this . self ( ) . createMenuButton ( 
146-             osparc . dashboard . CardBase . NEW_ICON   +   " 16", 
150+             "@FontAwesome5Solid/folder/ 16", 
147151            this . tr ( "New Folder" ) , 
148152          ) ; 
149153          osparc . utils . Utils . setIdToWidget ( control ,  "newFolderButton" ) ; 
@@ -154,35 +158,69 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
154158      return  control  ||  this . base ( arguments ,  id ) ; 
155159    } , 
156160
157-     __addItems : async  function ( )  { 
161+     __addItems : function ( )  { 
162+       this . __addUIConfigItems ( ) ; 
163+       if  ( osparc . store . StaticInfo . getInstance ( ) . isDevFeaturesEnabled ( ) )  { 
164+         this . __addOtherTabsAccess ( ) ; 
165+       } 
158166      this . getChildControl ( "new-folder" ) ; 
159-       this . addSeparator ( ) ; 
160-       await  this . __addNewStudyItems ( ) ; 
161167    } , 
162168
163-     __addNewStudyItems :  async  function ( )  { 
169+     __addUIConfigItems :  function ( )  { 
164170      const  plusButtonConfig  =  osparc . store . Products . getInstance ( ) . getPlusButtonUiConfig ( ) ; 
165171      if  ( plusButtonConfig )  { 
166-         await  osparc . data . Resources . get ( "templates" ) 
167-           . then ( templates  =>  { 
168-             if  ( plusButtonConfig [ "categories" ] )  { 
169-               this . __addCategories ( plusButtonConfig [ "categories" ] ) ; 
170-             } 
171-             plusButtonConfig [ "resources" ] . forEach ( buttonConfig  =>  { 
172-               if  ( buttonConfig [ "showDisabled" ] )  { 
173-                 this . __addDisabledButton ( buttonConfig ) ; 
174-               }  else  if  ( buttonConfig [ "resourceType" ]  ===  "study" )  { 
175-                 this . __addEmptyStudyButton ( buttonConfig ) ; 
176-               }  else  if  ( buttonConfig [ "resourceType" ]  ===  "template" )  { 
177-                 this . __addFromTemplateButton ( buttonConfig ,  templates ) ; 
178-               }  else  if  ( buttonConfig [ "resourceType" ]  ===  "service" )  { 
179-                 this . __addFromServiceButton ( buttonConfig ) ; 
180-               } 
181-             } ) ; 
182-           } ) ; 
172+         const  templates  =  osparc . store . Templates . getInstance ( ) . getTemplates ( ) 
173+         if  ( plusButtonConfig [ "categories" ] )  { 
174+           this . __addCategories ( plusButtonConfig [ "categories" ] ) ; 
175+         } 
176+         plusButtonConfig [ "resources" ] . forEach ( buttonConfig  =>  { 
177+           if  ( buttonConfig [ "showDisabled" ] )  { 
178+             this . __addDisabledButton ( buttonConfig ) ; 
179+           }  else  if  ( buttonConfig [ "resourceType" ]  ===  "study" )  { 
180+             this . __addEmptyStudyButton ( buttonConfig ) ; 
181+           }  else  if  ( buttonConfig [ "resourceType" ]  ===  "template" )  { 
182+             this . __addFromTemplateButton ( buttonConfig ,  templates ) ; 
183+           }  else  if  ( buttonConfig [ "resourceType" ]  ===  "service" )  { 
184+             this . __addFromServiceButton ( buttonConfig ) ; 
185+           } 
186+         } ) ; 
183187      } 
184188    } , 
185189
190+     __addOtherTabsAccess : function ( )  { 
191+       const  moreMenuButton  =  this . self ( ) . createMenuButton ( "@FontAwesome5Solid/star/16" ,  this . tr ( "More" ) ) ; 
192+       this . addAt ( moreMenuButton ,  this . __itemIdx ) ; 
193+       this . __itemIdx ++ ; 
194+ 
195+       const  moreMenu  =  new  qx . ui . menu . Menu ( ) . set ( { 
196+         appearance : "menu-wider" , 
197+       } ) ; 
198+ 
199+       const  permissions  =  osparc . data . Permissions . getInstance ( ) ; 
200+       if  ( permissions . canDo ( "dashboard.templates.read" ) )  { 
201+         const  templatesButton  =  this . self ( ) . createMenuButton ( "@FontAwesome5Solid/copy/16" ,  this . tr ( "Tutorials..." ) ) ; 
202+         templatesButton . addListener ( "execute" ,  ( )  =>  this . fireDataEvent ( "changeTab" ,  "templatesTab" ) ,  this ) ; 
203+         moreMenu . add ( templatesButton ) ; 
204+ 
205+         const  hypertoolsButton  =  this . self ( ) . createMenuButton ( "@FontAwesome5Solid/copy/16" ,  this . tr ( "Hypertools..." ) ) ; 
206+         hypertoolsButton . addListener ( "execute" ,  ( )  =>  this . fireDataEvent ( "changeTab" ,  "hypertoolsTab" ) ,  this ) ; 
207+         const  hypertools  =  osparc . store . Templates . getInstance ( ) . getTemplatesByType ( osparc . data . model . StudyUI . HYPERTOOL_TYPE ) ; 
208+         if  ( hypertools . length )  { 
209+           moreMenu . add ( hypertoolsButton ) ; 
210+         } 
211+       } 
212+ 
213+       if  ( permissions . canDo ( "dashboard.services.read" ) )  { 
214+         const  servicesButton  =  this . self ( ) . createMenuButton ( "@FontAwesome5Solid/cog/16" ,  this . tr ( "Services..." ) ) ; 
215+         servicesButton . addListener ( "execute" ,  ( )  =>  this . fireDataEvent ( "changeTab" ,  "servicesTab" ) ,  this ) ; 
216+         moreMenu . add ( servicesButton ) ; 
217+       } 
218+ 
219+       moreMenuButton . setVisibility ( moreMenu . getChildren ( ) . length  ? "visible"  : "excluded" ) ; 
220+ 
221+       moreMenuButton . setMenu ( moreMenu ) ; 
222+     } , 
223+ 
186224    __getLastIdxFromCategory : function ( categoryId )  { 
187225      for  ( let  i = this . getChildren ( ) . length - 1 ;  i >= 0 ;  i -- )  { 
188226        const  child  =  this . getChildren ( ) [ i ] ; 
@@ -206,14 +244,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
206244      } ) ; 
207245    } , 
208246
209-     __addIcon : function ( menuButton ,  resourceInfo ,  resourceMetadata )  { 
210-       let  source  =  null ; 
211-       if  ( resourceInfo  &&  resourceInfo [ "icon" ] )  { 
212-         source  =  resourceInfo [ "icon" ] ; 
213-       }  else  { 
214-         source  =  osparc . utils . Utils . getIconFromResource ( resourceMetadata ) ; 
215-       } 
216- 
247+     __addIcon : function ( menuButton ,  icon ,  resourceMetadata )  { 
248+       const  source  =  icon  ? icon  : osparc . utils . Utils . getIconFromResource ( resourceMetadata ) ; 
217249      if  ( source )  { 
218250        const  thumbnail  =  new  osparc . ui . basic . Thumbnail ( source ,  24 ,  24 ) . set ( { 
219251          minHeight : 24 , 
@@ -237,7 +269,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
237269        menuButton [ "categoryId" ]  =  category ; 
238270        this . addAt ( menuButton ,  idx + 1 ) ; 
239271      }  else  { 
240-         this . add ( menuButton ) ; 
272+         this . addAt ( menuButton ,  this . __itemIdx ) ; 
273+         this . __itemIdx ++ ; 
241274      } 
242275    } , 
243276
@@ -246,21 +279,25 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
246279      osparc . utils . Utils . setIdToWidget ( menuButton ,  buttonConfig [ "idToWidget" ] ) ; 
247280      menuButton . setEnabled ( false ) ; 
248281
249-       this . __addIcon ( menuButton ,  buttonConfig ) ; 
282+       this . __addIcon ( menuButton ,  buttonConfig [ "icon" ] ) ; 
250283      this . __addFromResourceButton ( menuButton ,  buttonConfig [ "category" ] ) ; 
251284    } , 
252285
253-     __addEmptyStudyButton : function ( buttonConfig )  { 
254-       const  menuButton  =  this . self ( ) . createMenuButton ( null ,  buttonConfig [ "title" ] ) ; 
255-       osparc . utils . Utils . setIdToWidget ( menuButton ,  buttonConfig [ "idToWidget" ] ) ; 
286+     __addEmptyStudyButton : function ( buttonConfig  =  { } )  { 
287+       if  ( this . __emptyPipelineButton )  { 
288+         return ; 
289+       } 
290+ 
291+       const  menuButton  =  this . __emptyPipelineButton  =  this . self ( ) . createMenuButton ( null ,  buttonConfig [ "title" ]  ||  "Empty Pipeline" ) ; 
292+       osparc . utils . Utils . setIdToWidget ( menuButton ,  buttonConfig [ "idToWidget" ]  ||  "emptyStudyBtn" ) ; 
256293
257294      menuButton . addListener ( "tap" ,  ( )  =>  { 
258295        this . fireDataEvent ( "newEmptyStudyClicked" ,  { 
259-           newStudyLabel : buttonConfig [ "newStudyLabel" ] , 
296+           newStudyLabel : buttonConfig [ "newStudyLabel" ]   ||   "Empty Pipeline" , 
260297        } ) ; 
261298      } ) ; 
262299
263-       this . __addIcon ( menuButton ,  buttonConfig ) ; 
300+       this . __addIcon ( menuButton ,  buttonConfig [ "icon" ]   ||   "osparc/icons/diagram.png" ) ; 
264301      this . __addFromResourceButton ( menuButton ,  buttonConfig [ "category" ] ) ; 
265302    } , 
266303
@@ -279,7 +316,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
279316            newStudyLabel : buttonConfig [ "newStudyLabel" ] , 
280317          } ) ; 
281318        } ) ; 
282-         this . __addIcon ( menuButton ,  buttonConfig ,  templateMetadata ) ; 
319+         this . __addIcon ( menuButton ,  buttonConfig [ "icon" ] ,  templateMetadata ) ; 
283320        this . __addFromResourceButton ( menuButton ,  buttonConfig [ "category" ] ) ; 
284321      } 
285322    } , 
@@ -327,7 +364,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
327364          return ; 
328365        } 
329366        menuButton . setEnabled ( true ) ; 
330-         this . __addIcon ( menuButton ,  buttonConfig ,  latestMetadata ) ; 
367+         this . __addIcon ( menuButton ,  buttonConfig [ "icon" ] ,  latestMetadata ) ; 
331368        this . __addFromResourceButton ( menuButton ,  buttonConfig [ "category" ] ) ; 
332369        addListenerToButton ( menuButton ,  latestMetadata ) ; 
333370      }  else  if  ( "myMostUsed"  in  buttonConfig )  { 
0 commit comments