Skip to content

Commit b0b4013

Browse files
authored
✨ [Frontend] Workspaces (#6283)
1 parent 22ff9da commit b0b4013

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1716
-288
lines changed

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

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*/
2222

23-
qx.Class.define("osparc.dashboard.FolderHeader", {
23+
qx.Class.define("osparc.dashboard.ContainerHeader", {
2424
extend: qx.ui.core.Widget,
2525

2626
construct: function() {
@@ -31,17 +31,21 @@ qx.Class.define("osparc.dashboard.FolderHeader", {
3131
}));
3232
},
3333

34-
events: {
35-
"changeCurrentFolderId": "qx.event.type.Data"
36-
},
37-
3834
properties: {
35+
currentWorkspaceId: {
36+
check: "Number",
37+
nullable: true,
38+
init: null,
39+
event: "changeCurrentWorkspaceId",
40+
apply: "__buildBreadcrumbs"
41+
},
42+
3943
currentFolderId: {
4044
check: "Number",
4145
nullable: true,
4246
init: null,
4347
event: "changeCurrentFolderId",
44-
apply: "__applyCurrentFolderId"
48+
apply: "__buildBreadcrumbs"
4549
}
4650
},
4751

@@ -55,24 +59,10 @@ qx.Class.define("osparc.dashboard.FolderHeader", {
5559
}));
5660
this._addAt(control, 0, {flex: 1});
5761
break;
58-
case "permissions-info": {
59-
control = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({
60-
alignY: "middle"
61-
})).set({
62-
paddingRight: 14
63-
});
64-
this._addAt(control, 1);
65-
break;
66-
}
6762
}
6863
return control || this.base(arguments, id);
6964
},
7065

