Skip to content

Commit 0f5cb2a

Browse files
committed
refactor
1 parent 4f61126 commit 0f5cb2a

File tree

2 files changed

+104
-55
lines changed

2 files changed

+104
-55
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.support.ConversationsPage", {
20+
extend: qx.ui.core.Widget,
21+
22+
construct: function() {
23+
this.base(arguments);
24+
25+
this._setLayout(new qx.ui.layout.VBox(15));
26+
27+
this.getChildControl("conversations-intro-text");
28+
this.getChildControl("conversations-list");
29+
this.getChildControl("ask-a-question-button");
30+
this.getChildControl("book-a-call-button");
31+
},
32+
33+
events: {
34+
"openConversation": "qx.event.type.Data",
35+
"createConversationBookCall": "qx.event.type.Event",
36+
},
37+
38+
members: {
39+
_createChildControlImpl: function(id) {
40+
let control;
41+
switch (id) {
42+
case "conversations-intro-text": {
43+
control = new qx.ui.basic.Label().set({
44+
rich: true,
45+
font: "text-14",
46+
});
47+
const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser();
48+
control.set({
49+
value: isSupportUser ?
50+
this.tr("Thanks for being here! Let's help every user feel supported.") :
51+
this.tr("Need help or want to share feedback? You're in the right place."),
52+
});
53+
this._add(control);
54+
break;
55+
}
56+
case "conversations-list": {
57+
control = new osparc.support.Conversations();
58+
control.addListener("openConversation", e => {
59+
const conversationId = e.getData();
60+
this.fireDataEvent("openConversation", conversationId);
61+
}, this);
62+
const scroll = new qx.ui.container.Scroll();
63+
scroll.add(control);
64+
this._add(scroll, {
65+
flex: 1,
66+
});
67+
break;
68+
}
69+
case "buttons-layout":
70+
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
71+
alignX: "center",
72+
}));
73+
this._add(control);
74+
break;
75+
case "ask-a-question-button":
76+
control = new osparc.ui.form.FetchButton(this.tr("Ask a Question")).set({
77+
appearance: "strong-button",
78+
allowGrowX: false,
79+
center: true,
80+
});
81+
control.addListener("execute", () => this.fireDataEvent("openConversation", null), this);
82+
this.getChildControl("buttons-layout").add(control);
83+
break;
84+
case "book-a-call-button":
85+
control = new osparc.ui.form.FetchButton(this.tr("Book a Call")).set({
86+
appearance: "strong-button",
87+
allowGrowX: false,
88+
center: true,
89+
});
90+
control.addListener("execute", () => this.fireEvent("createConversationBookCall"), this);
91+
this.getChildControl("buttons-layout").add(control);
92+
break;
93+
}
94+
return control || this.base(arguments, id);
95+
},
96+
}
97+
});

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

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ qx.Class.define("osparc.support.SupportCenter", {
3535
showClose: true,
3636
});
3737

38-
this.getChildControl("conversations-intro-text");
39-
this.getChildControl("conversations-list");
40-
this.getChildControl("ask-a-question-button");
41-
this.getChildControl("book-a-call-button");
38+
this.getChildControl("conversations-page");
39+
this.getChildControl("conversation-page");
4240
},
4341

4442
statics: {
@@ -83,60 +81,14 @@ qx.Class.define("osparc.support.SupportCenter", {
8381
flex: 1
8482
});
8583
break;
86-
case "conversations-layout":
87-
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(15));
88-
this.getChildControl("stack-layout").add(control);
89-
break;
90-
case "conversations-intro-text": {
91-
control = new qx.ui.basic.Label().set({
92-
rich: true,
93-
font: "text-14",
94-
});
95-
const isSupportUser = osparc.store.Groups.getInstance().amIASupportUser();
96-
control.set({
97-
value: isSupportUser ?
98-
this.tr("Thanks for being here! Let's help every user feel supported.") :
99-
this.tr("Need help or want to share feedback? You're in the right place."),
100-
});
101-
this.getChildControl("conversations-layout").add(control);
102-
break;
103-
}
104-
case "conversations-list": {
105-
control = new osparc.support.Conversations();
84+
case "conversations-page":
85+
control = new osparc.support.ConversationsPage();
10686
control.addListener("openConversation", e => {
10787
const conversationId = e.getData();
10888
this.openConversation(conversationId);
10989
}, this);
110-
const scroll = new qx.ui.container.Scroll();
111-
scroll.add(control);
112-
this.getChildControl("conversations-layout").add(scroll, {
113-
flex: 1,
114-
});
115-
break;
116-
}
117-
case "buttons-layout":
118-
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10).set({
119-
alignX: "center",
120-
}));
121-
this.getChildControl("conversations-layout").add(control);
122-
break;
123-
case "ask-a-question-button":
124-
control = new osparc.ui.form.FetchButton(this.tr("Ask a Question")).set({
125-
appearance: "strong-button",
126-
allowGrowX: false,
127-
center: true,
128-
});
129-
control.addListener("execute", () => this.openConversation(null), this);
130-
this.getChildControl("buttons-layout").add(control);
131-
break;
132-
case "book-a-call-button":
133-
control = new osparc.ui.form.FetchButton(this.tr("Book a Call")).set({
134-
appearance: "strong-button",
135-
allowGrowX: false,
136-
center: true,
137-
});
138-
control.addListener("execute", () => this.createConversationBookCall(null), this);
139-
this.getChildControl("buttons-layout").add(control);
90+
control.addListener("createConversationBookCall", () => this.createConversationBookCall(), this);
91+
this.getChildControl("stack-layout").add(control);
14092
break;
14193
case "conversation-page":
14294
control = new osparc.support.ConversationPage();
@@ -148,7 +100,7 @@ qx.Class.define("osparc.support.SupportCenter", {
148100
},
149101

150102
__showConversations: function() {
151-
this.getChildControl("stack-layout").setSelection([this.getChildControl("conversations-layout")]);
103+
this.getChildControl("stack-layout").setSelection([this.getChildControl("conversations-page")]);
152104
},
153105

154106
__showConversation: function() {

0 commit comments

Comments
 (0)