Skip to content

Commit 2af7f21

Browse files
authored
🎨 [Frontend] UX: New Workspace and New Organization (#6699)
1 parent ce9d3a5 commit 2af7f21

16 files changed

+231
-164
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
116116
};
117117
osparc.data.Resources.fetch("studies", "getWallet", params)
118118
.then(wallet => {
119-
if (isStudyCreation || wallet === null || osparc.desktop.credits.Utils.getWallet(wallet["walletId"]) === null) {
119+
if (
120+
isStudyCreation ||
121+
wallet === null ||
122+
osparc.desktop.credits.Utils.getWallet(wallet["walletId"]) === null
123+
) {
120124
// pop up study options if the study was just created or if it has no wallet assigned or user has no access to it
121125
const resourceSelector = new osparc.study.StudyOptions(studyId);
122126
const win = osparc.study.StudyOptions.popUpInWindow(resourceSelector);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
364364
const resourceData = this.__resourceData;
365365
if (osparc.utils.Resources.isStudy(resourceData)) {
366366
const id = "Billing";
367-
const title = this.tr("Billing Settings");
367+
const title = this.tr("Tier Settings");
368368
const iconSrc = "@FontAwesome5Solid/cogs/22";
369369
const page = this.__billingSettings = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
370370
this.__addOpenButton(page);

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
374374
newWorkspaceCard.setCardKey("new-workspace");
375375
newWorkspaceCard.subscribeToFilterGroup("searchBarFilter");
376376
[
377-
"createWorkspace",
378-
"updateWorkspace"
377+
"workspaceCreated",
378+
"workspaceDeleted",
379+
"workspaceUpdated",
379380
].forEach(e => {
380-
newWorkspaceCard.addListener(e, () => {
381-
this.__reloadWorkspaces();
382-
});
381+
newWorkspaceCard.addListener(e, () => this.__reloadWorkspaces());
383382
});
384383
this._resourcesContainer.addNewWorkspaceCard(newWorkspaceCard);
385384
},
@@ -1170,7 +1169,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
11701169
__newStudyBtnClicked: function(button) {
11711170
button.setValue(false);
11721171
const minStudyData = osparc.data.model.Study.createMinStudyObject();
1173-
const title = osparc.utils.Utils.getUniqueStudyName(minStudyData.name, this._resourcesList);
1172+
const existingNames = this._resourcesList.map(study => study["name"]);
1173+
const title = osparc.utils.Utils.getUniqueName(minStudyData.name, existingNames);
11741174
minStudyData["name"] = title;
11751175
minStudyData["workspaceId"] = this.getCurrentWorkspaceId();
11761176
minStudyData["folderId"] = this.getCurrentFolderId();
@@ -1190,7 +1190,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
11901190
__newPlanBtnClicked: function(templateData, newStudyName) {
11911191
// do not override cached template data
11921192
const templateCopyData = osparc.utils.Utils.deepCloneObject(templateData);
1193-
const title = osparc.utils.Utils.getUniqueStudyName(newStudyName, this._resourcesList);
1193+
const existingNames = this._resourcesList.map(study => study["name"]);
1194+
const title = osparc.utils.Utils.getUniqueName(newStudyName, existingNames);
11941195
templateCopyData.name = title;
11951196
this._showLoadingPage(this.tr("Creating ") + (newStudyName || osparc.product.Utils.getStudyAlias()));
11961197
const contextProps = {
@@ -1411,7 +1412,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
14111412
},
14121413

14131414
__getBillingMenuButton: function(card) {
1414-
const text = osparc.utils.Utils.capitalize(this.tr("Billing Settings..."));
1415+
const text = osparc.utils.Utils.capitalize(this.tr("Tier Settings..."));
14151416
const studyBillingSettingsButton = new qx.ui.menu.Button(text);
14161417
studyBillingSettingsButton["billingSettingsButton"] = true;
14171418
studyBillingSettingsButton.addListener("tap", () => card.openBilling(), this);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
339339

340340
__editWorkspace: function() {
341341
const workspace = osparc.store.Workspaces.getInstance().getWorkspace(this.getCurrentWorkspaceId());
342-
const permissionsView = new osparc.editor.WorkspaceEditor(workspace);
342+
const workspaceEditor = new osparc.editor.WorkspaceEditor(workspace);
343343
const title = this.tr("Edit Workspace");
344-
const win = osparc.ui.window.Window.popUpInWindow(permissionsView, title, 300, 200);
345-
permissionsView.addListener("workspaceUpdated", () => {
344+
const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 300, 150);
345+
workspaceEditor.addListener("workspaceUpdated", () => {
346346
win.close();
347347
this.__buildLayout();
348348
}, this);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
185185
const workspace = this.getWorkspace();
186186
const workspaceEditor = new osparc.editor.WorkspaceEditor(workspace);
187187
const title = this.tr("Edit Workspace");
188-
const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 300, 200);
188+
const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 300, 150);
189189
workspaceEditor.addListener("workspaceUpdated", () => {
190190
win.close();
191191
this.fireDataEvent("workspaceUpdated", workspace.getWorkspaceId());

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,29 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", {
4646
},
4747

4848
events: {
49-
"createWorkspace": "qx.event.type.Data",
50-
"updateWorkspace": "qx.event.type.Data"
49+
"workspaceCreated": "qx.event.type.Event",
50+
"workspaceDeleted": "qx.event.type.Event",
51+
"workspaceUpdated": "qx.event.type.Event",
5152
},
5253

5354
members: {
5455
__itemSelected: function(newVal) {
5556
if (newVal) {
56-
const workspaceCreator = new osparc.editor.WorkspaceEditor();
57+
const workspaceEditor = new osparc.editor.WorkspaceEditor();
5758
const title = this.tr("New Workspace");
58-
const win = osparc.ui.window.Window.popUpInWindow(workspaceCreator, title, 300, 200);
59-
workspaceCreator.addListener("workspaceCreated", e => {
60-
win.close();
61-
const newWorkspace = e.getData();
62-
this.fireDataEvent("createWorkspace", newWorkspace.getWorkspaceId(), this);
63-
const permissionsView = new osparc.share.CollaboratorsWorkspace(newWorkspace);
64-
const title2 = qx.locale.Manager.tr("Share Workspace");
65-
osparc.ui.window.Window.popUpInWindow(permissionsView, title2, 500, 500);
66-
permissionsView.addListener("updateAccessRights", () => this.fireDataEvent("updateWorkspace", newWorkspace.getWorkspaceId()), this);
59+
const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 500, 500).set({
60+
modal: true,
61+
clickAwayClose: false,
6762
});
68-
workspaceCreator.addListener("cancel", () => win.close());
63+
workspaceEditor.addListener("workspaceCreated", () => this.fireEvent("workspaceCreated"));
64+
workspaceEditor.addListener("workspaceDeleted", () => this.fireEvent("workspaceDeleted"));
65+
workspaceEditor.addListener("workspaceUpdated", () => {
66+
win.close();
67+
this.fireEvent("workspaceUpdated");
68+
}, this);
69+
workspaceEditor.addListener("updateAccessRights", () => this.fireEvent("workspaceUpdated"));
70+
win.getChildControl("close-button").addListener("tap", () => workspaceEditor.cancel());
71+
workspaceEditor.addListener("cancel", () => win.close());
6972
}
7073
this.setValue(false);
7174
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
300300
if (oldParentFolderId === undefined) {
301301
// it was removed, not moved
302302
// remove it from the cached models
303-
const modelFound = this.__getModel(folder.getWorkspaceId(), folder.getParentFolderId());
303+
const modelFound = this.__getModel(folder.getWorkspaceId(), folder.getFolderId());
304304
if (modelFound) {
305305
const index = this.__models.indexOf(modelFound);
306306
if (index > -1) { // only splice array when item is found

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,9 @@ qx.Class.define("osparc.desktop.organizations.OrganizationDetails", {
9494

9595
__openEditOrganization: function() {
9696
const org = this.__orgModel;
97-
98-
const newOrg = false;
99-
const orgEditor = new osparc.editor.OrganizationEditor(newOrg);
100-
org.bind("gid", orgEditor, "gid");
101-
org.bind("label", orgEditor, "label");
102-
org.bind("description", orgEditor, "description");
103-
org.bind("thumbnail", orgEditor, "thumbnail", {
104-
converter: val => val ? val : ""
105-
});
10697
const title = this.tr("Organization Details Editor");
107-
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 250);
98+
const orgEditor = new osparc.editor.OrganizationEditor(org);
99+
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 200);
108100
orgEditor.addListener("updateOrg", () => {
109101
this.__updateOrganization(win, orgEditor.getChildControl("save"), orgEditor);
110102
});

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
9999
allowGrowX: false
100100
});
101101
createOrgBtn.addListener("execute", function() {
102-
const newOrg = true;
103-
const orgEditor = new osparc.editor.OrganizationEditor(newOrg);
104102
const title = this.tr("New Organization");
105-
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 250);
103+
const orgEditor = new osparc.editor.OrganizationEditor();
104+
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 200);
106105
orgEditor.addListener("createOrg", () => {
107106
this.__createOrganization(win, orgEditor.getChildControl("create"), orgEditor);
108107
});
@@ -176,7 +175,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
176175
}
177176
},
178177

179-
reloadOrganizations: function() {
178+
reloadOrganizations: function(orgId) {
180179
this.__orgsUIList.resetSelection();
181180
const orgsModel = this.__orgsModel;
182181
orgsModel.removeAll();
@@ -199,6 +198,9 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
199198
orgsList.sort(this.self().sortOrganizations);
200199
orgsList.forEach(org => orgsModel.append(qx.data.marshal.Json.createModel(org)));
201200
this.setOrganizationsLoaded(true);
201+
if (orgId) {
202+
this.fireDataEvent("organizationSelected", orgId);
203+
}
202204
});
203205
},
204206

@@ -208,16 +210,9 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
208210
return;
209211
}
210212

211-
const newOrg = false;
212-
const orgEditor = new osparc.editor.OrganizationEditor(newOrg);
213-
org.bind("gid", orgEditor, "gid");
214-
org.bind("label", orgEditor, "label");
215-
org.bind("description", orgEditor, "description");
216-
org.bind("thumbnail", orgEditor, "thumbnail", {
217-
converter: val => val ? val : ""
218-
});
219213
const title = this.tr("Organization Details Editor");
220-
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 250);
214+
const orgEditor = new osparc.editor.OrganizationEditor(org);
215+
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 200);
221216
orgEditor.addListener("updateOrg", () => {
222217
this.__updateOrganization(win, orgEditor.getChildControl("save"), orgEditor);
223218
});
@@ -287,14 +282,15 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
287282
}
288283
};
289284
osparc.data.Resources.fetch("organizations", "post", params)
290-
.then(() => {
285+
.then(org => {
291286
osparc.FlashMessenger.getInstance().logAs(name + this.tr(" successfully created"));
292287
button.setFetching(false);
293288
osparc.store.Store.getInstance().reset("organizations");
294289
// reload "profile", "organizations" are part of the information in this endpoint
295290
osparc.data.Resources.getOne("profile", {}, null, false)
296291
.then(() => {
297-
this.reloadOrganizations();
292+
// open it
293+
this.reloadOrganizations(org["gid"]);
298294
});
299295
})
300296
.catch(err => {

services/static-webserver/client/source/class/osparc/editor/OrganizationEditor.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
qx.Class.define("osparc.editor.OrganizationEditor", {
1919
extend: qx.ui.core.Widget,
2020

21-
construct: function(newOrg = true) {
21+
construct: function(organization) {
2222
this.base(arguments);
2323

2424
this._setLayout(new qx.ui.layout.VBox(8));
@@ -29,7 +29,27 @@ qx.Class.define("osparc.editor.OrganizationEditor", {
2929
manager.add(title);
3030
this.getChildControl("description");
3131
this.getChildControl("thumbnail");
32-
newOrg ? this.getChildControl("create") : this.getChildControl("save");
32+
organization ? this.getChildControl("save") : this.getChildControl("create");
33+
34+
if (organization) {
35+
organization.bind("gid", this, "gid");
36+
organization.bind("label", this, "label");
37+
organization.bind("description", this, "description");
38+
organization.bind("thumbnail", this, "thumbnail", {
39+
converter: val => val ? val : ""
40+
});
41+
} else {
42+
osparc.store.Store.getInstance().getGroupsOrganizations()
43+
.then(orgs => {
44+
const existingNames = orgs.map(org => org["label"]);
45+
const defaultName = osparc.utils.Utils.getUniqueName("New Organization", existingNames)
46+
title.setValue(defaultName);
47+
})
48+
.catch(err => {
49+
console.error(err);
50+
title.setValue("New Organization");
51+
});
52+
}
3353

3454
this.addListener("appear", () => {
3555
title.focus();
@@ -82,20 +102,18 @@ qx.Class.define("osparc.editor.OrganizationEditor", {
82102
font: "text-14",
83103
backgroundColor: "background-main",
84104
placeholder: this.tr("Title"),
85-
height: 35
105+
height: 30,
86106
});
87107
this.bind("label", control, "value");
88108
control.bind("value", this, "label");
89109
this._add(control);
90110
break;
91111
}
92112
case "description": {
93-
control = new qx.ui.form.TextArea().set({
113+
control = new qx.ui.form.TextField().set({
94114
font: "text-14",
95115
placeholder: this.tr("Description"),
96-
autoSize: true,
97-
minHeight: 70,
98-
maxHeight: 140
116+
height: 30,
99117
});
100118
this.bind("description", control, "value");
101119
control.bind("value", this, "description");
@@ -106,7 +124,7 @@ qx.Class.define("osparc.editor.OrganizationEditor", {
106124
control = new qx.ui.form.TextField().set({
107125
font: "text-14",
108126
placeholder: this.tr("Thumbnail"),
109-
height: 35
127+
height: 30,
110128
});
111129
this.bind("thumbnail", control, "value");
112130
control.bind("value", this, "thumbnail");

0 commit comments

Comments
 (0)