@@ -77,12 +77,14 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
77
77
} ) ;
78
78
79
79
this . __categoryHeaders = [ ] ;
80
+ this . __itemIdx = 0 ;
80
81
81
82
this . __addItems ( ) ;
82
83
} ,
83
84
84
85
events : {
85
86
"createFolder" : "qx.event.type.Data" ,
87
+ "changeTab" : "qx.event.type.Data" ,
86
88
"newEmptyStudyClicked" : "qx.event.type.Data" ,
87
89
"newStudyFromTemplateClicked" : "qx.event.type.Data" ,
88
90
"newStudyFromServiceClicked" : "qx.event.type.Data" ,
@@ -137,13 +139,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
137
139
138
140
members : {
139
141
__categoryHeaders : null ,
142
+ __itemIdx : null ,
140
143
141
144
_createChildControlImpl : function ( id ) {
142
145
let control ;
143
146
switch ( id ) {
144
147
case "new-folder" :
148
+ this . addSeparator ( ) ;
145
149
control = this . self ( ) . createMenuButton (
146
- osparc . dashboard . CardBase . NEW_ICON + " 16",
150
+ "@FontAwesome5Solid/folder/ 16",
147
151
this . tr ( "New Folder" ) ,
148
152
) ;
149
153
osparc . utils . Utils . setIdToWidget ( control , "newFolderButton" ) ;
@@ -154,35 +158,69 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
154
158
return control || this . base ( arguments , id ) ;
155
159
} ,
156
160
157
- __addItems : async function ( ) {
161
+ __addItems : function ( ) {
162
+ this . __addUIConfigItems ( ) ;
163
+ if ( osparc . store . StaticInfo . getInstance ( ) . isDevFeaturesEnabled ( ) ) {
164
+ this . __addOtherTabsAccess ( ) ;
165
+ }
158
166
this . getChildControl ( "new-folder" ) ;
159
- this . addSeparator ( ) ;
160
- await this . __addNewStudyItems ( ) ;
161
167
} ,
162
168
163
- __addNewStudyItems : async function ( ) {
169
+ __addUIConfigItems : function ( ) {
164
170
const plusButtonConfig = osparc . store . Products . getInstance ( ) . getPlusButtonUiConfig ( ) ;
165
171
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
+ } ) ;
183
187
}
184
188
} ,
185
189
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
+
186
224
__getLastIdxFromCategory : function ( categoryId ) {
187
225
for ( let i = this . getChildren ( ) . length - 1 ; i >= 0 ; i -- ) {
188
226
const child = this . getChildren ( ) [ i ] ;
@@ -206,14 +244,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
206
244
} ) ;
207
245
} ,
208
246
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 ) ;
217
249
if ( source ) {
218
250
const thumbnail = new osparc . ui . basic . Thumbnail ( source , 24 , 24 ) . set ( {
219
251
minHeight : 24 ,
@@ -237,7 +269,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
237
269
menuButton [ "categoryId" ] = category ;
238
270
this . addAt ( menuButton , idx + 1 ) ;
239
271
} else {
240
- this . add ( menuButton ) ;
272
+ this . addAt ( menuButton , this . __itemIdx ) ;
273
+ this . __itemIdx ++ ;
241
274
}
242
275
} ,
243
276
@@ -246,21 +279,25 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
246
279
osparc . utils . Utils . setIdToWidget ( menuButton , buttonConfig [ "idToWidget" ] ) ;
247
280
menuButton . setEnabled ( false ) ;
248
281
249
- this . __addIcon ( menuButton , buttonConfig ) ;
282
+ this . __addIcon ( menuButton , buttonConfig [ "icon" ] ) ;
250
283
this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
251
284
} ,
252
285
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" ) ;
256
293
257
294
menuButton . addListener ( "tap" , ( ) => {
258
295
this . fireDataEvent ( "newEmptyStudyClicked" , {
259
- newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
296
+ newStudyLabel : buttonConfig [ "newStudyLabel" ] || "Empty Pipeline" ,
260
297
} ) ;
261
298
} ) ;
262
299
263
- this . __addIcon ( menuButton , buttonConfig ) ;
300
+ this . __addIcon ( menuButton , buttonConfig [ "icon" ] || "osparc/icons/diagram.png" ) ;
264
301
this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
265
302
} ,
266
303
@@ -279,7 +316,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
279
316
newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
280
317
} ) ;
281
318
} ) ;
282
- this . __addIcon ( menuButton , buttonConfig , templateMetadata ) ;
319
+ this . __addIcon ( menuButton , buttonConfig [ "icon" ] , templateMetadata ) ;
283
320
this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
284
321
}
285
322
} ,
@@ -327,7 +364,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
327
364
return ;
328
365
}
329
366
menuButton . setEnabled ( true ) ;
330
- this . __addIcon ( menuButton , buttonConfig , latestMetadata ) ;
367
+ this . __addIcon ( menuButton , buttonConfig [ "icon" ] , latestMetadata ) ;
331
368
this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
332
369
addListenerToButton ( menuButton , latestMetadata ) ;
333
370
} else if ( "myMostUsed" in buttonConfig ) {
0 commit comments