Skip to content

Commit

Permalink
📝 Frontend: The user will not get notified (#3915)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Feb 24, 2023
1 parent a4043e2 commit 9d02582
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ qx.Class.define("osparc.component.share.CollaboratorsService", {
osparc.data.Resources.fetch("services", "patch", params)
.then(serviceData => {
this.fireDataEvent("updateService", serviceData);
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("Collaborator(s) successfully added"));
let text = this.tr("Collaborator(s) successfully added.");
text += "<br>";
text += this.tr("The user will not get notified.");
osparc.component.message.FlashMessenger.getInstance().logAs(text);
this._reloadCollaboratorsList();
})
.catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ qx.Class.define("osparc.component.share.CollaboratorsStudy", {
osparc.data.Resources.fetch("studies", "put", params)
.then(updatedData => {
this.fireDataEvent("updateAccessRights", updatedData);
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("Collaborator(s) successfully added"));
let text = this.tr("Collaborator(s) successfully added.");
text += "<br>";
text += this.tr("The user will not get notified.");
osparc.component.message.FlashMessenger.getInstance().logAs(text);
this._reloadCollaboratorsList();
})
.catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
delete selectedAnnotation["initPos"];
});

if (nodeUI) {
if (nodeUI && osparc.desktop.preferences.Preferences.getInstance().isSnapNodeToGrid()) {
nodeUI.snapToGrid();
// make sure nodeUI is moved, then update edges
setTimeout(() => this.__updateNodeUIPos(nodeUI), 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
apply: "__applyUiMode"
},

emptyWorkbench: {
check: "Boolean",
nullable: false,
init: null,
event: "changeEmptyWorkbench",
apply: "__applyEmptyWorkbench"
},

updatable: {
check: [null, "retired", "deprecated", "updatable"],
nullable: false,
Expand Down Expand Up @@ -393,7 +401,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
},

__applyWorkbench: function(workbench) {
if (this.isResourceType("study") || this.isResourceType("template")) {
this.setEmptyWorkbench(Object.keys(workbench).length === 0);
}
if (workbench === null) {
// it is a service
return;
}

Expand Down Expand Up @@ -426,6 +438,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
});
},

__applyEmptyWorkbench: function(isEmpty) {
const emptyWorkbench = this.getChildControl("empty-workbench");
emptyWorkbench.setVisibility(isEmpty ? "visible" : "excluded");
},

__applyUpdatable: function(updatable) {
const updateStudy = this.getChildControl("update-study");
updateStudy.addListener("pointerdown", e => e.stopPropagation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,46 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
_createChildControlImpl: function(id) {
let control;
switch (id) {
case "tsr-rating": {
case "tsr-rating":
control = osparc.dashboard.CardBase.createTSRLayout();
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.TSR);
break;
}
case "workbench-mode": {
case "workbench-mode":
control = new qx.ui.basic.Image().set({
alignY: "middle"
});
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.VIEWER_MODE);
break;
}
case "update-study": {
case "empty-workbench":
control = new qx.ui.basic.Image().set({
source: "@FontAwesome5Solid/times-circle/14",
alignY: "middle",
toolTipText: this.tr("Empty")
});
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.UPDATES);
break;
case "update-study":
control = new qx.ui.basic.Image().set({
source: "@MaterialIcons/update/16",
visibility: "excluded",
alignY: "middle"
});
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.UPDATES);
break;
}
case "hits-service": {
case "hits-service":
control = new qx.ui.basic.Label().set({
toolTipText: this.tr("Number of times you instantiated it"),
alignY: "middle"
});
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.UPDATES);
break;
}
case "tags":
control = new qx.ui.container.Composite(new qx.ui.layout.Flow(5, 3)).set({
anonymous: true
});
this._mainLayout.add(control, osparc.dashboard.GridButtonBase.POS.TAGS);
break;
case "menu-button": {
case "menu-button":
this.getChildControl("title").set({
maxWidth: osparc.dashboard.GridButtonBase.ITEM_WIDTH - 2*osparc.dashboard.GridButtonBase.PADDING - this.self().MENU_BTN_WIDTH
});
Expand All @@ -95,7 +99,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
right: -2
});
break;
}
case "tick-unselected":
control = new qx.ui.basic.Image("@FontAwesome5Solid/circle/16");
this._add(control, {
Expand All @@ -119,15 +122,14 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
left: 0
});
break;
case "permission-icon": {
case "permission-icon":
control = new qx.ui.basic.Image();
control.exclude();
this._add(control, {
bottom: 2,
right: 12
});
break;
}
}

