Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
},

statics: {
createLoginAnnouncement: function(title, text) {
createLoginAnnouncement: function(title, description) {
const loginAnnouncement = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({
backgroundColor: "strong-main",
alignX: "center",
Expand All @@ -46,22 +46,20 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
const titleLabel = new qx.ui.basic.Label().set({
value: title,
font: "text-16",
textColor: "white",
alignX: "center",
rich: true,
wrap: true
textAlign: "center",
rich: true
});
loginAnnouncement.add(titleLabel);
}

if (text) {
if (description) {
const descriptionLabel = new qx.ui.basic.Label().set({
value: text,
value: description,
font: "text-14",
textColor: "white",
alignX: "center",
rich: true,
wrap: true
textAlign: "center",
rich: true
});
loginAnnouncement.add(descriptionLabel);
}
Expand All @@ -75,16 +73,12 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {

__isValid: function(widgetType) {
const announcement = this.getAnnouncement();

const now = new Date();
if (
announcement &&
announcement.getProducts().includes(osparc.product.Utils.getProductName()) &&
announcement.getWidgets().includes(widgetType) &&
now > announcement.getStart() &&
now < announcement.getEnd()
) {
return true;
if (announcement) {
const now = new Date();
const validPeriod = now > announcement.getStart() && now < announcement.getEnd();
const validProduct = announcement.getProducts().includes(osparc.product.Utils.getProductName());
const validWidgetType = widgetType ? announcement.getWidgets().includes(widgetType) : true;
return validPeriod && validProduct && validWidgetType;
}
return false;
},
Expand Down Expand Up @@ -124,8 +118,10 @@ qx.Class.define("osparc.announcement.AnnouncementUIFactory", {
return;
}

let text = announcement.getTitle() + ": ";
text += announcement.getDescription();
let text = announcement.getTitle();
if (announcement.getDescription()) {
text += ": " + announcement.getDescription();
}

const ribbonAnnouncement = this.__ribbonAnnouncement = new osparc.notification.RibbonNotification(text, "announcement", true);
ribbonAnnouncement.announcementId = announcement.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ qx.Class.define("osparc.auth.ui.LoginView", {
this.addAt(announcementUIFactory.createLoginAnnouncement(), 0);
} else {
announcementUIFactory.addListenerOnce("changeAnnouncement", e => {
const announcement = e.getData();
if (announcement) {
if (announcementUIFactory.hasLoginAnnouncement()) {
this.addAt(announcementUIFactory.createLoginAnnouncement(), 0);
}
});
Expand Down
Loading