Skip to content

Commit c8d0d33

Browse files
committed
refactor
1 parent e4b3cd4 commit c8d0d33

File tree

1 file changed

+75
-77
lines changed

1 file changed

+75
-77
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -376,42 +376,29 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
376376

377377
if (this.__resourceData["resourceType"] === "function") {
378378
// for now, we only want the preview page
379-
const page = this.__getPreviewPage();
380-
if (page) {
381-
tabsView.add(page);
382-
}
379+
this.__addPreviewPage();
383380
this.fireEvent("pagesAdded");
384381
return;
385382
}
386383

387-
// add Open service button
388-
[
389-
this.__getInfoPage,
390-
this.__getBillingPage,
391-
this.__getServicesUpdatePage,
392-
this.__getServicesBootOptionsPage,
393-
this.__getConversationsPage,
394-
this.__getPermissionsPage,
395-
this.__getPublishPage,
396-
this.__getCreateTemplatePage,
397-
this.__getCreateFunctionsPage,
398-
this.__getTagsPage,
399-
this.__getQualityPage,
400-
this.__getClassifiersPage,
401-
this.__getPreviewPage
402-
].forEach(pageCallee => {
403-
if (pageCallee) {
404-
const page = pageCallee.call(this);
405-
if (page) {
406-
tabsView.add(page);
407-
}
408-
}
409-
});
384+
this.__addInfoPage();
385+
this.__addBillingPage();
386+
this.__addServicesUpdatePage();
387+
this.__addServicesBootOptionsPage();
388+
this.__addConversationsPage();
389+
this.__addPermissionsPage();
390+
this.__addPublishPage();
391+
this.__addCreateTemplatePage();
392+
this.__addCreateFunctionsPage();
393+
this.__addTagsPage();
394+
this.__addQualityPage();
395+
this.__addClassifiersPage();
396+
this.__addPreviewPage();
410397

411398
if (osparc.product.Utils.showComputationalActivity()) {
412-
this.__getActivityOverviewPopUp();
399+
this.__addActivityOverviewPopUp();
413400
}
414-
this.__getProjectFilesPopUp();
401+
this.__addProjectFilesPopUp();
415402

416403
if (selectedTabId) {
417404
const pageFound = tabsView.getChildren().find(page => page.tabId === selectedTabId);
@@ -443,7 +430,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
443430
}
444431
},
445432

446-
__getInfoPage: function() {
433+
__addInfoPage: function() {
447434
const id = "Information";
448435
const title = this.tr("Overview");
449436
const iconSrc = "@FontAwesome5Solid/info/22";
@@ -475,12 +462,13 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
475462
}
476463
page.addListenerOnce("appear", lazyLoadContent, this);
477464

478-
return page;
465+
const tabsView = this.getChildControl("tabs-view");
466+
tabsView.add(page);
479467
},
480468

481-
__getBillingPage: function() {
469+
__addBillingPage: function() {
482470
if (!osparc.desktop.credits.Utils.areWalletsEnabled()) {
483-
return null;
471+
return;
484472
}
485473

486474
const resourceData = this.__resourceData;
@@ -513,7 +501,8 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
513501
}
514502
page.addListenerOnce("appear", lazyLoadContent, this);
515503

516-
return page;
504+
const tabsView = this.getChildControl("tabs-view");
505+
tabsView.add(page);
517506
} else if (osparc.utils.Resources.isService(resourceData)) {
518507
const id = "Tiers";
519508
const title = this.tr("Tiers");
@@ -528,20 +517,20 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
528517
}
529518
page.addListenerOnce("appear", lazyLoadContent, this);
530519

531-
return page;
520+
const tabsView = this.getChildControl("tabs-view");
521+
tabsView.add(page);
532522
}
533-
return null;
534523
},
535524

