Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
banners: Redesign demo organization deadline navbar banner.
Sayam Samal9664b1b550a2
diff --git a/web/src/navbar_alerts.ts b/web/src/navbar_alerts.tsindex a04a7357ddb..67ebfc14c37 100644--- a/web/src/navbar_alerts.ts+++ b/web/src/navbar_alerts.ts@@ -1,8 +1,8 @@import {addDays} from "date-fns";+import Handlebars from "handlebars";import $ from "jquery";import assert from "minimalistic-assert";-import render_demo_organization_deadline_content from "../templates/navbar_alerts/demo_organization_deadline.hbs";import render_empty_required_profile_fields from "../templates/navbar_alerts/empty_required_profile_fields.hbs";import render_insecure_desktop_app_alert_content from "../templates/navbar_alerts/insecure_desktop_app.hbs";import render_navbar_alert_wrapper from "../templates/navbar_alerts/navbar_alert_wrapper.hbs";@@ -15,7 +15,7 @@ import type {AlertBanner} from "./banners.ts";import * as channel from "./channel.ts";import * as desktop_notifications from "./desktop_notifications.ts";import * as feedback_widget from "./feedback_widget.ts";-import {$t} from "./i18n.ts";+import {$t, $t_html} from "./i18n.ts";import * as keydown_util from "./keydown_util.ts";import type {LocalStorage} from "./localstorage.ts";import {localstorage} from "./localstorage.ts";@@ -263,18 +263,37 @@ const bankruptcy_banner = (): AlertBanner => {};};+const demo_organization_deadline_banner = (): AlertBanner => {+ const days_remaining = get_demo_organization_deadline_days_remaining();+ return {+ process: "demo-organization-deadline",+ intent: days_remaining <= 7 ? "danger" : "info",+ label: new Handlebars.SafeString(+ $t_html(+ {+ defaultMessage:+ "This <z-demo-link>demo organization</z-demo-link> will be automatically deleted in {days_remaining} days, unless it's <z-convert-link>converted into a permanent organization</z-convert-link>.",+ },+ {+ "z-demo-link": (content_html) =>+ `<a class="banner__link" href="https://zulip.com/help/demo-organizations" target="_blank" rel="noopener noreferrer">${content_html.join("")}</a>`,+ "z-convert-link": (content_html) =>+ `<a class="banner__link" href="https://zulip.com/help/demo-organizations#convert-a-demo-organization-to-a-permanent-organization" target="_blank" rel="noopener noreferrer">${content_html.join("")}</a>`,+ days_remaining,+ },+ ),+ ),+ buttons: [],+ close_button: true,+ custom_classes: "navbar-alert-banner",+ };+};+export function initialize(): void {const ls = localstorage();const browser_time_zone = timerender.browser_time_zone();if (realm.demo_organization_scheduled_deletion_date) {- const days_remaining = get_demo_organization_deadline_days_remaining();- open({- data_process: "demo-organization-deadline",- custom_class: days_remaining <= 7 ? "red" : "",- rendered_alert_content_html: render_demo_organization_deadline_content({- days_remaining,- }),- });+ banners.open(demo_organization_deadline_banner(), $("#navbar_alerts_wrapper"));} else if (page_params.insecure_desktop_app) {open({data_process: "insecure-desktop-app",diff --git a/web/templates/navbar_alerts/demo_organization_deadline.hbs b/web/templates/navbar_alerts/demo_organization_deadline.hbsdeleted file mode 100644index ee79d4bcd26..00000000000--- a/web/templates/navbar_alerts/demo_organization_deadline.hbs+++ /dev/null@@ -1,7 +0,0 @@-<div data-step="1">- {{#tr}}- This is a <z-link-general>demo organization</z-link-general> and will be automatically deleted in {days_remaining} days, unless it's <z-link-convert>converted into a permanent organization</z-link-convert>.- {{#*inline "z-link-general"}}<a class="alert-link" href="/help/demo-organizations" target="_blank" rel="noopener noreferrer" role="button" tabindex=0>{{> @partial-block}}</a>{{/inline}}- {{#*inline "z-link-convert"}}<a class="alert-link" href="/help/demo-organizations#convert-a-demo-organization-to-a-permanent-organization" target="_blank" rel="noopener noreferrer" role="button" tabindex=0>{{> @partial-block}}</a>{{/inline}}- {{/tr}}-</div>diff --git a/web/tests/navbar_alerts.test.cjs b/web/tests/navbar_alerts.test.cjsindex a331e90a519..b8bef1fc4c9 100644--- a/web/tests/navbar_alerts.test.cjs+++ b/web/tests/navbar_alerts.test.cjs@@ -129,24 +129,15 @@ test("server_upgrade_alert hide_duration_expired", ({override}) => {assert.equal(navbar_alerts.should_show_server_upgrade_notification(ls), false);});-test("demo_organization_days_remaining", ({override}) => {- const start_time = new Date(1620327447050); // Thursday 06/5/2021 07:02:27 AM (UTC+0)-- const high_priority_deadline = addDays(start_time, 5);- override(- realm,- "demo_organization_scheduled_deletion_date",- Math.trunc(high_priority_deadline / 1000),- );+test("get_demo_organization_deadline_days_remaining", ({override}) => {+ const start_time = new Date("2024-01-01T10:00:00.000Z"); // Wednesday 1/1/2024 10:00:00 AM (UTC+0)override(Date, "now", () => start_time);- assert.equal(navbar_alerts.get_demo_organization_deadline_days_remaining(), 5);- const low_priority_deadline = addDays(start_time, 10);+ const demo_organization_scheduled_deletion_date = addDays(start_time, 7); // Wednesday 1/8/2024 10:00:00 AM (UTC+0)override(realm,"demo_organization_scheduled_deletion_date",- Math.trunc(low_priority_deadline / 1000),+ Math.trunc(demo_organization_scheduled_deletion_date / 1000),);- override(Date, "now", () => start_time);- assert.equal(navbar_alerts.get_demo_organization_deadline_days_remaining(), 10);+ assert.equal(navbar_alerts.get_demo_organization_deadline_days_remaining(), 7);});