return control || this.base(arguments, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ qx.Class.define("osparc.dashboard.ListButtonBase", {
LOCK_STATUS: 1,
TITLE: 2,
DESCRIPTION: 3,
UPDATE_STUDY: 4,
TAGS: 5,
UI_MODE: 6,
UPDATES: 4,
UI_MODE: 5,
TAGS: 6,
PERMISSION: 7,
TSR: 8,
SHARED: 9,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.LOCK_STATUS
});
break;
case "permission-icon": {
case "permission-icon":
control = new qx.ui.basic.Image().set({
minWidth: 50
});
Expand All @@ -59,7 +59,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.PERMISSION
});
break;
}
case "tags":
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(3).set({
alignY: "middle"
Expand All @@ -72,7 +71,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.TAGS
});
break;
case "shared-icon": {
case "shared-icon":
control = new qx.ui.basic.Image().set({
minWidth: 50,
alignY: "middle"
Expand All @@ -82,8 +81,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.SHARED
});
break;
}
case "last-change": {
case "last-change":
control = new qx.ui.basic.Label().set({
anonymous: true,
font: "text-13",
Expand All @@ -96,26 +94,23 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.LAST_CHANGE
});
break;
}
case "tsr-rating": {
case "tsr-rating":
control = osparc.dashboard.CardBase.createTSRLayout();
this._add(control, {
row: 0,
column: osparc.dashboard.ListButtonBase.POS.TSR
});
break;
}
case "workbench-mode":
control = new qx.ui.basic.Image().set({
minWidth: 20,
alignY: "middle"
});
this._add(control, {
row: 0,
column: osparc.dashboard.ListButtonBase.POS.UI_MODE
});
break;
case "hits-service": {
case "hits-service":
control = new qx.ui.basic.Label().set({
alignY: "middle",
toolTipText: this.tr("Number of times you instantiated it")
Expand All @@ -125,17 +120,26 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.HITS
});
break;
}
case "empty-workbench":
control = new qx.ui.basic.Image().set({
alignY: "middle",
source: "@FontAwesome5Solid/times-circle/14",
toolTipText: this.tr("Empty")
});
this._add(control, {
row: 0,
column: osparc.dashboard.ListButtonBase.POS.UPDATES
});
break;
case "update-study":
control = new qx.ui.basic.Image().set({
minWidth: 20,
alignY: "middle",
source: "@MaterialIcons/update/18",
visibility: "excluded"
});
this._add(control, {
row: 0,
column: osparc.dashboard.ListButtonBase.POS.UPDATE_STUDY
column: osparc.dashboard.ListButtonBase.POS.UPDATES
});
break;
case "menu-selection-stack":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ qx.Class.define("osparc.desktop.preferences.Preferences", {
init: true,
check: "Boolean",
event: "changeConfirmStopNode"
},

snapNodeToGrid: {
nullable: false,
init: true,
check: "Boolean",
event: "changeSnapNodeToGrid"
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ qx.Class.define("osparc.desktop.preferences.pages.ConfirmationsPage", {
preferencesSettings.bind("confirmStopNode", cbConfirmStopNode, "value");
cbConfirmStopNode.bind("value", preferencesSettings, "confirmStopNode");
box.add(cbConfirmStopNode);

const cbSnapNodeToGrid = new qx.ui.form.CheckBox(this.tr("Snap Node to grid"));
preferencesSettings.bind("snapNodeToGrid", cbSnapNodeToGrid, "value");
cbSnapNodeToGrid.bind("value", preferencesSettings, "snapNodeToGrid");
box.add(cbSnapNodeToGrid);
}

return box;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@ qx.Class.define("osparc.desktop.preferences.pages.OrganizationMembersList", {
});
},

__addMember: function(orgMemberEmail) {
__addMember: async function(orgMemberEmail) {
if (this.__currentOrg === null) {
return;
}

const productEveryone = await osparc.store.Store.getInstance().getProductEveryone();

const orgId = this.__currentOrg.getKey();
const params = {
url: {
Expand All @@ -321,30 +323,28 @@ qx.Class.define("osparc.desktop.preferences.pages.OrganizationMembersList", {
};
osparc.data.Resources.fetch("organizationMembers", "post", params)
.then(() => {
const store = osparc.store.Store.getInstance();
store.getProductEveryone()
.then(productEveryone => {
if (productEveryone && productEveryone["gid"] === parseInt(orgId)) {
// demote the new member to user
const params2 = {
url: {
"gid": orgId
}
};
osparc.data.Resources.get("organizationMembers", params2)
.then(respOrgMembers => {
const newMember = respOrgMembers.find(m => m["login"] === orgMemberEmail);
if (newMember) {
const msg = orgMemberEmail + this.tr(" added");
this.__demoteToUser(newMember, msg);
}
});
} else {
osparc.component.message.FlashMessenger.getInstance().logAs(orgMemberEmail + this.tr(" added"));
osparc.store.Store.getInstance().reset("organizationMembers");
this.__reloadOrgMembers();
let text = orgMemberEmail + this.tr(" successfully added.");
text += "<br>";
text += this.tr("The user will not get notified.");
if (productEveryone && productEveryone["gid"] === parseInt(orgId)) {
// demote the new member to user
const params2 = {
url: {
"gid": orgId
}
});
};
osparc.data.Resources.get("organizationMembers", params2)
.then(respOrgMembers => {
const newMember = respOrgMembers.find(m => m["login"] === orgMemberEmail);
if (newMember) {
this.__demoteToUser(newMember, text);
}
});
} else {
osparc.component.message.FlashMessenger.getInstance().logAs(text);
osparc.store.Store.getInstance().reset("organizationMembers");
this.__reloadOrgMembers();
}
})
.catch(err => {
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("Something went wrong adding the user"), "ERROR");
Expand Down

0 comments on commit 9d02582

Please sign in to comment.