536-
__getPreviewPage: function() {
525+
__addPreviewPage: function() {
537526
const resourceData = this.__resourceData;
538527
if (
539528
osparc.utils.Resources.isService(resourceData) ||
540529
!osparc.product.Utils.showStudyPreview() ||
541530
["app", "guided", "standalone"].includes(osparc.study.Utils.getUiMode(resourceData))
542531
) {
543532
// there is no pipelining or don't show it
544-
return null;
533+
return;
545534
}
546535

547536
const id = "Pipeline";
@@ -561,13 +550,14 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
561550
}
562551
page.addListenerOnce("appear", lazyLoadContent, this);
563552

564-
return page;
553+
const tabsView = this.getChildControl("tabs-view");
554+
tabsView.add(page);
565555
},
566556

567-
__getConversationsPage: function() {
557+
__addConversationsPage: function() {
568558
const resourceData = this.__resourceData;
569559
if (osparc.utils.Resources.isService(resourceData)) {
570-
return null;
560+
return;
571561
}
572562

573563
const id = "Conversations";
@@ -582,10 +572,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
582572
}
583573
page.addListenerOnce("appear", lazyLoadContent, this);
584574

585-
return page;
575+
const tabsView = this.getChildControl("tabs-view");
576+
tabsView.add(page);
586577
},
587578

588-
__getPermissionsPage: function() {
579+
__addPermissionsPage: function() {
589580
const id = "Permissions";
590581
const title = this.tr("Sharing");
591582
const iconSrc = "@FontAwesome5Solid/share-alt/22";
@@ -619,16 +610,17 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
619610
}
620611
page.addListenerOnce("appear", lazyLoadContent, this);
621612

622-
return page;
613+
const tabsView = this.getChildControl("tabs-view");
614+
tabsView.add(page);
623615
},
624616

625-
__getClassifiersPage: function() {
617+
__addClassifiersPage: function() {
626618
if (!osparc.product.Utils.showClassifiers()) {
627-
return null;
619+
return;
628620
}
629621
const id = "Classifiers";
630622
if (!osparc.data.Permissions.getInstance().canDo("study.classifier")) {
631-
return null;
623+
return;
632624
}
633625
const title = this.tr("Classifiers");
634626
const iconSrc = "@FontAwesome5Solid/search/22";
@@ -654,12 +646,13 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
654646
}
655647
page.addListenerOnce("appear", lazyLoadContent, this);
656648

657-
return page;
649+
const tabsView = this.getChildControl("tabs-view");
650+
tabsView.add(page);
658651
},
659652

660-
__getQualityPage: function() {
653+
__addQualityPage: function() {
661654
if (!osparc.product.Utils.showQuality()) {
662-
return null;
655+
return;
663656
}
664657

665658
const resourceData = this.__resourceData;
@@ -683,18 +676,18 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
683676
}
684677
page.addListenerOnce("appear", lazyLoadContent, this);
685678

686-
return page;
679+
const tabsView = this.getChildControl("tabs-view");
680+
tabsView.add(page);
687681
}
688-
return null;
689682
},
690683

691-
__getTagsPage: function() {
684+
__addTagsPage: function() {
692685
const resourceData = this.__resourceData;
693686
if (osparc.utils.Resources.isService(resourceData)) {
694-
return null;
687+
return;
695688
}
696689
if (!osparc.data.model.Study.canIWrite(resourceData["accessRights"])) {
697-
return null;
690+
return;
698691
}
699692

700693
const id = "Tags";
@@ -714,13 +707,14 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
714707
}
715708
page.addListenerOnce("appear", lazyLoadContent, this);
716709

717-
return page;
710+
const tabsView = this.getChildControl("tabs-view");
711+
tabsView.add(page);
718712
},
719713

720-
__getServicesUpdatePage: function() {
714+
__addServicesUpdatePage: function() {
721715
const resourceData = this.__resourceData;
722716
if (osparc.utils.Resources.isService(resourceData)) {
723-
return null;
717+
return;
724718
}
725719

726720
const id = "ServicesUpdate";
@@ -743,16 +737,17 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
743737
}
744738
page.addListenerOnce("appear", lazyLoadContent, this);
745739

746-
return page;
740+
const tabsView = this.getChildControl("tabs-view");
741+
tabsView.add(page);
747742
},
748743

