Skip to content

Commit 1c2cae7

Browse files
odeimaizmatusdrobuliak66
authored andcommitted
🐛 [Frontend] Announcements: allow in ribbon only (#6440)
1 parent 44480cd commit 1c2cae7

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

services/static-webserver/client/source/class/osparc/announcement/AnnouncementUIFactory.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
3030
},
3131

3232
statics: {
33-
createLoginAnnouncement: function(title, text) {
33+
createLoginAnnouncement: function(title, description) {
3434
const loginAnnouncement = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({
3535
backgroundColor: "strong-main",
3636
alignX: "center",
@@ -46,22 +46,20 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
4646
const titleLabel = new qx.ui.basic.Label().set({
4747
value: title,
4848
font: "text-16",
49-
textColor: "white",
5049
alignX: "center",
51-
rich: true,
52-
wrap: true
50+
textAlign: "center",
51+
rich: true
5352
});
5453
loginAnnouncement.add(titleLabel);
5554
}
5655

57-
if (text) {
56+
if (description) {
5857
const descriptionLabel = new qx.ui.basic.Label().set({
59-
value: text,
58+
value: description,
6059
font: "text-14",
61-
textColor: "white",
6260
alignX: "center",
63-
rich: true,
64-
wrap: true
61+
textAlign: "center",
62+
rich: true
6563
});
6664
loginAnnouncement.add(descriptionLabel);
6765
}
@@ -75,16 +73,12 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
7573

7674
__isValid: function(widgetType) {
7775
const announcement = this.getAnnouncement();
78-
79-
const now = new Date();
80-
if (
81-
announcement &&
82-
announcement.getProducts().includes(osparc.product.Utils.getProductName()) &&
83-
announcement.getWidgets().includes(widgetType) &&
84-
now > announcement.getStart() &&
85-
now < announcement.getEnd()
86-
) {
87-
return true;
76+
if (announcement) {
77+
const now = new Date();
78+
const validPeriod = now > announcement.getStart() && now < announcement.getEnd();
79+
const validProduct = announcement.getProducts().includes(osparc.product.Utils.getProductName());
80+
const validWidgetType = widgetType ? announcement.getWidgets().includes(widgetType) : true;
81+
return validPeriod && validProduct && validWidgetType;
8882
}
8983
return false;
9084
},
@@ -124,8 +118,10 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
124118
return;
125119
}
126120

127-
let text = announcement.getTitle() + ": ";
128-
text += announcement.getDescription();
121+
let text = announcement.getTitle();
122+
if (announcement.getDescription()) {
123+
text += ": " + announcement.getDescription();
124+
}
129125

130126
const ribbonAnnouncement = this.__ribbonAnnouncement = new osparc.notification.RibbonNotification(text, "announcement", true);
131127
ribbonAnnouncement.announcementId = announcement.getId();

services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ qx.Class.define("osparc.auth.ui.LoginView", {
4545
this.addAt(announcementUIFactory.createLoginAnnouncement(), 0);
4646
} else {
4747
announcementUIFactory.addListenerOnce("changeAnnouncement", e => {
48-
const announcement = e.getData();
49-
if (announcement) {
48+
if (announcementUIFactory.hasLoginAnnouncement()) {
5049
this.addAt(announcementUIFactory.createLoginAnnouncement(), 0);
5150
}
5251
});

0 commit comments

Comments
 (0)