@@ -38,23 +38,12 @@ qx.Class.define("osparc.store.Products", {
3838 }
3939
4040 Promise . all ( [
41- osparc . data . Resources . fetch ( "productMetadata" , "getUiConfig" ) ,
42- osparc . utils . Utils . fetchJSON ( "/resource/osparc/ui_config.json" ) ,
41+ this . __getUIConfig ( ) ,
4342 osparc . utils . Utils . fetchJSON ( "/resource/schemas/product-ui.json" ) ,
4443 ] )
4544 . then ( values => {
46- let uiConfig = { } ;
47- const beUiConfig = values [ 0 ] ;
48- const feUiConfig = values [ 1 ] ;
49- const schema = values [ 2 ] ;
50- if ( beUiConfig && beUiConfig [ "ui" ] && Object . keys ( beUiConfig [ "ui" ] ) . length ) {
51- uiConfig = beUiConfig [ "ui" ] ;
52- } else {
53- const product = osparc . product . Utils . getProductName ( ) ;
54- if ( feUiConfig && product in feUiConfig ) {
55- uiConfig = feUiConfig [ product ] ;
56- }
57- }
45+ const uiConfig = values [ 0 ] ;
46+ const schema = values [ 1 ] ;
5847 const ajvLoader = new qx . util . DynamicScriptLoader ( [
5948 "/resource/ajv/ajv-6-11-0.min.js" ,
6049 "/resource/object-path/object-path-0-11-4.min.js"
@@ -85,6 +74,46 @@ qx.Class.define("osparc.store.Products", {
8574 } ) ;
8675 } ,
8776
77+ __getUIConfig : function ( ) {
78+ return Promise . all ( [
79+ this . __getUiConfigBackend ( ) ,
80+ this . __getUiConfigFrontend ( ) ,
81+ ] )
82+ . then ( values => {
83+ const beUiConfig = values [ 0 ] ;
84+ if ( beUiConfig ) {
85+ return beUiConfig ;
86+ }
87+ const feUiConfig = values [ 1 ] ;
88+ return feUiConfig || { } ;
89+ } ) ;
90+ } ,
91+
92+ __getUiConfigBackend : function ( ) {
93+ if ( osparc . auth . Data . getInstance ( ) . isGuest ( ) ) {
94+ // Guest users do not have access to product metadata
95+ return Promise . resolve ( null ) ;
96+ }
97+ return osparc . data . Resources . fetch ( "productMetadata" , "getUiConfig" )
98+ . then ( response => {
99+ if ( response && response [ "ui" ] && Object . keys ( response [ "ui" ] ) . length ) {
100+ return response [ "ui" ] ;
101+ }
102+ return null ;
103+ } ) ;
104+ } ,
105+
106+ __getUiConfigFrontend : function ( ) {
107+ return osparc . utils . Utils . fetchJSON ( "/resource/osparc/ui_config.json" )
108+ . then ( uiConfig => {
109+ const product = osparc . product . Utils . getProductName ( ) ;
110+ if ( uiConfig && product in uiConfig ) {
111+ return uiConfig [ product ] ;
112+ }
113+ return null ;
114+ } ) ;
115+ } ,
116+
88117 getPlusButtonUiConfig : function ( ) {
89118 return this . __uiConfig [ "plusButton" ] ;
90119 } ,
0 commit comments