749-
__getServicesBootOptionsPage: function() {
744+
__addServicesBootOptionsPage: function() {
750745
const resourceData = this.__resourceData;
751746
if (
752747
osparc.utils.Resources.isService(resourceData) ||
753748
!osparc.data.Permissions.getInstance().canDo("study.node.bootOptions.read")
754749
) {
755-
return null;
750+
return;
756751
}
757752

758753
const id = "ServicesBootOptions";
@@ -793,15 +788,16 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
793788
}
794789
page.addListenerOnce("appear", lazyLoadContent, this);
795790

796-
return page;
791+
const tabsView = this.getChildControl("tabs-view");
792+
tabsView.add(page);
797793
},
798794

799-
__getPublishPage: function() {
795+
__addPublishPage: function() {
800796
if (
801797
!osparc.utils.Resources.isStudy(this.__resourceData) ||
802798
!osparc.product.Utils.showPublicProjects()
803799
) {
804-
return null;
800+
return;
805801
}
806802

807803
const canIWrite = osparc.data.model.Study.canIWrite(this.__resourceData["accessRights"]);
@@ -830,17 +826,17 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
830826
}
831827
page.addListenerOnce("appear", lazyLoadContent, this);
832828

833-
return page;
829+
const tabsView = this.getChildControl("tabs-view");
830+
tabsView.add(page);
834831
}
835-
return null;
836832
},
837833

838-
__getCreateTemplatePage: function() {
834+
__addCreateTemplatePage: function() {
839835
if (
840836
!osparc.utils.Resources.isStudy(this.__resourceData) ||
841837
!osparc.product.Utils.showTemplates()
842838
) {
843-
return null;
839+
return;
844840
}
845841

846842
const canIWrite = osparc.data.model.Study.canIWrite(this.__resourceData["accessRights"]);
@@ -869,22 +865,22 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
869865
}
870866
page.addListenerOnce("appear", lazyLoadContent, this);
871867

872-
return page;
868+
const tabsView = this.getChildControl("tabs-view");
869+
tabsView.add(page);
873870
}
874-
return null;
875871
},
876872

877-
__getCreateFunctionsPage: function() {
873+
__addCreateFunctionsPage: function() {
878874
if (!osparc.data.Permissions.getInstance().checkFunctionPermissions("writeFunctions")) {
879-
return null;
875+
return;
880876
}
881877

882878
if (!osparc.utils.Resources.isStudy(this.__resourceData)) {
883-
return null;
879+
return;
884880
}
885881

886882
if (!osparc.study.Utils.canCreateFunction(this.__resourceData["workbench"])) {
887-
return null;
883+
return;
888884
}
889885

890886
const id = "CreateFunction";
@@ -898,10 +894,12 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
898894
toolbar.add(createFunctionButton);
899895
page.addToHeader(toolbar);
900896
page.addToContent(createFunction);
901-
return page;
897+
898+
const tabsView = this.getChildControl("tabs-view");
899+
tabsView.add(page);
902900
},
903901

904-
__getProjectFilesPopUp: function() {
902+
__addProjectFilesPopUp: function() {
905903
const resourceData = this.__resourceData;
906904
if (!osparc.utils.Resources.isService(resourceData)) {
907905
const title = osparc.product.Utils.resourceTypeToAlias(resourceData["resourceType"], {firstUpperCase: true}) + this.tr(" Files");
@@ -925,7 +923,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
925923
}
926924
},
927925

928-
__getActivityOverviewPopUp: function() {
926+
__addActivityOverviewPopUp: function() {
929927
const resourceData = this.__resourceData;
930928
if (osparc.utils.Resources.isStudy(resourceData)) {
931929
const title = this.tr("Activity Overview...");

0 commit comments

Comments
 (0)