Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Frontend] Announcements: allow in ribbon only #6440

Merged
merged 11 commits into from
Sep 25, 2024
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