Skip to content

Commit

Permalink
🐛 Handle nullables for firstName lastName in me response ITISFoundati…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsaq007 authored Jan 17, 2024
1 parent 12310f8 commit 146e3ec
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ qx.Class.define("osparc.auth.Manager", {
const authData = osparc.auth.Data.getInstance();
authData.set({
email: profile["login"],
firstName: profile["first_name"],
lastName: profile["last_name"],
firstName: profile["first_name"] || profile["login"],
lastName: profile["last_name"] || "",
expirationDate: "expirationDate" in profile ? new Date(profile["expirationDate"]) : null
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
__showBlockedCardFromStatus: function(lockedStatus) {
const status = lockedStatus["status"];
const owner = lockedStatus["owner"];
let toolTip = osparc.utils.Utils.firstsUp(owner["first_name"], owner["last_name"]);
let toolTip = osparc.utils.Utils.firstsUp(owner["first_name"] || this.tr("A user"), owner["last_name"] || "");
let image = null;
switch (status) {
case "CLOSING":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ qx.Class.define("osparc.desktop.MainPageHandler", {
lockedBy = studyData["state"]["locked"]["owner"];
}
if (locked && lockedBy["user_id"] !== osparc.auth.Data.getInstance().getUserId()) {
const msg = qx.locale.Manager.tr("Study is already open by ") + lockedBy["first_name"];
const msg = `${qx.locale.Manager.tr("Study is already open by ")} ${
"first_name" in lockedBy && lockedBy["first_name"] != null ?
lockedBy["first_name"] :
qx.locale.Manager.tr("another user.")
}`;
throw new Error(msg);
}
const store = osparc.store.Store.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
const membersList = [];
members.forEach(member => {
member["thumbnail"] = osparc.utils.Avatar.getUrl(member["login"], 32);
member["name"] = osparc.utils.Utils.firstsUp(member["first_name"], member["last_name"]);
member["name"] = osparc.utils.Utils.firstsUp(member["first_name"] || member["login"], member["last_name"] || "");
let options = [];
if (canIDelete) {
// admin...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ qx.Class.define("osparc.desktop.preferences.pages.ClustersPage", {
collabObj["login"] = collaborator["description"];
} else if (collaborator["collabType"] === 2) {
collabObj["thumbnail"] = osparc.utils.Avatar.getUrl(collaborator["login"], 32);
collabObj["name"] = osparc.utils.Utils.firstsUp(collaborator["first_name"], collaborator["last_name"]);
collaborator["name"] = osparc.utils.Utils.firstsUp(
`${"first_name" in collaborator && collaborator["first_name"] != null ?
collaborator["first_name"] : collaborator["login"]}`,
`${"last_name" in collaborator && collaborator["last_name"] ?
collaborator["last_name"] : ""}`
);
collabObj["login"] = collaborator["login"];
}
if (Object.keys(collabObj).length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ qx.Class.define("osparc.desktop.wallets.MembersList", {
const collaborator = osparc.utils.Utils.deepCloneObject(collab);
if ("first_name" in collaborator) {
collaborator["thumbnail"] = osparc.utils.Avatar.getUrl(collaborator["login"], 32);
collaborator["name"] = osparc.utils.Utils.firstsUp(collaborator["first_name"], collaborator["last_name"]);
collaborator["name"] = osparc.utils.Utils.firstsUp(
`${"first_name" in collaborator && collaborator["first_name"] != null ?
collaborator["first_name"] : collaborator["login"]}`,
`${"last_name" in collaborator && collaborator["last_name"] != null ?
collaborator["last_name"] : ""}`
);
}
collaborator["accessRights"] = accessRights;
let options = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ qx.Class.define("osparc.filter.CollaboratorToggleButton", {
});

let label = null;
if ("first_name" in collaborator) {
if (collaborator["first_name"]) {
// user
label = collaborator["first_name"] + " " + collaborator["last_name"];
label = `${collaborator["first_name"]} ${"last_name" in collaborator && collaborator["last_name"] != null ? collaborator["last_name"] : ""}`;
} else if ("login" in collaborator) {
label = collaborator["login"];
} else {
// org
label = collaborator["label"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ qx.Class.define("osparc.filter.OrganizationMembers", {
.then(members => {
members.sort((a, b) => (a["first_name"] > b["first_name"]) ? 1 : -1);
members.forEach(member => {
const name = osparc.utils.Utils.firstsUp(member["first_name"], member["last_name"]);
const name = osparc.utils.Utils.firstsUp(member["first_name"] || member["login"], member["last_name"] || "");
const bnt = this._addOption(name);
bnt.uid = member["id"];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ qx.Class.define("osparc.filter.OrganizationsAndMembers", {
addOption: function(group) {
let name = "";
if ("first_name" in group) {
name = group["first_name"] + " " + group["last_name"];
name = `${group["first_name"]} ${"last_name" in group && group["last_name"] != null ? group["last_name"] : ""}`;
} else {
name = group["label"];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ qx.Class.define("osparc.metadata.ServicesInStudyUpdate", {
});

const updateAllButton = this.__updateAllButton = new osparc.ui.form.FetchButton(this.tr("Update all"), "@MaterialIcons/update/14").set({
backgroundColor: "strong-main",
appearance: "form-button",
padding: [2, 5],
visibility: "excluded"
});
this._servicesGrid.add(updateAllButton, {
Expand Down Expand Up @@ -256,7 +257,8 @@ qx.Class.define("osparc.metadata.ServicesInStudyUpdate", {
}
if (isUpdatable) {
updateButton.set({
backgroundColor: "strong-main",
appearance: "form-button-outlined",
padding: [2, 5],
label: this.tr("Update")
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,12 @@ qx.Class.define("osparc.share.Collaborators", {
const collaborator = osparc.utils.Utils.deepCloneObject(collab);
if ("first_name" in collaborator) {
collaborator["thumbnail"] = osparc.utils.Avatar.getUrl(collaborator["login"], 32);
collaborator["name"] = osparc.utils.Utils.firstsUp(collaborator["first_name"], collaborator["last_name"]);
collaborator["name"] = osparc.utils.Utils.firstsUp(
`${"first_name" in collaborator && collaborator["first_name"] != null ?
collaborator["first_name"] : collaborator["login"]}`,
`${"last_name" in collaborator && collaborator["last_name"] ?
collaborator["last_name"] : ""}`
);
}
collaborator["accessRights"] = accessRights[gid];
collaborator["showOptions"] = (this._resourceType === "service") ? this._canIWrite() : this._canIDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
alignX: "right"
}));
const shareButton = this.__shareButton = new osparc.ui.form.FetchButton(this.tr("Share")).set({
appearance: "strong-button"
appearance: "form-button"
});
shareButton.addListener("execute", () => this.__shareClicked(), this);
buttons.add(shareButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,10 @@ qx.Class.define("osparc.store.Store", {
.then(orgMemberss => {
orgMemberss.forEach(orgMembers => {
orgMembers.forEach(orgMember => {
orgMember["label"] = osparc.utils.Utils.firstsUp(orgMember["first_name"], orgMember["last_name"]);
orgMember["label"] = osparc.utils.Utils.firstsUp(
`${"first_name" in orgMember && orgMember["first_name"] != null ? orgMember["first_name"] : orgMember["login"]}`,
`${orgMember["last_name"] ? orgMember["last_name"] : ""}`
);
reachableMembers[orgMember["gid"]] = orgMember;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ qx.Class.define("osparc.utils.Utils", {
firstsUp: function(...args) {
const labels = [];
args.forEach(arg => labels.push(qx.lang.String.firstUp(arg)));
return labels.join(" ");
return labels.length > 1 ? labels.join(" ") : labels[0];
},

onlyFirstsUp: function(word) {
Expand Down

0 comments on commit 146e3ec

Please sign in to comment.