Skip to content

Commit ed97990

Browse files
authored
🎨 [Frontend] Workspaces: Prettify tree I (#6349)
1 parent fbdfe63 commit ed97990

File tree

14 files changed

+221
-198
lines changed

14 files changed

+221
-198
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
784784
if (moveToFolderButton) {
785785
moveToFolderButton.setEnabled(osparc.study.Utils.canMoveToFolder(resourceData));
786786
}
787+
const moveToWorkspaceButton = menuButtons.find(menuBtn => "moveToWorkspaceButton" in menuBtn);
788+
if (moveToWorkspaceButton) {
789+
moveToWorkspaceButton.setEnabled(osparc.study.Utils.canMoveToWorkspace(resourceData));
790+
}
787791
const deleteButton = menuButtons.find(menuBtn => "deleteButton" in menuBtn);
788792
if (deleteButton) {
789793
deleteButton.setEnabled(osparc.study.Utils.canBeDeleted(resourceData));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ qx.Class.define("osparc.dashboard.ContainerHeader", {
8181
__createUpstreamButtons: function(childFolder) {
8282
if (childFolder) {
8383
const breadcrumbsLayout = this.getChildControl("breadcrumbs-layout");
84-
const parentFolder = osparc.store.Folders.getInstance().getFolder(childFolder.getParentId());
84+
const parentFolder = osparc.store.Folders.getInstance().getFolder(childFolder.getParentFolderId());
8585
if (parentFolder) {
8686
breadcrumbsLayout.addAt(this.__createArrow(), 0);
8787
const upstreamButton = this.__createFolderButton(parentFolder);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
143143
});
144144
folder.bind("workspaceId", this, "workspaceId");
145145
folder.bind("folderId", this, "folderId");
146-
folder.bind("parentId", this, "parentFolderId");
146+
folder.bind("parentFolderId", this, "parentFolderId");
147147
folder.bind("name", this, "title");
148148
folder.bind("lastModified", this, "lastModified");
149149

@@ -227,7 +227,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
227227
const updateData = {
228228
"name": newName,
229229
};
230-
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
230+
osparc.store.Folders.getInstance().putFolder(this.getFolderId(), updateData)
231231
.then(() => {
232232
folder.set({
233233
name: newName,

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,13 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
374374

375375
if (this._resourceType === "study") {
376376
const workspacesAndFoldersTree = resourceFilter.getWorkspacesAndFoldersTree();
377-
workspacesAndFoldersTree.bind("currentWorkspaceId", this, "currentWorkspaceId");
378-
workspacesAndFoldersTree.bind("currentFolderId", this, "currentFolderId");
377+
workspacesAndFoldersTree.addListener("changeContext", e => {
378+
const {
379+
workspaceId,
380+
folderId,
381+
} = e.getData();
382+
this._changeContext(workspaceId, folderId);
383+
});
379384
this.bind("currentWorkspaceId", workspacesAndFoldersTree, "currentWorkspaceId");
380385
this.bind("currentFolderId", workspacesAndFoldersTree, "currentFolderId");
381386
}
@@ -478,6 +483,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
478483
throw new Error("Abstract method called!");
479484
},
480485

486+
_changeContext: function(workspaceId, folderId) {
487+
throw new Error("Abstract method called!");
488+
},
489+
481490
_folderSelected: function(folderId) {
482491
throw new Error("Abstract method called!");
483492
},

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
6868

6969
__createWorkspacesAndFoldersTree: function() {
7070
const workspacesAndFoldersTree = this.__workspacesAndFoldersTree = new osparc.dashboard.WorkspacesAndFoldersTree();
71-
// play with the height of:
72-
// osparc.dashboard.WorkspacesAndFoldersTree
73-
// Pane
74-
// 1st child
71+
// Height needs to be calculated manually to make it flexible
72+
workspacesAndFoldersTree.set({
73+
minHeight: 100,
74+
maxHeight: 400,
75+
height: 100,
76+
});
77+
workspacesAndFoldersTree.addListener("openChanged", () => {
78+
const rowConfig = workspacesAndFoldersTree.getPane().getRowConfig();
79+
const totalHeight = rowConfig.itemCount * rowConfig.defaultItemSize;
80+
workspacesAndFoldersTree.setHeight(totalHeight + 10);
81+
});
7582
return workspacesAndFoldersTree;
7683
},
7784

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

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
5353
check: "Number",
5454
nullable: true,
5555
init: null,
56-
event: "changeCurrentWorkspaceId",
57-
apply: "__applyCurrentWorkspaceId"
56+
event: "changeCurrentWorkspaceId"
5857
},
5958

6059
currentFolderId: {
6160
check: "Number",
6261
nullable: true,
6362
init: null,
64-
event: "changeCurrentFolderId",
65-
apply: "__resetAndReloadAll"
63+
event: "changeCurrentFolderId"
6664
},
6765

6866
multiSelection: {
@@ -105,7 +103,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
105103
__currentRequest: null,
106104
__workspacesList: null,
107105
__foldersList: null,
108-
__reloadFoldersAndStudiesTimeout: null,
109106

110107
// overridden
111108
initResources: function() {
@@ -121,6 +118,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
121118
const isStudyCreation = false;
122119
this._startStudyById(loadStudyId, null, cancelCB, isStudyCreation);
123120
} else {
121+
this.__reloadFolders();
124122
this.reloadResources();
125123
}
126124
// "Starting..." page
@@ -400,18 +398,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
400398
osparc.filter.UIFilterController.dispatch("searchBarFilter");
401399
},
402400

403-
__applyCurrentWorkspaceId: function(workspaceId) {
404-
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
405-
if (workspaceId === -1) {
406-
this._resourcesContainer.setResourcesToList([]);
407-
this._resourcesList = [];
408-
this.__reloadWorkspaces();
409-
} else {
410-
this.__resetAndReloadAll();
411-
}
412-
}
413-
},
414-
415401
// WORKSPACES
416402
__reloadWorkspaceCards: function() {
417403
this._resourcesContainer.setWorkspacesToList(this.__workspacesList);
@@ -450,26 +436,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
450436
},
451437
// /WORKSPACES
452438

453-
__resetAndReloadAll: function() {
439+
_changeContext: function(workspaceId, folderId) {
454440
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
455-
const workspaceId = this.getCurrentWorkspaceId();
456-
if (workspaceId === -1) {
457-
return;
458-
}
459-
441+
this.set({
442+
currentWorkspaceId: workspaceId,
443+
currentFolderId: folderId,
444+
});
460445
this._resourcesContainer.setResourcesToList([]);
461446
this._resourcesList = [];
462-
this.invalidateStudies();
463447

464-
// It can be triggered by a change of context: workspace and folder,
465-
// delay it to make just one call
466-
if (this.__reloadFoldersAndStudiesTimeout) {
467-
clearTimeout(this.__reloadFoldersAndStudiesTimeout);
468-
}
469-
this.__reloadFoldersAndStudiesTimeout = setTimeout(() => {
470-
this.__reloadFoldersAndStudiesTimeout = null;
448+
if (workspaceId === -1) {
449+
this.__reloadWorkspaces();
450+
} else {
451+
this.invalidateStudies();
471452
this.__reloadFoldersAndStudies();
472-
}, 50);
453+
}
473454
}
474455
},
475456

@@ -502,6 +483,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
502483

503484
_folderSelected: function(folderId) {
504485
this.setCurrentFolderId(folderId);
486+
this._changeContext(this.getCurrentWorkspaceId(), folderId);
505487
},
506488

507489
_folderUpdated: function() {
@@ -543,6 +525,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
543525
},
544526

545527
_moveFolderToWorkspaceRequested: function(folderId) {
528+
const folderToWorkspaceRequested = false;
529+
if (!folderToWorkspaceRequested) {
530+
const msg = this.tr("Coming soon");
531+
osparc.FlashMessenger.getInstance().logAs(msg, "WARNING");
532+
return;
533+
}
546534
const moveFolderToWorkspace = new osparc.dashboard.MoveResourceToWorkspace(this.getCurrentWorkspaceId());
547535
const title = "Move to Workspace";
548536
const win = osparc.ui.window.Window.popUpInWindow(moveFolderToWorkspace, title, 350, 280);
@@ -573,7 +561,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
573561
},
574562

575563
_deleteFolderRequested: function(folderId) {
576-
osparc.store.Folders.getInstance().deleteFolder(folderId)
564+
osparc.store.Folders.getInstance().deleteFolder(folderId, this.getCurrentWorkspaceId())
577565
.then(() => this.__reloadFolders())
578566
.catch(err => console.error(err));
579567
},
@@ -882,7 +870,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
882870
onUpdate: () => containerHeader.setCurrentFolderId(null)
883871
});
884872
this.bind("currentFolderId", containerHeader, "currentFolderId");
885-
containerHeader.bind("currentFolderId", this, "currentFolderId");
873+
containerHeader.bind("currentFolderId", this, "currentFolderId", {
874+
onUpdate: () => this._changeContext(this.getCurrentWorkspaceId(), this.getCurrentFolderId())
875+
});
886876
}
887877
const list = this._resourcesContainer.getFlatList();
888878
if (list) {

0 commit comments

Comments
 (0)