@@ -935,36 +935,91 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
935935
936936      if  ( ! osparc . product . Utils . hasNewPlusButton ( ) )  { 
937937        switch  ( osparc . product . Utils . getProductName ( ) )  { 
938-           case  "osparc" :
939-             this . __addEmptyStudyPlusButton ( ) ; 
940-             break ; 
941938          case  "tis" :
942939          case  "tiplite" :
940+             // this one is different since it groups all new buttons in one new button 
943941            this . __addTIPPlusButton ( ) ; 
944942            break ; 
945-           case  "s4l" :
946-           case  "s4lacad" :
947-           case  "s4llite" :
948-             this . __addPlusButtonsFromServices ( ) ; 
943+           default :
944+             this . __addPlusButtons ( ) ; 
949945            break ; 
950946        } 
951947      } 
952948    } , 
953949
954-     __addEmptyStudyPlusButton : function ( )  { 
950+     __addPlusButtons : function ( )  { 
951+       const  plusButtonConfig  =  osparc . store . Products . getInstance ( ) . getNewStudiesUiConfig ( ) ; 
952+       plusButtonConfig [ "resources" ] . forEach ( newStudyData  =>  { 
953+         if  ( newStudyData [ "resourceType" ]  ===  "study" )  { 
954+           this . __addEmptyStudyPlusButton ( newStudyData ) ; 
955+         }  else  if  ( newStudyData [ "resourceType" ]  ===  "service" )  { 
956+           this . __addNewStudyFromServiceButton ( newStudyData ) ; 
957+         } 
958+       } ) ; 
959+     } , 
960+ 
961+     __addEmptyStudyPlusButton : function ( newStudyData )  { 
955962      const  mode  =  this . _resourcesContainer . getMode ( ) ; 
956-       const  title  =  this . tr ( "Empty" )  +  " "  +  osparc . product . Utils . getStudyAlias ( { 
963+       const  defTitle  =  this . tr ( "Empty" )  +  " "  +  osparc . product . Utils . getStudyAlias ( { 
957964        firstUpperCase : true 
958-       } ) 
959-       const  desc  =  this . tr ( "Start with an empty study" ) ; 
965+       } ) ; 
966+       const  title  =  newStudyData [ "title" ]  ||  defTitle ; 
967+       const  desc  =  newStudyData [ "description" ]  ||  this . tr ( "Start with an empty study" ) ; 
960968      const  newEmptyStudyBtn  =  ( mode  ===  "grid" )  ? new  osparc . dashboard . GridButtonNew ( title ,  desc )  : new  osparc . dashboard . ListButtonNew ( title ,  desc ) ; 
961969      newEmptyStudyBtn . setCardKey ( "new-study" ) ; 
962970      newEmptyStudyBtn . subscribeToFilterGroup ( "searchBarFilter" ) ; 
963-       osparc . utils . Utils . setIdToWidget ( newEmptyStudyBtn ,  "emptyStudyBtn" ) ; 
964-       newEmptyStudyBtn . addListener ( "tap" ,  ( )  =>  this . __newEmptyStudyBtnClicked ( "New Study" ) ) ; 
971+       osparc . utils . Utils . setIdToWidget ( newEmptyStudyBtn ,  newStudyData [ "idToWidget" ] ) ; 
972+       newEmptyStudyBtn . addListener ( "tap" ,  ( )  =>  this . __newEmptyStudyBtnClicked ( newStudyData [ "newStudyLabel" ] ) ) ; 
965973      this . _resourcesContainer . addNonResourceCard ( newEmptyStudyBtn ) ; 
966974    } , 
967975
976+     __addNewStudyFromServiceButton : function ( newStudyData )  { 
977+       if  ( "expectedKey"  in  newStudyData )  { 
978+         const  key  =  newStudyData [ "expectedKey" ] ; 
979+         // Include deprecated versions, they should all be updatable to a non deprecated version 
980+         const  versions  =  osparc . service . Utils . getVersions ( key ,  false ) ; 
981+         if  ( versions . length  &&  newStudyData )  { 
982+           // scale to latest compatible 
983+           const  latestVersion  =  versions [ 0 ] ; 
984+           const  latestCompatible  =  osparc . service . Utils . getLatestCompatible ( key ,  latestVersion ) ; 
985+           osparc . store . Services . getService ( latestCompatible [ "key" ] ,  latestCompatible [ "version" ] ) 
986+             . then ( latestMetadata  =>  { 
987+               // make sure this one is not deprecated 
988+               if  ( osparc . service . Utils . isDeprecated ( latestMetadata ) )  { 
989+                 return ; 
990+               } 
991+               const  title  =  newStudyData . title  +  " "  +  osparc . service . Utils . extractVersionDisplay ( latestMetadata ) ; 
992+               const  desc  =  newStudyData . description ; 
993+               const  mode  =  this . _resourcesContainer . getMode ( ) ; 
994+               const  newStudyFromServiceButton  =  ( mode  ===  "grid" )  ? new  osparc . dashboard . GridButtonNew ( title ,  desc )  : new  osparc . dashboard . ListButtonNew ( title ,  desc ) ; 
995+               newStudyFromServiceButton . setCardKey ( "new-" + key ) ; 
996+               if  ( newStudyData [ "idToWidget" ] )  { 
997+                 osparc . utils . Utils . setIdToWidget ( newStudyFromServiceButton ,  newStudyData [ "idToWidget" ] ) ; 
998+               } 
999+               newStudyFromServiceButton . addListener ( "tap" ,  ( )  =>  this . __newStudyFromServiceBtnClicked ( latestMetadata [ "key" ] ,  latestMetadata [ "version" ] ,  newStudyData . newStudyLabel ) ) ; 
1000+               this . _resourcesContainer . addNonResourceCard ( newStudyFromServiceButton ) ; 
1001+             } ) 
1002+         } 
1003+       }  else  if  ( "myMostUsed"  in  newStudyData )  { 
1004+         const  excludeFrontend  =  true ; 
1005+         const  excludeDeprecated  =  true 
1006+         osparc . store . Services . getServicesLatestList ( excludeFrontend ,  excludeDeprecated ) 
1007+           . then ( servicesList  =>  { 
1008+             osparc . service . Utils . sortObjectsBasedOn ( servicesList ,  { 
1009+               "sort" : "hits" , 
1010+               "order" : "down" 
1011+             } ) ; 
1012+             for  ( let  i = 0 ;  i < newStudyData [ "myMostUsed" ] ;  i ++ )  { 
1013+               const  latestMetadata  =  servicesList [ i ] ; 
1014+               const  mode  =  this . _resourcesContainer . getMode ( ) ; 
1015+               const  newStudyFromServiceButton  =  ( mode  ===  "grid" )  ? new  osparc . dashboard . GridButtonNew ( latestMetadata [ "name" ] )  : new  osparc . dashboard . ListButtonNew ( latestMetadata [ "name" ] ) ; 
1016+               newStudyFromServiceButton . addListener ( "tap" ,  ( )  =>  this . __newStudyFromServiceBtnClicked ( latestMetadata [ "key" ] ,  latestMetadata [ "version" ] ,  latestMetadata [ "name" ] ) ) ; 
1017+               this . _resourcesContainer . addNonResourceCard ( newStudyFromServiceButton ) ; 
1018+             } 
1019+           } ) ; 
1020+       } 
1021+     } , 
1022+ 
9681023    __addTIPPlusButton : function ( )  { 
9691024      const  mode  =  this . _resourcesContainer . getMode ( ) ; 
9701025      const  title  =  this . tr ( "New Plan" ) ; 
@@ -975,15 +1030,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
9751030      this . _resourcesContainer . addNonResourceCard ( newPlansBtn ) ; 
9761031      newPlansBtn . setEnabled ( false ) ; 
9771032
978-       const  newStudiesData  =  osparc . store . Products . getInstance ( ) . getNewStudiesUiConfig ( ) ; 
979-       if  ( newStudiesData )  { 
1033+       const  newStudiesConfig  =  osparc . store . Products . getInstance ( ) . getNewStudiesUiConfig ( ) ; 
1034+       if  ( newStudiesConfig )  { 
9801035        newPlansBtn . setEnabled ( true ) ; 
9811036
9821037        newPlansBtn . addListener ( "tap" ,  ( )  =>  { 
9831038          osparc . data . Resources . get ( "templates" ) 
9841039            . then ( templates  =>  { 
9851040              if  ( templates )  { 
986-                 const  newStudies  =  new  osparc . dashboard . NewStudies ( newStudiesData ) ; 
1041+                 const  newStudies  =  new  osparc . dashboard . NewStudies ( newStudiesConfig ) ; 
9871042                newStudies . addListener ( "templatesLoaded" ,  ( )  =>  { 
9881043                  newStudies . setGroupBy ( "category" ) ; 
9891044                  const  winTitle  =  this . tr ( "New Plan" ) ; 
@@ -1007,45 +1062,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10071062      } 
10081063    } , 
10091064
1010-     // Used in S4L products 
1011-     __addNewStudyFromServiceButtons : function ( key ,  newButtonInfo )  { 
1012-       // Include deprecated versions, they should all be updatable to a non deprecated version 
1013-       const  versions  =  osparc . service . Utils . getVersions ( key ,  false ) ; 
1014-       if  ( versions . length  &&  newButtonInfo )  { 
1015-         // scale to latest compatible 
1016-         const  latestVersion  =  versions [ 0 ] ; 
1017-         const  latestCompatible  =  osparc . service . Utils . getLatestCompatible ( key ,  latestVersion ) ; 
1018-         osparc . store . Services . getService ( latestCompatible [ "key" ] ,  latestCompatible [ "version" ] ) 
1019-           . then ( latestMetadata  =>  { 
1020-             // make sure this one is not deprecated 
1021-             if  ( osparc . service . Utils . isDeprecated ( latestMetadata ) )  { 
1022-               return ; 
1023-             } 
1024-             const  title  =  newButtonInfo . title  +  " "  +  osparc . service . Utils . extractVersionDisplay ( latestMetadata ) ; 
1025-             const  desc  =  newButtonInfo . description ; 
1026-             const  mode  =  this . _resourcesContainer . getMode ( ) ; 
1027-             const  newStudyFromServiceButton  =  ( mode  ===  "grid" )  ? new  osparc . dashboard . GridButtonNew ( title ,  desc )  : new  osparc . dashboard . ListButtonNew ( title ,  desc ) ; 
1028-             newStudyFromServiceButton . setCardKey ( "new-" + key ) ; 
1029-             if  ( newButtonInfo [ "idToWidget" ] )  { 
1030-               osparc . utils . Utils . setIdToWidget ( newStudyFromServiceButton ,  newButtonInfo [ "idToWidget" ] ) ; 
1031-             } 
1032-             newStudyFromServiceButton . addListener ( "tap" ,  ( )  =>  this . __newStudyFromServiceBtnClicked ( latestMetadata [ "key" ] ,  latestMetadata [ "version" ] ,  newButtonInfo . newStudyLabel ) ) ; 
1033-             this . _resourcesContainer . addNonResourceCard ( newStudyFromServiceButton ) ; 
1034-           } ) 
1035-       } 
1036-     } , 
1037- 
1038-     __addPlusButtonsFromServices : function ( )  { 
1039-       // add new plus buttons if key services exists 
1040-       const  newStudiesData  =  osparc . store . Products . getInstance ( ) . getNewStudiesUiConfig ( ) ; 
1041-       if  ( newStudiesData )  { 
1042-         const  newButtonsInfo  =  newStudiesData [ "resources" ] ; 
1043-         newButtonsInfo . forEach ( newButtonInfo  =>  { 
1044-           this . __addNewStudyFromServiceButtons ( newButtonInfo . expectedKey ,  newButtonInfo ) ; 
1045-         } ) ; 
1046-       } 
1047-     } , 
1048- 
10491065    // LAYOUT // 
10501066    _createLayout : function ( )  { 
10511067      this . _createSearchBar ( ) ; 
0 commit comments