@@ -147,17 +147,15 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
147147 const toolbar = this . self ( ) . createToolbar ( ) ;
148148 page . addToHeader ( toolbar ) ;
149149
150- if ( this . __resourceData [ "resourceType" ] === "study" ) {
150+ if ( [ "study" , "template" ] . includes ( this . __resourceData [ "resourceType" ] ) ) {
151151 const payDebtButton = new qx . ui . form . Button ( this . tr ( "Credits required" ) ) ;
152152 page . payDebtButton = payDebtButton ;
153153 osparc . dashboard . resources . pages . BasePage . decorateHeaderButton ( payDebtButton ) ;
154154 payDebtButton . addListener ( "execute" , ( ) => this . openBillingSettings ( ) ) ;
155- if ( this . __resourceData [ "resourceType" ] === "study" ) {
156- const studyData = this . __resourceData ;
157- payDebtButton . set ( {
158- visibility : osparc . study . Utils . isInDebt ( studyData ) ? "visible" : "excluded"
159- } ) ;
160- }
155+ const studyData = this . __resourceData ;
156+ payDebtButton . set ( {
157+ visibility : osparc . study . Utils . isInDebt ( studyData ) ? "visible" : "excluded"
158+ } ) ;
161159 toolbar . add ( payDebtButton ) ;
162160 }
163161
@@ -183,10 +181,10 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
183181 } ) ;
184182 openButton . addListener ( "execute" , ( ) => this . __openTapped ( openButton ) ) ;
185183
186- if ( this . __resourceData [ "resourceType" ] === "study" ) {
184+ if ( [ "study" , "template" ] . includes ( this . __resourceData [ "resourceType" ] ) ) {
187185 const studyData = this . __resourceData ;
188- const canBeOpened = osparc . study . Utils . canBeOpened ( studyData ) ;
189- openButton . setEnabled ( canBeOpened ) ;
186+ const enabled = osparc . study . Utils . canBeOpened ( studyData ) ;
187+ openButton . setEnabled ( enabled ) ;
190188 }
191189
192190 toolbar . add ( openButton ) ;
@@ -458,13 +456,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
458456 const lazyLoadContent = ( ) => {
459457 const billingSettings = new osparc . study . BillingSettings ( resourceData ) ;
460458 billingSettings . addListener ( "debtPayed" , ( ) => {
461- if ( resourceData [ "resourceType" ] === "study" ) {
462- page . payDebtButton . set ( {
463- visibility : osparc . study . Utils . isInDebt ( resourceData ) ? "visible" : "excluded"
464- } ) ;
465- const canBeOpened = osparc . study . Utils . canBeOpened ( resourceData ) ;
466- page . openButton . setEnabled ( canBeOpened ) ;
467- }
459+ page . payDebtButton . set ( {
460+ visibility : osparc . study . Utils . isInDebt ( resourceData ) ? "visible" : "excluded"
461+ } ) ;
462+ const enabled = osparc . study . Utils . canBeOpened ( resourceData ) ;
463+ page . openButton . setEnabled ( enabled ) ;
468464 } )
469465 const billingScroll = new qx . ui . container . Scroll ( billingSettings ) ;
470466 page . addToContent ( billingScroll ) ;
@@ -508,11 +504,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
508504 const page = new osparc . dashboard . resources . pages . BasePage ( title , iconSrc , id ) ;
509505 this . __addOpenButton ( page ) ;
510506
511- if ( this . __resourceData [ "resourceType" ] === "study" ) {
512- const studyData = this . __resourceData ;
513- const canBeOpened = osparc . study . Utils . canShowPreview ( studyData ) ;
514- page . setEnabled ( canBeOpened ) ;
515- }
507+ const studyData = this . __resourceData ;
508+ const enabled = osparc . study . Utils . canShowPreview ( studyData ) ;
509+ page . setEnabled ( enabled ) ;
516510
517511 const lazyLoadContent = ( ) => {
518512 const resourceModel = this . __resourceModel ;
@@ -689,11 +683,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
689683 const page = this . __servicesUpdatePage = new osparc . dashboard . resources . pages . BasePage ( title , iconSrc , id ) ;
690684 this . __addOpenButton ( page ) ;
691685
692- if ( this . __resourceData [ "resourceType" ] === "study" ) {
693- const studyData = this . __resourceData ;
694- const canBeOpened = osparc . study . Utils . canShowServiceUpdates ( studyData ) ;
695- page . setEnabled ( canBeOpened ) ;
696- }
686+ const studyData = this . __resourceData ;
687+ const enabled = osparc . study . Utils . canShowServiceUpdates ( studyData ) ;
688+ page . setEnabled ( enabled ) ;
697689
698690 const lazyLoadContent = ( ) => {
699691 const servicesUpdate = new osparc . metadata . ServicesInStudyUpdate ( resourceData ) ;
@@ -723,11 +715,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
723715 const page = new osparc . dashboard . resources . pages . BasePage ( title , iconSrc , id ) ;
724716 this . __addOpenButton ( page ) ;
725717
726- if ( this . __resourceData [ "resourceType" ] === "study" ) {
727- const studyData = this . __resourceData ;
728- const canBeOpened = osparc . study . Utils . canShowServiceBootOptions ( studyData ) ;
729- page . setEnabled ( canBeOpened ) ;
730- }
718+ const studyData = this . __resourceData ;
719+ const enabled = osparc . study . Utils . canShowServiceBootOptions ( studyData ) ;
720+ page . setEnabled ( enabled ) ;
731721
732722 const lazyLoadContent = ( ) => {
733723 const servicesBootOpts = new osparc . metadata . ServicesInStudyBootOpts ( resourceData ) ;
@@ -776,11 +766,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
776766 const title = this . tr ( "Publish" ) ;
777767 const page = new osparc . dashboard . resources . pages . BasePage ( title , iconSrc , id ) ;
778768
779- if ( this . __resourceData [ "resourceType" ] === "study" ) {
780- const studyData = this . __resourceData ;
781- const canBeOpened = osparc . study . Utils . canBeDuplicated ( studyData ) ;
782- page . setEnabled ( canBeOpened ) ;
783- }
769+ const studyData = this . __resourceData ;
770+ const enabled = osparc . study . Utils . canBeDuplicated ( studyData ) ;
771+ page . setEnabled ( enabled ) ;
784772
785773 const lazyLoadContent = ( ) => {
786774 const makeItPublic = true ;
@@ -817,11 +805,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
817805 const title = this . tr ( "Template" ) ;
818806 const page = new osparc . dashboard . resources . pages . BasePage ( title , iconSrc , id ) ;
819807
820- if ( this . __resourceData [ "resourceType" ] === "study" ) {
821- const studyData = this . __resourceData ;
822- const canBeOpened = osparc . study . Utils . canBeDuplicated ( studyData ) ;
823- page . setEnabled ( canBeOpened ) ;
824- }
808+ const studyData = this . __resourceData ;
809+ const enabled = osparc . study . Utils . canBeDuplicated ( studyData ) ;
810+ page . setEnabled ( enabled ) ;
825811
826812 const lazyLoadContent = ( ) => {
827813 const makeItPublic = false ;
0 commit comments