Skip to content

Commit 8c0a500

Browse files
authored
🎨 [Frontend] Enh: Converstations (#7571)
1 parent 2155efe commit 8c0a500

File tree

17 files changed

+174
-73
lines changed

17 files changed

+174
-73
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
161161
__addItems: function() {
162162
this.__addUIConfigItems();
163163
if (osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled()) {
164-
this.__addHypertools();
164+
if (osparc.product.Utils.isS4LProduct()) {
165+
this.__addHypertools();
166+
}
165167
this.__addOtherTabsAccess();
166168
}
167169
this.getChildControl("new-folder");

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,8 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
522522
this.__addOpenButton(page);
523523

524524
const lazyLoadContent = () => {
525-
const commentsList = new osparc.info.CommentsList(resourceData["uuid"]);
526-
page.addToContent(commentsList);
527-
if (osparc.data.model.Study.canIWrite(resourceData["accessRights"])) {
528-
const addComment = new osparc.info.CommentAdd(resourceData["uuid"]);
529-
addComment.setPaddingLeft(10);
530-
addComment.addListener("commentAdded", () => commentsList.fetchComments());
531-
page.addToFooter(addComment);
532-
}
525+
const conversations = new osparc.info.Conversations(resourceData);
526+
page.addToContent(conversations);
533527
}
534528
page.addListenerOnce("appear", lazyLoadContent, this);
535529

@@ -545,23 +539,23 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
545539

546540
const lazyLoadContent = () => {
547541
const resourceData = this.__resourceData;
548-
let permissionsView = null;
542+
let collaboratorsView = null;
549543
if (osparc.utils.Resources.isService(resourceData)) {
550-
permissionsView = new osparc.share.CollaboratorsService(resourceData);
551-
permissionsView.addListener("updateAccessRights", e => {
544+
collaboratorsView = new osparc.share.CollaboratorsService(resourceData);
545+
collaboratorsView.addListener("updateAccessRights", e => {
552546
const updatedData = e.getData();
553547
if (osparc.utils.Resources.isService(resourceData)) {
554548
this.fireDataEvent("updateService", updatedData);
555549
}
556550
}, this);
557551
} else {
558-
permissionsView = new osparc.share.CollaboratorsStudy(resourceData);
552+
collaboratorsView = new osparc.share.CollaboratorsStudy(resourceData);
559553
if (osparc.utils.Resources.isStudy(resourceData)) {
560-
permissionsView.getChildControl("study-link").show();
554+
collaboratorsView.getChildControl("study-link").show();
561555
} else if (osparc.utils.Resources.isTemplate(resourceData)) {
562-
permissionsView.getChildControl("template-link").show();
556+
collaboratorsView.getChildControl("template-link").show();
563557
}
564-
permissionsView.addListener("updateAccessRights", e => {
558+
collaboratorsView.addListener("updateAccessRights", e => {
565559
const updatedData = e.getData();
566560
if (osparc.utils.Resources.isStudy(resourceData)) {
567561
this.fireDataEvent("updateStudy", updatedData);
@@ -570,7 +564,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
570564
}
571565
}, this);
572566
}
573-
page.addToContent(permissionsView);
567+
page.addToContent(collaboratorsView);
574568
}
575569
page.addListenerOnce("appear", lazyLoadContent, this);
576570

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

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

418418
__openShareWith: function() {
419419
const workspace = osparc.store.Workspaces.getInstance().getWorkspace(this.getCurrentWorkspaceId());
420-
const permissionsView = new osparc.share.CollaboratorsWorkspace(workspace);
420+
const collaboratorsView = new osparc.share.CollaboratorsWorkspace(workspace);
421421
const title = this.tr("Share Workspace");
422-
const win = osparc.ui.window.Window.popUpInWindow(permissionsView, title, 500, 400);
423-
permissionsView.addListener("updateAccessRights", () => {
422+
const win = osparc.ui.window.Window.popUpInWindow(collaboratorsView, title, 500, 400);
423+
collaboratorsView.addListener("updateAccessRights", () => {
424424
win.close();
425425
this.__updateShareInfo(workspace.getAccessRights());
426426
}, this);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
293293
},
294294

295295
__openShareWith: function() {
296-
const permissionsView = new osparc.share.CollaboratorsWorkspace(this.getWorkspace());
296+
const collaboratorsView = new osparc.share.CollaboratorsWorkspace(this.getWorkspace());
297297
const title = this.tr("Share Workspace");
298-
osparc.ui.window.Window.popUpInWindow(permissionsView, title, 500, 400);
299-
permissionsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getWorkspace().getAccessRights()), this);
298+
osparc.ui.window.Window.popUpInWindow(collaboratorsView, title, 500, 400);
299+
collaboratorsView.addListener("updateAccessRights", () => this.__applyAccessRights(this.getWorkspace().getAccessRights()), this);
300300
},
301301

302302
__trashWorkspaceRequested: function() {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,19 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
438438

439439
this.__addTopBarSpacer(topBar);
440440

441+
if (osparc.utils.DisabledPlugins.isConversationEnabled()) {
442+
const commentsButton = new qx.ui.form.Button().set({
443+
appearance: "form-button-outlined",
444+
toolTipText: this.tr("Conversations"),
445+
icon: "@FontAwesome5Solid/comments/16",
446+
marginRight: 10,
447+
marginTop: 7,
448+
...osparc.navigation.NavigationBar.BUTTON_OPTIONS
449+
});
450+
commentsButton.addListener("execute", () => osparc.info.Conversations.popUpInWindow(study.serialize()));
451+
topBar.add(commentsButton);
452+
}
453+
441454
const startAppButtonTB = this.__startAppButtonTB = new qx.ui.form.Button().set({
442455
appearance: "form-button-outlined",
443456
label: this.tr("App Mode"),

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

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

21-
construct: function() {
21+
construct: function(study) {
2222
this.base(arguments);
2323

24+
this.__study = study;
25+
2426
this._setLayout(new qx.ui.layout.VBox(10));
2527

2628
this.getChildControl("instructions");
@@ -86,16 +88,48 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", {
8688
control.addListener("execute", () => {
8789
const currentStudy = osparc.store.Store.getInstance().getCurrentStudy().serialize();
8890
currentStudy["resourceType"] = "study";
89-
const collaboratorsManager = new osparc.share.NewCollaboratorsManager(currentStudy, false);
90-
collaboratorsManager.setCaption("Recipient");
91-
collaboratorsManager.getActionButton().setLabel(this.tr("Add"));
92-
collaboratorsManager.addListener("addCollaborators", e => {
93-
const {
94-
selectedGids,
95-
} = e.getData();
96-
if (selectedGids) {
97-
collaboratorsManager.close();
98-
this.__setRecipientGid(selectedGids[0]);
91+
const recipientsManager = new osparc.share.NewCollaboratorsManager(currentStudy, false, false);
92+
recipientsManager.setCaption("Recipient");
93+
recipientsManager.getActionButton().setLabel(this.tr("Add"));
94+
recipientsManager.addListener("addCollaborators", e => {
95+
const data = e.getData();
96+
const recipientGids = data["selectedGids"];
97+
98+
if (recipientGids && recipientGids.length) {
99+
const recipientGid = parseInt(recipientGids[0]);
100+
this.__setRecipientGid(recipientGid);
101+
recipientsManager.close();
102+
103+
const currentAccessRights = this.__study.getAccessRights();
104+
const proposeSharing = [];
105+
if (!(parseInt(recipientGid) in currentAccessRights)) {
106+
proposeSharing.push(recipientGid);
107+
}
108+
if (proposeSharing.length) {
109+
const collaboratorsManager = new osparc.share.NewCollaboratorsManager(currentStudy, false, true, proposeSharing);
110+
collaboratorsManager.addListener("addCollaborators", ev => {
111+
const {
112+
selectedGids,
113+
newAccessRights,
114+
} = ev.getData();
115+
const newCollaborators = {};
116+
selectedGids.forEach(gid => {
117+
newCollaborators[gid] = newAccessRights;
118+
});
119+
const studyData = this.__study.serialize();
120+
osparc.store.Study.addCollaborators(studyData, newCollaborators)
121+
.then(() => {
122+
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators()
123+
selectedGids.forEach(gid => {
124+
if (gid in potentialCollaborators && "getUserId" in potentialCollaborators[gid]) {
125+
const uid = potentialCollaborators[gid].getUserId();
126+
osparc.notification.Notifications.postNewStudy(uid, studyData["uuid"]);
127+
}
128+
});
129+
})
130+
.finally(() => collaboratorsManager.close());
131+
});
132+
}
99133
}
100134
}, this);
101135
}, this);

services/static-webserver/client/source/class/osparc/info/CommentUI.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ qx.Class.define("osparc.info.CommentUI", {
6565
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
6666
alignX: this.__isMyComment() ? "right" : "left"
6767
}));
68+
control.addAt(new qx.ui.basic.Label("-"), 1);
6869
this._add(control, {
6970
row: 0,
7071
column: 1
@@ -74,17 +75,17 @@ qx.Class.define("osparc.info.CommentUI", {
7475
control = new qx.ui.basic.Label().set({
7576
font: "text-12"
7677
});
77-
this.getChildControl("header-layout").addAt(control, 0);
78+
this.getChildControl("header-layout").addAt(control, this.__isMyComment() ? 2 : 0);
7879
break;
7980
case "last-updated":
8081
control = new qx.ui.basic.Label().set({
8182
font: "text-12"
8283
});
83-
this.getChildControl("header-layout").addAt(control, 1);
84+
this.getChildControl("header-layout").addAt(control, this.__isMyComment() ? 0 : 2);
8485
break;
8586
case "comment-content":
8687
control = new osparc.ui.markdown.Markdown().set({
87-
backgroundColor: "background-main-2",
88+
// backgroundColor: "background-main-2",
8889
decorator: "rounded",
8990
noMargin: true,
9091
paddingLeft: 8,

services/static-webserver/client/source/class/osparc/info/CommentsList.js renamed to services/static-webserver/client/source/class/osparc/info/Conversations.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
************************************************************************ */
1717

1818

19-
qx.Class.define("osparc.info.CommentsList", {
19+
qx.Class.define("osparc.info.Conversations", {
2020
extend: qx.ui.core.Widget,
2121

2222
/**
23-
* @param studyId {String} Study Id
23+
* @param studyData {String} Study Data
2424
*/
25-
construct: function(studyId) {
25+
construct: function(studyData) {
2626
this.base(arguments);
2727

28-
this.__studyId = studyId;
28+
this.__studyData = studyData;
2929

3030
this._setLayout(new qx.ui.layout.VBox(10));
3131

@@ -34,7 +34,19 @@ qx.Class.define("osparc.info.CommentsList", {
3434
this.fetchComments();
3535
},
3636

37+
statics: {
38+
popUpInWindow: function(studyData) {
39+
const conversations = new osparc.info.Conversations(studyData);
40+
const title = qx.locale.Manager.tr("Conversations");
41+
const viewWidth = 600;
42+
const viewHeight = 700;
43+
const win = osparc.ui.window.Window.popUpInWindow(conversations, title, viewWidth, viewHeight);
44+
return win;
45+
},
46+
},
47+
3748
members: {
49+
__studyData: null,
3850
__nextRequestParams: null,
3951

4052
_createChildControlImpl: function(id) {
@@ -50,13 +62,23 @@ qx.Class.define("osparc.info.CommentsList", {
5062
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({
5163
alignY: "middle"
5264
});
53-
this._add(control);
65+
this._add(control, {
66+
flex: 1
67+
});
5468
break;
5569
case "load-more-button":
5670
control = new osparc.ui.form.FetchButton(this.tr("Load more comments..."));
5771
control.addListener("execute", () => this.fetchComments(false));
5872
this._add(control);
5973
break;
74+
case "add-comment":
75+
if (osparc.data.model.Study.canIWrite(this.__studyData["accessRights"])) {
76+
control = new osparc.info.CommentAdd(this.__studyData["uuid"]);
77+
control.setPaddingLeft(10);
78+
control.addListener("commentAdded", () => this.fetchComments());
79+
this._add(control);
80+
}
81+
break;
6082
}
6183

6284
return control || this.base(arguments, id);
@@ -66,6 +88,7 @@ qx.Class.define("osparc.info.CommentsList", {
6688
this.getChildControl("title");
6789
this.getChildControl("comments-list");
6890
this.getChildControl("load-more-button");
91+
this.getChildControl("add-comment");
6992
},
7093

7194
fetchComments: function(removeComments = true) {
@@ -92,7 +115,7 @@ qx.Class.define("osparc.info.CommentsList", {
92115
__getNextRequest: function() {
93116
const params = {
94117
url: {
95-
studyId: this.__studyId,
118+
studyId: this.__studyData["uuid"],
96119
offset: 0,
97120
limit: 20
98121
}

services/static-webserver/client/source/class/osparc/info/ServiceLarge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ qx.Class.define("osparc.info.ServiceLarge", {
505505
},
506506

507507
__openAccessRights: function() {
508-
const permissionsView = osparc.info.ServiceUtils.openAccessRights(this.getService());
509-
permissionsView.addListener("updateAccessRights", e => {
508+
const collaboratorsView = osparc.info.ServiceUtils.openAccessRights(this.getService());
509+
collaboratorsView.addListener("updateAccessRights", e => {
510510
const updatedServiceData = e.getData();
511511
this.setService(updatedServiceData);
512512
this.fireDataEvent("updateService", updatedServiceData);

services/static-webserver/client/source/class/osparc/info/ServiceUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ qx.Class.define("osparc.info.ServiceUtils", {
367367
* @param serviceData {Object} Serialized Service Object
368368
*/
369369
openAccessRights: function(serviceData) {
370-
const permissionsView = new osparc.share.CollaboratorsService(serviceData);
370+
const collaboratorsView = new osparc.share.CollaboratorsService(serviceData);
371371
const title = qx.locale.Manager.tr("Share with Collaborators and Organizations");
372-
osparc.ui.window.Window.popUpInWindow(permissionsView, title, 400, 300);
373-
return permissionsView;
372+
osparc.ui.window.Window.popUpInWindow(collaboratorsView, title, 400, 300);
373+
return collaboratorsView;
374374
},
375375

376376
/**

0 commit comments

Comments
 (0)