diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 46a05799fddc..0e8465a9a646 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -52,6 +52,7 @@ qx.Class.define("osparc.dashboard.CardBase", { statics: { SHARE_ICON: "@FontAwesome5Solid/share-alt/13", SHARED_USER: "@FontAwesome5Solid/user/13", + SHARED_SUPPORT: "@FontAwesome5Solid/question/13", SHARED_ORGS: "@FontAwesome5Solid/users/13", SHARED_ALL: "@FontAwesome5Solid/globe/13", PERM_READ: "@FontAwesome5Solid/eye/13", @@ -188,17 +189,25 @@ qx.Class.define("osparc.dashboard.CardBase", { // Icon const groupsStore = osparc.store.Groups.getInstance(); const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); + const supportGroup = groupsStore.getSupportGroup(); const organizations = groupsStore.getOrganizations(); const myGroupId = groupsStore.getMyGroupId(); const organizationIds = Object.keys(organizations).map(key => parseInt(key)); if (gids.some(gid => everyoneGroupIds.includes(gid))) { + // shared with "1" or product everyone shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL); + } else if (supportGroup && gids.includes(supportGroup.getGroupId())) { + // shared with support group, show as if it was a group + shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS); } else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection + // shared with at least one organization shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS); } else if (gids.length === 1 && gids[0] === myGroupId) { + // not shared shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON); } else { + // shared with some users shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER); } @@ -227,10 +236,14 @@ qx.Class.define("osparc.dashboard.CardBase", { addHintFromGids: function(icon, gids) { const groupsStore = osparc.store.Groups.getInstance(); const everyoneGroups = groupsStore.getEveryoneGroups(); + const supportGroup = groupsStore.getSupportGroup(); const organizations = groupsStore.getOrganizations(); const myGroupId = groupsStore.getMyGroupId(); const groups = everyoneGroups.slice(); + if (supportGroup) { + groups.push(supportGroup); + } groups.push(...Object.values(organizations)); const sharedGrps = []; groups.forEach(group => { @@ -267,10 +280,14 @@ qx.Class.define("osparc.dashboard.CardBase", { sharedGrpLabels.push("..."); break; } - let sharedGrpLabel = sharedGrps[i].getLabel(); - if (everyoneGroups.includes(sharedGrps[i])) { + const sharedGroup = sharedGrps[i]; + let sharedGrpLabel = sharedGroup.getLabel(); + if (everyoneGroups.includes(sharedGroup)) { sharedGrpLabel = "Public"; } + if (supportGroup && supportGroup.getGroupId() === sharedGroup.getGroupId()) { + sharedGrpLabel = supportGroup.getLabel(); + } if (!sharedGrpLabels.includes(sharedGrpLabel)) { sharedGrpLabels.push(sharedGrpLabel); } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index a331425a5557..8ff84ed5bce2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -580,11 +580,11 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { let icon = ""; if (group.getThumbnail()) { icon = group.getThumbnail(); - } else if (group["collabType"] === 0) { + } else if (group["collabType"] === osparc.store.Groups.COLLAB_TYPE.EVERYONE) { icon = "@FontAwesome5Solid/globe/24"; - } else if (group["collabType"] === 1) { + } else if (group["collabType"] === osparc.store.Groups.COLLAB_TYPE.ORGANIZATION) { icon = "@FontAwesome5Solid/users/24"; - } else if (group["collabType"] === 2) { + } else if (group["collabType"] === osparc.store.Groups.COLLAB_TYPE.USER) { icon = "@FontAwesome5Solid/user/24"; } groupContainer.set({ diff --git a/services/static-webserver/client/source/class/osparc/data/model/Group.js b/services/static-webserver/client/source/class/osparc/data/model/Group.js index e345265ba689..174e1081ab84 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/Group.js +++ b/services/static-webserver/client/source/class/osparc/data/model/Group.js @@ -82,7 +82,7 @@ qx.Class.define("osparc.data.model.Group", { }, groupType: { - check: ["me", "organization", "productEveryone", "everyone"], + check: ["me", "organization", "support", "productEveryone", "everyone"], nullable: false, init: null, }, diff --git a/services/static-webserver/client/source/class/osparc/data/model/User.js b/services/static-webserver/client/source/class/osparc/data/model/User.js index 538fd41c3692..595223ff4aea 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/User.js +++ b/services/static-webserver/client/source/class/osparc/data/model/User.js @@ -55,13 +55,7 @@ qx.Class.define("osparc.data.model.User", { phoneNumber: userData["phone"] || null, }); - let description = this.getFullName(); - if (email) { - if (description) { - description += " - " - } - description += email; - } + const description = osparc.data.model.User.userDataToDescription(firstName, lastName, email); this.set({ label: userData["userName"] || description, description, diff --git a/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js b/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js index 2817fd3af730..d003e056d2b9 100644 --- a/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js +++ b/services/static-webserver/client/source/class/osparc/filter/CollaboratorToggleButton.js @@ -28,18 +28,23 @@ qx.Class.define("osparc.filter.CollaboratorToggleButton", { let label = null; let toolTipText = ""; switch (collaborator["collabType"]) { - case 0: - iconPath = "@FontAwesome5Solid/globe/14"; + case osparc.store.Groups.COLLAB_TYPE.EVERYONE: + iconPath = osparc.dashboard.CardBase.SHARED_ALL; label = this.tr("Public"); toolTipText = this.tr("Public to all users"); break; - case 1: - iconPath = "@FontAwesome5Solid/users/14"; + case osparc.store.Groups.COLLAB_TYPE.SUPPORT: + iconPath = osparc.dashboard.CardBase.SHARED_SUPPORT; label = collaborator.getLabel(); toolTipText = collaborator.getDescription(); break; - case 2: { - iconPath = "@FontAwesome5Solid/user/14"; + case osparc.store.Groups.COLLAB_TYPE.ORGANIZATION: + iconPath = osparc.dashboard.CardBase.SHARED_ORGS; + label = collaborator.getLabel(); + toolTipText = collaborator.getDescription(); + break; + case osparc.store.Groups.COLLAB_TYPE.USER: { + iconPath = osparc.dashboard.CardBase.SHARED_USER; label = collaborator.getLabel(); if (collaborator.getEmail()) { toolTipText += collaborator.getEmail() + "
"; diff --git a/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js b/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js index 0ca91537931f..67103aa43e48 100644 --- a/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js +++ b/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js @@ -64,18 +64,21 @@ qx.Class.define("osparc.filter.OrganizationsAndMembers", { const visibleCollaborators = Object.values(this.__visibleCollaborators); + // define the priority order + const collabTypeOrder = [ + osparc.store.Groups.COLLAB_TYPE.EVERYONE, + osparc.store.Groups.COLLAB_TYPE.SUPPORT, + osparc.store.Groups.COLLAB_TYPE.ORGANIZATION, + osparc.store.Groups.COLLAB_TYPE.USER + ]; // sort them first visibleCollaborators.sort((a, b) => { - if (a["collabType"] > b["collabType"]) { - return 1; - } - if (a["collabType"] < b["collabType"]) { - return -1; - } - if (a.getLabel() > b.getLabel()) { - return 1; - } - return -1; + const typeDiff = collabTypeOrder.indexOf(a["collabType"]) - collabTypeOrder.indexOf(b["collabType"]); + if (typeDiff !== 0) { + return typeDiff; + } + // fallback: sort alphabetically by label + return a.getLabel().localeCompare(b.getLabel()); }); visibleCollaborators.forEach(visibleCollaborator => { @@ -85,14 +88,14 @@ qx.Class.define("osparc.filter.OrganizationsAndMembers", { const btn = this.addOption(visibleCollaborator); let iconPath = null; switch (visibleCollaborator["collabType"]) { - case 0: - iconPath = "@FontAwesome5Solid/globe/14"; + case osparc.store.Groups.COLLAB_TYPE.EVERYONE: + iconPath = osparc.dashboard.CardBase.SHARED_ALL; break; - case 1: - iconPath = "@FontAwesome5Solid/users/14"; + case osparc.store.Groups.COLLAB_TYPE.ORGANIZATION: + iconPath = osparc.dashboard.CardBase.SHARED_ORGS; break; - case 2: - iconPath = "@FontAwesome5Solid/user/14"; + case osparc.store.Groups.COLLAB_TYPE.USER: + iconPath = osparc.dashboard.CardBase.SHARED_USER; break; } btn.setIcon(iconPath); diff --git a/services/static-webserver/client/source/class/osparc/product/Utils.js b/services/static-webserver/client/source/class/osparc/product/Utils.js index 68bbedbe17e4..c88a4a3c8ffc 100644 --- a/services/static-webserver/client/source/class/osparc/product/Utils.js +++ b/services/static-webserver/client/source/class/osparc/product/Utils.js @@ -450,9 +450,5 @@ qx.Class.define("osparc.product.Utils", { groupServices: function() { return Boolean(osparc.store.Products.getInstance().getGroupedServicesUiConfig()); }, - - isSupportEnabled: function() { - return Boolean(osparc.store.Products.getInstance().getSupportGroupId()); - }, } }); diff --git a/services/static-webserver/client/source/class/osparc/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/share/Collaborators.js index d20a1d2b8f34..394766ae2de1 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -437,6 +437,7 @@ qx.Class.define("osparc.share.Collaborators", { const usersStore = osparc.store.Users.getInstance(); const groupsStore = osparc.store.Groups.getInstance(); const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); + const supportGroup = groupsStore.getSupportGroup(); const allGroups = groupsStore.getAllGroups(); const showOptions = this.__canIChangePermissions(); const accessRights = this._serializedDataCopy["accessRights"]; @@ -461,6 +462,8 @@ qx.Class.define("osparc.share.Collaborators", { // organization if (everyoneGroupIds.includes(parseInt(gid))) { collaborator["thumbnail"] = "@FontAwesome5Solid/globe/32"; + } else if (supportGroup && supportGroup.getGroupId() === parseInt(gid)) { + collaborator["thumbnail"] = supportGroup.getThumbnail(); } else if (!collaborator["thumbnail"]) { collaborator["thumbnail"] = "@FontAwesome5Solid/users/26"; } diff --git a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js index 2a43e07c6fd9..71acad53e4c9 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -17,11 +17,12 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { allowMaximize: false, showMinimize: false, showMaximize: false, + resizable: true, autoDestroy: true, modal: true, width: 430, - maxHeight: 500, - clickAwayClose: true + height: 500, + clickAwayClose: true, }); this.__resourceData = resourceData; @@ -120,9 +121,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { break; } case "potential-collaborators-list": { - control = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({ - minHeight: 160, - }); + control = new qx.ui.container.Composite(new qx.ui.layout.VBox()); const scrollContainer = new qx.ui.container.Scroll(); scrollContainer.add(control); this.add(scrollContainer, { @@ -242,7 +241,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const text = this.getChildControl("text-filter").getChildControl("textfield").getValue(); osparc.store.Users.getInstance().searchUsers(text) .then(users => { - users.forEach(user => user["collabType"] = 2); + users.forEach(user => user["collabType"] = osparc.store.Groups.COLLAB_TYPE.USER); this.__addPotentialCollaborators(users); }) .catch(err => osparc.FlashMessenger.logError(err)) @@ -338,18 +337,21 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { const potentialCollaborators = Object.values(this.__potentialCollaborators).concat(foundCollaborators); const potentialCollaboratorList = this.getChildControl("potential-collaborators-list"); + // define the priority order + const collabTypeOrder = [ + osparc.store.Groups.COLLAB_TYPE.EVERYONE, + osparc.store.Groups.COLLAB_TYPE.SUPPORT, + osparc.store.Groups.COLLAB_TYPE.ORGANIZATION, + osparc.store.Groups.COLLAB_TYPE.USER + ]; // sort them first potentialCollaborators.sort((a, b) => { - if (a["collabType"] > b["collabType"]) { - return 1; - } - if (a["collabType"] < b["collabType"]) { - return -1; - } - if (a.getLabel() > b.getLabel()) { - return 1; + const typeDiff = collabTypeOrder.indexOf(a["collabType"]) - collabTypeOrder.indexOf(b["collabType"]); + if (typeDiff !== 0) { + return typeDiff; } - return -1; + // fallback: sort alphabetically by label + return a.getLabel().localeCompare(b.getLabel()); }); let existingCollabs = []; @@ -383,7 +385,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { return; } // maybe, do not list the organizations - if (this.__showOrganizations === false && potentialCollaborator["collabType"] !== 2) { + if (this.__showOrganizations === false && potentialCollaborator["collabType"] !== osparc.store.Groups.COLLAB_TYPE.USER) { return; } potentialCollaboratorList.add(this.__collaboratorButton(potentialCollaborator)); diff --git a/services/static-webserver/client/source/class/osparc/store/Groups.js b/services/static-webserver/client/source/class/osparc/store/Groups.js index 9279cae9d4f1..191adf1b2ad2 100644 --- a/services/static-webserver/client/source/class/osparc/store/Groups.js +++ b/services/static-webserver/client/source/class/osparc/store/Groups.js @@ -36,6 +36,13 @@ qx.Class.define("osparc.store.Groups", { init: null // this will stay null for guest users }, + supportGroup: { + check: "osparc.data.model.Group", + init: null, // this will stay null for guest users + nullable: true, + event: "changeSupportGroup", + }, + organizations: { check: "Object", init: {}, @@ -48,6 +55,15 @@ qx.Class.define("osparc.store.Groups", { }, }, + statics: { + COLLAB_TYPE: { + EVERYONE: "everyone", + SUPPORT: "support", + ORGANIZATION: "organization", + USER: "user", + }, + }, + members: { groupsCached: null, @@ -62,6 +78,15 @@ qx.Class.define("osparc.store.Groups", { .then(resp => { const everyoneGroup = this.__addToGroupsCache(resp["all"], "everyone"); const productEveryoneGroup = this.__addToGroupsCache(resp["product"], "productEveryone"); + let supportGroup = null; + if ("support" in resp && resp["support"]) { + resp["support"]["accessRights"] = { + "read": false, + "write": false, + "delete": false, + }; + supportGroup = this.__addToGroupsCache(resp["support"], "support"); + } const groupMe = this.__addToGroupsCache(resp["me"], "me"); const orgs = {}; resp["organizations"].forEach(organization => { @@ -70,12 +95,14 @@ qx.Class.define("osparc.store.Groups", { }); this.setEveryoneGroup(everyoneGroup); this.setEveryoneProductGroup(productEveryoneGroup); + this.setSupportGroup(supportGroup); this.setOrganizations(orgs); this.setGroupMe(groupMe); const myAuthData = osparc.auth.Data.getInstance(); + const description = osparc.data.model.User.userDataToDescription(myAuthData.getFirstName(), myAuthData.getLastName(), myAuthData.getEmail()); groupMe.set({ label: myAuthData.getUsername(), - description: `${myAuthData.getFirstName()} ${myAuthData.getLastName()} - ${myAuthData.getEmail()}`, + description, thumbnail: osparc.utils.Avatar.emailToThumbnail(myAuthData.getEmail(), myAuthData.getUsername()), }) return orgs; @@ -129,6 +156,11 @@ qx.Class.define("osparc.store.Groups", { allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone; } + const supportGroup = this.getSupportGroup(); + if (supportGroup) { + allGroupsAndUsers[supportGroup.getGroupId()] = supportGroup; + } + const groupMe = this.getGroupMe(); allGroupsAndUsers[groupMe.getGroupId()] = groupMe; @@ -152,9 +184,6 @@ qx.Class.define("osparc.store.Groups", { this.getMyGroupId(), ...this.getOrganizationIds().map(gId => parseInt(gId)) ]; - if (this.getEveryoneProductGroup()) { - allMyGroupIds.push(this.getEveryoneProductGroup().getGroupId()); - } if (this.getEveryoneGroup()) { allMyGroupIds.push(this.getEveryoneGroup().getGroupId()); } @@ -177,34 +206,53 @@ qx.Class.define("osparc.store.Groups", { return everyoneGroups; }, + isSupportEnabled: function() { + return Boolean(this.getSupportGroup()); + }, + + amIASupportUser: function() { + const supportGroup = this.getSupportGroup(); + if (supportGroup) { + const myOrgIds = this.getOrganizationIds().map(gId => parseInt(gId)); + return myOrgIds.includes(supportGroup.getGroupId()); + } + return false; + }, + getGroup: function(groupId) { const groups = []; const groupMe = this.getGroupMe(); - groupMe["collabType"] = 2; + groupMe["collabType"] = osparc.store.Groups.COLLAB_TYPE.USER; groups.push(groupMe); const usersStore = osparc.store.Users.getInstance(); const users = usersStore.getUsers(); users.forEach(user => { - user["collabType"] = 2; + user["collabType"] = osparc.store.Groups.COLLAB_TYPE.USER; groups.push(user); }); Object.values(this.getOrganizations()).forEach(org => { - org["collabType"] = 1; + org["collabType"] = osparc.store.Groups.COLLAB_TYPE.ORGANIZATION; groups.push(org); }); + const supportGroup = this.getSupportGroup(); + if (supportGroup && groups.findIndex(g => g.getGroupId() === supportGroup.getGroupId()) === -1) { + supportGroup["collabType"] = osparc.store.Groups.COLLAB_TYPE.SUPPORT; + groups.push(supportGroup); + } + const groupProductEveryone = this.getEveryoneProductGroup(); if (groupProductEveryone) { - groupProductEveryone["collabType"] = 0; + groupProductEveryone["collabType"] = osparc.store.Groups.COLLAB_TYPE.EVERYONE; groups.push(groupProductEveryone); } const groupEveryone = this.getEveryoneGroup(); if (groupEveryone) { - groupEveryone["collabType"] = 0; + groupEveryone["collabType"] = osparc.store.Groups.COLLAB_TYPE.EVERYONE; groups.push(groupEveryone); } const idx = groups.findIndex(group => group.getGroupId() === parseInt(groupId)); @@ -217,10 +265,11 @@ qx.Class.define("osparc.store.Groups", { getPotentialCollaborators: function(includeMe = false, includeProductEveryone = false) { const potentialCollaborators = {}; const orgs = this.getOrganizations(); + const supportGroup = this.getSupportGroup(); const productEveryone = this.getEveryoneProductGroup(); if (includeProductEveryone && productEveryone) { - productEveryone["collabType"] = 0; + productEveryone["collabType"] = osparc.store.Groups.COLLAB_TYPE.EVERYONE; potentialCollaborators[productEveryone.getGroupId()] = productEveryone; } @@ -231,21 +280,26 @@ qx.Class.define("osparc.store.Groups", { if (org.getGroupId() === productEveryone.getGroupId() && !includeProductEveryone) { return; } - org["collabType"] = 1; + org["collabType"] = osparc.store.Groups.COLLAB_TYPE.ORGANIZATION; potentialCollaborators[org.getGroupId()] = org; } }); + if (supportGroup && !(supportGroup.getGroupId() in potentialCollaborators)) { + supportGroup["collabType"] = osparc.store.Groups.COLLAB_TYPE.SUPPORT; + potentialCollaborators[supportGroup.getGroupId()] = supportGroup; + } + if (includeMe) { const myGroup = this.getGroupMe(); - myGroup["collabType"] = 2; + myGroup["collabType"] = osparc.store.Groups.COLLAB_TYPE.USER; potentialCollaborators[myGroup.getGroupId()] = myGroup; } const usersStore = osparc.store.Users.getInstance(); const users = usersStore.getUsers(); users.forEach(user => { - user["collabType"] = 2; + user["collabType"] = osparc.store.Groups.COLLAB_TYPE.USER; potentialCollaborators[user.getGroupId()] = user; }); diff --git a/services/static-webserver/client/source/class/osparc/store/Products.js b/services/static-webserver/client/source/class/osparc/store/Products.js index 14e759434bec..c62da0be5ee5 100644 --- a/services/static-webserver/client/source/class/osparc/store/Products.js +++ b/services/static-webserver/client/source/class/osparc/store/Products.js @@ -125,16 +125,5 @@ qx.Class.define("osparc.store.Products", { getGroupedServicesUiConfig: function() { return this.__uiConfig["groupedServices"]; }, - - getSupportGroupId: function() { - return osparc.store.StaticInfo.getValue("supportStandardGroupId"); - }, - - amIASupportUser: function() { - const supportGroupId = this.getSupportGroupId(); - const groupsStore = osparc.store.Groups.getInstance(); - const myGroupIds = groupsStore.getOrganizationIds().map(gId => parseInt(gId)); - return (supportGroupId && myGroupIds.includes(supportGroupId)); - }, } }); diff --git a/services/static-webserver/client/source/class/osparc/store/Support.js b/services/static-webserver/client/source/class/osparc/store/Support.js index 58e71f81301d..3f2ea79dcebf 100644 --- a/services/static-webserver/client/source/class/osparc/store/Support.js +++ b/services/static-webserver/client/source/class/osparc/store/Support.js @@ -20,23 +20,25 @@ qx.Class.define("osparc.store.Support", { }, addSupportConversationsToMenu: function(menu) { - if (osparc.product.Utils.isSupportEnabled()) { - const supportCenterButton = new qx.ui.menu.Button().set({ - icon: "@FontAwesome5Regular/question-circle/16", - }); - const amISupporter = () => { - const isSupportUser = osparc.store.Products.getInstance().amIASupportUser(); - supportCenterButton.set({ - label: isSupportUser ? qx.locale.Manager.tr("Support Center") : qx.locale.Manager.tr("Support"), - }); - }; - amISupporter(); - osparc.store.Groups.getInstance().addListener("organizationsChanged", () => amISupporter()); - supportCenterButton.addListener("execute", () => { - osparc.support.SupportCenter.openWindow(); + const supportCenterButton = new qx.ui.menu.Button().set({ + icon: "@FontAwesome5Regular/question-circle/16", + visibility: "excluded", + }); + supportCenterButton.addListener("execute", () => osparc.support.SupportCenter.openWindow()); + menu.add(supportCenterButton); + + const updateSupportButton = () => { + const isSupportEnabled = osparc.store.Groups.getInstance().isSupportEnabled(); + const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser(); + supportCenterButton.set({ + visibility: isSupportEnabled ? "visible" : "excluded", + label: isSupportUser ? qx.locale.Manager.tr("Support Center") : qx.locale.Manager.tr("Support"), }); - menu.add(supportCenterButton); } + + updateSupportButton(); + osparc.store.Groups.getInstance().addListener("changeSupportGroup", () => updateSupportButton()); + osparc.store.Groups.getInstance().addListener("organizationsChanged", () => updateSupportButton()); }, addQuickStartToMenu: function(menu) { diff --git a/services/static-webserver/client/source/class/osparc/support/Conversation.js b/services/static-webserver/client/source/class/osparc/support/Conversation.js index 27d9ab07d505..3ff136a1336a 100644 --- a/services/static-webserver/client/source/class/osparc/support/Conversation.js +++ b/services/static-webserver/client/source/class/osparc/support/Conversation.js @@ -190,7 +190,7 @@ qx.Class.define("osparc.support.Conversation", { .then(studyData => { let isAlreadyShared = false; const accessRights = studyData["accessRights"]; - const supportGroupId = osparc.store.Products.getInstance().getSupportGroupId(); + const supportGroupId = osparc.store.Groups.getInstance().getSupportGroup().getGroupId(); if (supportGroupId && supportGroupId in accessRights) { isAlreadyShared = true; } else { @@ -207,7 +207,7 @@ qx.Class.define("osparc.support.Conversation", { __shareProjectWithSupport: function(e) { const share = e.getData(); - const supportGroupId = osparc.store.Products.getInstance().getSupportGroupId(); + const supportGroupId = osparc.store.Groups.getInstance().getSupportGroup().getGroupId(); const projectId = this.getConversation().getContextProjectId(); osparc.store.Study.getInstance().getOne(projectId) .then(studyData => { diff --git a/services/static-webserver/client/source/class/osparc/support/ConversationPage.js b/services/static-webserver/client/source/class/osparc/support/ConversationPage.js index ed1eb3404598..c85395200826 100644 --- a/services/static-webserver/client/source/class/osparc/support/ConversationPage.js +++ b/services/static-webserver/client/source/class/osparc/support/ConversationPage.js @@ -154,7 +154,7 @@ qx.Class.define("osparc.support.ConversationPage", { } const extraContextLayout = this.getChildControl("conversation-extra-layout"); - const amISupporter = osparc.store.Products.getInstance().amIASupportUser(); + const amISupporter = osparc.store.Groups.getInstance().amIASupportUser(); if (conversation) { const createExtraContextLabel = text => { return new qx.ui.basic.Label(text).set({ diff --git a/services/static-webserver/client/source/class/osparc/support/SupportCenter.js b/services/static-webserver/client/source/class/osparc/support/SupportCenter.js index 80ae521f7c27..2147c7de3c0c 100644 --- a/services/static-webserver/client/source/class/osparc/support/SupportCenter.js +++ b/services/static-webserver/client/source/class/osparc/support/SupportCenter.js @@ -92,7 +92,7 @@ qx.Class.define("osparc.support.SupportCenter", { rich: true, font: "text-14", }); - const isSupportUser = osparc.store.Products.getInstance().amIASupportUser(); + const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser(); control.set({ value: isSupportUser ? this.tr("Thanks for being here! Let's help every user feel supported.") : diff --git a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js index 5a2eb6c160bf..09ff26332b4c 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js @@ -20,7 +20,12 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { properties: { collabType: { - check: [0, 1, 2], // 0:all, 1:org, 2:user + check: [ + "everyone", // osparc.store.Groups.COLLAB_TYPE.EVERYONE + "support", // osparc.store.Groups.COLLAB_TYPE.SUPPORT + "organization", // osparc.store.Groups.COLLAB_TYPE.ORGANIZATION + "user", // osparc.store.Groups.COLLAB_TYPE.USER + ], event: "changeCollabType", nullable: true }, @@ -143,13 +148,13 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { if (value === null) { const collabType = this.getCollabType(); switch (collabType) { - case 0: + case osparc.store.Groups.COLLAB_TYPE.EVERYONE: value = "@FontAwesome5Solid/globe/28"; break; - case 1: + case osparc.store.Groups.COLLAB_TYPE.ORGANIZATION: value = "@FontAwesome5Solid/users/28"; break; - case 2: + case osparc.store.Groups.COLLAB_TYPE.USER: value = "@FontAwesome5Solid/user/28"; break; } diff --git a/services/static-webserver/client/source/class/osparc/ui/message/FlashMessageOEC.js b/services/static-webserver/client/source/class/osparc/ui/message/FlashMessageOEC.js index 30d59bb878ff..8fd9344fd097 100644 --- a/services/static-webserver/client/source/class/osparc/ui/message/FlashMessageOEC.js +++ b/services/static-webserver/client/source/class/osparc/ui/message/FlashMessageOEC.js @@ -28,7 +28,7 @@ qx.Class.define("osparc.ui.message.FlashMessageOEC", { construct: function(message, duration, supportId) { this.base(arguments, message, "ERROR", duration ? duration*2 : null); - if (osparc.product.Utils.isSupportEnabled()) { + if (osparc.store.Groups.getInstance().isSupportEnabled()) { this.getChildControl("contact-support"); } else { const oecAtom = this.getChildControl("oec-atom"); diff --git a/services/static-webserver/client/source/class/osparc/utils/Icons.js b/services/static-webserver/client/source/class/osparc/utils/Icons.js index 6fc5b52935b0..4fb976460836 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Icons.js +++ b/services/static-webserver/client/source/class/osparc/utils/Icons.js @@ -23,21 +23,21 @@ qx.Class.define("osparc.utils.Icons", { if (iconSize) { return "@FontAwesome5Solid/user/" + iconSize; } - return "@FontAwesome5Solid/user/14"; + return osparc.dashboard.CardBase.SHARED_USER; }, organization: function(iconSize) { if (iconSize) { return "@FontAwesome5Solid/users/" + iconSize; } - return "@FontAwesome5Solid/users/14"; + return osparc.dashboard.CardBase.SHARED_ORGS; }, everyone: function(iconSize) { if (iconSize) { return "@FontAwesome5Solid/globe/" + iconSize; } - return "@FontAwesome5Solid/globe/14"; + return osparc.dashboard.CardBase.SHARED_ALL; } } });