71-
__applyCurrentFolderId: function() {
72-
this.__buildBreadcrumbs();
73-
this.__populatePermissions();
74-
},
75-
7666
__buildBreadcrumbs: function() {
7767
const breadcrumbsLayout = this.getChildControl("breadcrumbs-layout");
7868
breadcrumbsLayout.removeAll();
@@ -110,14 +100,38 @@ qx.Class.define("osparc.dashboard.FolderHeader", {
110100
return this.__createFolderButton(currentFolder);
111101
},
112102

103+
__createRootButton: function(workspaceId) {
104+
let rootButton = null;
105+
if (workspaceId) {
106+
if (workspaceId === -1) {
107+
rootButton = new qx.ui.form.Button(this.tr("Shared Workspaces"), osparc.store.Workspaces.iconPath());
108+
} else {
109+
const workspace = osparc.store.Workspaces.getWorkspace(workspaceId);
110+
rootButton = new qx.ui.form.Button(workspace.getName(), osparc.store.Workspaces.iconPath());
111+
}
112+
rootButton.addListener("execute", () => this.set({
113+
currentWorkspaceId: workspaceId,
114+
currentFolderId: null,
115+
}));
116+
} else {
117+
rootButton = new qx.ui.form.Button(this.tr("My Workspace"), "@FontAwesome5Solid/home/14");
118+
rootButton.addListener("execute", () => this.set({
119+
currentWorkspaceId: null,
120+
currentFolderId: null,
121+
}));
122+
}
123+
return rootButton;
124+
},
125+
113126
__createFolderButton: function(folder) {
114127
let folderButton = null;
115128
if (folder) {
116129
folderButton = new qx.ui.form.Button(folder.getName(), "@FontAwesome5Solid/folder/14");
130+
folderButton.addListener("execute", () => this.fireDataEvent("changeCurrentFolderId", folder ? folder.getFolderId() : null), this);
117131
} else {
118-
folderButton = new qx.ui.form.Button(this.tr("Home"), "@FontAwesome5Solid/home/14");
132+
const workspaceId = this.getCurrentWorkspaceId();
133+
folderButton = this.__createRootButton(workspaceId);
119134
}
120-
folderButton.addListener("execute", () => this.fireDataEvent("changeCurrentFolderId", folder ? folder.getFolderId() : null), this);
121135
folderButton.set({
122136
backgroundColor: "transparent",
123137
textColor: "text",
@@ -128,22 +142,6 @@ qx.Class.define("osparc.dashboard.FolderHeader", {
128142

129143
__createArrow: function() {
130144
return new qx.ui.basic.Label("/");
131-
},
132-
133-
__populatePermissions: function() {
134-
const permissionsLayout = this.getChildControl("permissions-info");
135-
permissionsLayout.removeAll();
136-
137-
if (this.getCurrentFolderId()) {
138-
const currentFolder = osparc.store.Folders.getInstance().getFolder(this.getCurrentFolderId());
139-
const ar = currentFolder.getMyAccessRights();
140-
const permissions = ar["read"] + ar["write"] + ar["delete"];
141-
const roleTitle = new qx.ui.basic.Label().set({
142-
value: osparc.data.Roles.FOLDERS[permissions].label
143-
});
144-
permissionsLayout.add(roleTitle);
145-
permissionsLayout.add(osparc.data.Roles.createRolesFolderInfo(false));
146-
}
147145
}
148146
}
149147
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ qx.Class.define("osparc.dashboard.Dashboard", {
167167
const preResourcePromises = [];
168168
const store = osparc.store.Store.getInstance();
169169
preResourcePromises.push(store.getAllGroupsAndMembers());
170-
preResourcePromises.push(osparc.service.Store.getServicesLatest(false));
170+
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
171171
if (permissions.canDo("study.tag")) {
172172
preResourcePromises.push(osparc.data.Resources.get("tags"));
173173
}

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

Lines changed: 44 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
7979
apply: "__applyDescription"
8080
},
8181

82-
myAccessRights: {
83-
check: "Object",
84-
nullable: true,
85-
apply: "__applyMyAccessRights"
86-
},
87-
88-
accessRights: {
89-
check: "Object",
90-
nullable: true,
91-
apply: "__applyAccessRights"
92-
},
93-
9482
lastModified: {
9583
check: "Date",
9684
nullable: true,
@@ -103,7 +91,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
10391
let control;
10492
switch (id) {
10593
case "icon": {
106-
control = new osparc.dashboard.FolderWithSharedIcon().set({
94+
control = new qx.ui.basic.Image().set({
95+
source: "@FontAwesome5Solid/folder/26",
10796
anonymous: true,
10897
height: 40,
10998
padding: 5
@@ -155,9 +144,9 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
155144
folder.bind("parentId", this, "parentFolderId");
156145
folder.bind("name", this, "title");
157146
folder.bind("description", this, "description");
158-
folder.bind("accessRights", this, "accessRights");
159147
folder.bind("lastModified", this, "lastModified");
160-
folder.bind("myAccessRights", this, "myAccessRights");
148+
149+
this.__addMenuButton();
161150
},
162151

163152
__applyTitle: function(value) {
@@ -177,73 +166,51 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
177166
}
178167
},
179168

180-
__applyMyAccessRights: function(value) {
181-
if (value && value["delete"]) {
182-
const menuButton = this.getChildControl("menu-button");
183-
menuButton.setVisibility("visible");
169+
__addMenuButton: function() {
170+
const menuButton = this.getChildControl("menu-button");
171+
menuButton.setVisibility("visible");
184172

185-
const menu = new qx.ui.menu.Menu().set({
186-
position: "bottom-right"
187-
});
173+
const menu = new qx.ui.menu.Menu().set({
174+
position: "bottom-right"
175+
});
188176

189-
const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12");
190-
editButton.addListener("execute", () => {
191-
const folder = this.getFolder();
192-
const newFolder = false;
193-
const folderEditor = new osparc.editor.FolderEditor(newFolder).set({
194-
label: folder.getName(),
195-
description: folder.getDescription()
196-
});
197-
const title = this.tr("Edit Folder");
198-
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 200);
199-
folderEditor.addListener("updateFolder", () => {
200-
const newName = folderEditor.getLabel();
201-
const newDescription = folderEditor.getDescription();
202-
const updateData = {
203-
"name": newName,
204-
"description": newDescription
205-
};
206-
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
207-
.then(() => {
208-
folder.set({
209-
name: newName,
210-
description: newDescription
211-
});
212-
this.fireDataEvent("folderUpdated", folder.getFolderId());
213-
})
214-
.catch(err => console.error(err));
215-
win.close();
216-
});
217-
folderEditor.addListener("cancel", () => win.close());
177+
const editButton = new qx.ui.menu.Button(this.tr("Rename..."), "@FontAwesome5Solid/pencil-alt/12");
178+
editButton.addListener("execute", () => {
179+
const folder = this.getFolder();
180+
const newFolder = false;
181+
const folderEditor = new osparc.editor.FolderEditor(newFolder).set({
182+
label: folder.getName(),
183+
description: folder.getDescription()
218184
});
219-
menu.add(editButton);
220-
221-
const shareButton = new qx.ui.menu.Button(this.tr("Share..."), "@FontAwesome5Solid/share-alt/12");
222-
shareButton.addListener("execute", () => this.__openShareWith(), this);
223-
menu.add(shareButton);
224-
225-
menu.addSeparator();
226-
227-
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
228-
deleteButton.addListener("execute", () => this.__deleteStudyRequested(), this);
229-
menu.add(deleteButton);
185+
const title = this.tr("Edit Folder");
186+
const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 200);
187+
folderEditor.addListener("updateFolder", () => {
188+
const newName = folderEditor.getLabel();
189+
const newDescription = folderEditor.getDescription();
190+
const updateData = {
191+
"name": newName,
192+
"description": newDescription
193+
};
194+
osparc.data.model.Folder.putFolder(this.getFolderId(), updateData)
195+
.then(() => {
196+
folder.set({
197+
name: newName,
198+
description: newDescription
199+
});
200+
this.fireDataEvent("folderUpdated", folder.getFolderId());
201+
})
202+
.catch(err => console.error(err));
203+
win.close();
204+
});
205+
folderEditor.addListener("cancel", () => win.close());
206+
});
207+
menu.add(editButton);
230208

231-
menuButton.setMenu(menu);
232-
}
233-
},
209+
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
210+
deleteButton.addListener("execute", () => this.__deleteStudyRequested(), this);
211+
menu.add(deleteButton);
234212

235-
__applyAccessRights: function(value) {
236-
if (value && Object.keys(value).length) {
237-
const shareIcon = this.getChildControl("icon").getChildControl("shared-icon");
238-
// if it's not shared don't show the share icon
239-
shareIcon.addListener("changeSource", e => {
240-
const newSource = e.getData();
241-
shareIcon.set({
242-
visibility: newSource.includes(osparc.dashboard.CardBase.SHARE_ICON) ? "hidden" : "visible"
243-
});
244-
});
245-
osparc.dashboard.CardBase.populateShareIcon(shareIcon, value);
246-
}
213+
menuButton.setMenu(menu);
247214
},
248215

249216
__updateTooltip: function() {
@@ -260,18 +227,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
260227
this.setValue(false);
261228
},
262229

263-
__openShareWith: function() {
264-
const disableShare = true;
265-
if (disableShare) {
266-
osparc.FlashMessenger.getInstance().logAs(this.tr("Not yet implemented"), "WARNING");
267-
} else {
268-
const title = this.tr("Share Folder");
269-
const permissionsView = new osparc.share.CollaboratorsFolder(this.getFolder());
270-
osparc.ui.window.Window.popUpInWindow(permissionsView, title);
271-
permissionsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getFolder().getAccessRights()), this);
272-
}
273-
},
274-
275230
__deleteStudyRequested: function() {
276231
const msg = this.tr("Are you sure you want to delete") + " <b>" + this.getTitle() + "</b>?";
277232
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({

0 commit comments

Comments
 (0)