Skip to content

Commit dab82bc

Browse files
committed
support group
1 parent f437d19 commit dab82bc

File tree

9 files changed

+57
-37
lines changed

9 files changed

+57
-37
lines changed

services/static-webserver/client/source/class/osparc/data/model/Group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ qx.Class.define("osparc.data.model.Group", {
8282
},
8383

8484
groupType: {
85-
check: ["me", "organization", "productEveryone", "everyone"],
85+
check: ["me", "organization", "support", "productEveryone", "everyone"],
8686
nullable: false,
8787
init: null,
8888
},

services/static-webserver/client/source/class/osparc/product/Utils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,5 @@ qx.Class.define("osparc.product.Utils", {
417417
groupServices: function() {
418418
return Boolean(osparc.store.Products.getInstance().getGroupedServicesUiConfig());
419419
},
420-
421-
isSupportEnabled: function() {
422-
return Boolean(osparc.store.Products.getInstance().getSupportGroupId());
423-
},
424420
}
425421
});

services/static-webserver/client/source/class/osparc/store/Groups.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ qx.Class.define("osparc.store.Groups", {
3838

3939
supportGroup: {
4040
check: "osparc.data.model.Group",
41-
init: null // this will stay null for guest users
41+
init: null, // this will stay null for guest users
42+
event: "changeSupportGroup",
4243
},
4344

4445
organizations: {
@@ -67,6 +68,15 @@ qx.Class.define("osparc.store.Groups", {
6768
.then(resp => {
6869
const everyoneGroup = this.__addToGroupsCache(resp["all"], "everyone");
6970
const productEveryoneGroup = this.__addToGroupsCache(resp["product"], "productEveryone");
71+
let supportGroup = null;
72+
if ("support" && resp["support"]) {
73+
resp["support"]["accessRights"] = {
74+
"read": false,
75+
"write": false,
76+
"delete": false,
77+
};
78+
supportGroup = this.__addToGroupsCache(resp["support"], "support");
79+
}
7080
const groupMe = this.__addToGroupsCache(resp["me"], "me");
7181
const orgs = {};
7282
resp["organizations"].forEach(organization => {
@@ -75,6 +85,7 @@ qx.Class.define("osparc.store.Groups", {
7585
});
7686
this.setEveryoneGroup(everyoneGroup);
7787
this.setEveryoneProductGroup(productEveryoneGroup);
88+
this.setSupportGroup(supportGroup);
7889
this.setOrganizations(orgs);
7990
this.setGroupMe(groupMe);
8091
const myAuthData = osparc.auth.Data.getInstance();
@@ -182,6 +193,19 @@ qx.Class.define("osparc.store.Groups", {
182193
return everyoneGroups;
183194
},
184195

196+
isSupportEnabled: function() {
197+
return Boolean(this.getSupportGroup());
198+
},
199+
200+
amIASupportUser: function() {
201+
const supportGroup = this.getSupportGroup();
202+
if (supportGroup) {
203+
const myOrgIds = this.getOrganizationIds().map(gId => parseInt(gId));
204+
return myOrgIds.includes(supportGroup.getGroupId());
205+
}
206+
return false;
207+
},
208+
185209
getGroup: function(groupId) {
186210
const groups = [];
187211

services/static-webserver/client/source/class/osparc/store/Products.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ qx.Class.define("osparc.store.Products", {
2727
extend: qx.core.Object,
2828
type: "singleton",
2929

30+
properties: {
31+
supportEnabled: {
32+
check: "Boolean",
33+
nullable: false,
34+
init: false,
35+
event: "changeSupportEnabled",
36+
},
37+
},
38+
3039
members: {
3140
__uiConfig: null,
3241

@@ -125,16 +134,5 @@ qx.Class.define("osparc.store.Products", {
125134
getGroupedServicesUiConfig: function() {
126135
return this.__uiConfig["groupedServices"];
127136
},
128-
129-
getSupportGroupId: function() {
130-
return osparc.store.StaticInfo.getValue("supportStandardGroupId");
131-
},
132-
133-
amIASupportUser: function() {
134-
const supportGroupId = this.getSupportGroupId();
135-
const groupsStore = osparc.store.Groups.getInstance();
136-
const myGroupIds = groupsStore.getOrganizationIds().map(gId => parseInt(gId));
137-
return (supportGroupId && myGroupIds.includes(supportGroupId));
138-
},
139137
}
140138
});

services/static-webserver/client/source/class/osparc/store/Support.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ qx.Class.define("osparc.store.Support", {
2020
},
2121

2222
addSupportConversationsToMenu: function(menu) {
23-
if (osparc.product.Utils.isSupportEnabled()) {
24-
const supportCenterButton = new qx.ui.menu.Button().set({
25-
icon: "@FontAwesome5Regular/question-circle/16",
26-
});
27-
const amISupporter = () => {
28-
const isSupportUser = osparc.store.Products.getInstance().amIASupportUser();
29-
supportCenterButton.set({
30-
label: isSupportUser ? qx.locale.Manager.tr("Support Center") : qx.locale.Manager.tr("Support"),
31-
});
32-
};
33-
amISupporter();
34-
osparc.store.Groups.getInstance().addListener("organizationsChanged", () => amISupporter());
35-
supportCenterButton.addListener("execute", () => {
36-
osparc.support.SupportCenter.openWindow();
23+
const supportCenterButton = new qx.ui.menu.Button().set({
24+
icon: "@FontAwesome5Regular/question-circle/16",
25+
visibility: "excluded",
26+
});
27+
supportCenterButton.addListener("execute", () => osparc.support.SupportCenter.openWindow());
28+
menu.add(supportCenterButton);
29+
30+
const updateSupportButton = () => {
31+
const isSupportEnabled = osparc.store.Groups.getInstance().isSupportEnabled();
32+
const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser();
33+
supportCenterButton.set({
34+
visibility: isSupportEnabled ? "visible" : "excluded",
35+
label: isSupportUser ? qx.locale.Manager.tr("Support Center") : qx.locale.Manager.tr("Support"),
3736
});
38-
menu.add(supportCenterButton);
3937
}
38+
39+
updateSupportButton();
40+
osparc.store.Groups.getInstance().addListener("changeSupportGroup", () => updateSupportButton());
41+
osparc.store.Groups.getInstance().addListener("organizationsChanged", () => updateSupportButton());
4042
},
4143

4244
addQuickStartToMenu: function(menu) {

services/static-webserver/client/source/class/osparc/support/Conversation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ qx.Class.define("osparc.support.Conversation", {
190190
.then(studyData => {
191191
let isAlreadyShared = false;
192192
const accessRights = studyData["accessRights"];
193-
const supportGroupId = osparc.store.Products.getInstance().getSupportGroupId();
193+
const supportGroupId = osparc.store.Groups.getInstance().getSupportGroup().getGroupId();
194194
if (supportGroupId && supportGroupId in accessRights) {
195195
isAlreadyShared = true;
196196
} else {
@@ -207,7 +207,7 @@ qx.Class.define("osparc.support.Conversation", {
207207

208208
__shareProjectWithSupport: function(e) {
209209
const share = e.getData();
210-
const supportGroupId = osparc.store.Products.getInstance().getSupportGroupId();
210+
const supportGroupId = osparc.store.Groups.getInstance().getSupportGroup().getGroupId();
211211
const projectId = this.getConversation().getContextProjectId();
212212
osparc.store.Study.getInstance().getOne(projectId)
213213
.then(studyData => {

services/static-webserver/client/source/class/osparc/support/ConversationPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ qx.Class.define("osparc.support.ConversationPage", {
147147
}
148148

149149
const extraContextLabel = this.getChildControl("conversation-extra-content");
150-
const amISupporter = osparc.store.Products.getInstance().amIASupportUser();
150+
const amISupporter = osparc.store.Groups.getInstance().amIASupportUser();
151151
if (conversation && amISupporter) {
152152
const extraContext = conversation.getExtraContext();
153153
if (extraContext && Object.keys(extraContext).length) {

services/static-webserver/client/source/class/osparc/support/SupportCenter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ qx.Class.define("osparc.support.SupportCenter", {
9090
rich: true,
9191
font: "text-14",
9292
});
93-
const isSupportUser = osparc.store.Products.getInstance().amIASupportUser();
93+
const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser();
9494
control.set({
9595
value: isSupportUser ?
9696
this.tr("Thanks for being here! Let's help every user feel supported.") :

services/static-webserver/client/source/class/osparc/ui/message/FlashMessageOEC.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ qx.Class.define("osparc.ui.message.FlashMessageOEC", {
2828
construct: function(message, duration, supportId) {
2929
this.base(arguments, message, "ERROR", duration ? duration*2 : null);
3030

31-
if (osparc.product.Utils.isSupportEnabled()) {
31+
if (osparc.store.Groups.getInstance().isSupportEnabled()) {
3232
this.getChildControl("contact-support");
3333
} else {
3434
const oecAtom = this.getChildControl("oec-atom");

0 commit comments

Comments
 (0)