Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
navbar_alerts: Delay showing "Complete the organization profile" banner.
Joeluteeb7826416200
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex 5fc916383a5..676e62d7ddf 100644--- a/api_docs/changelog.md+++ b/api_docs/changelog.md@@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.## Changes in Zulip 8.0+**Feature level 203**++* [`POST /register`](/api/register-queue): Add+ `realm_date_created` field to realm data.+**Feature level 202*** [`PATCH /realm/linkifiers`](/api/reorder-linkifiers): Added new endpointdiff --git a/web/src/navbar_alerts.js b/web/src/navbar_alerts.jsindex 4aa9e088a4f..c292f39ed75 100644--- a/web/src/navbar_alerts.js+++ b/web/src/navbar_alerts.js@@ -15,6 +15,7 @@ import * as keydown_util from "./keydown_util";import {localstorage} from "./localstorage";import * as notifications from "./notifications";import {page_params} from "./page_params";+import {should_display_profile_incomplete_alert} from "./timerender";import * as unread from "./unread";import * as unread_ops from "./unread_ops";import * as unread_ui from "./unread_ui";@@ -96,6 +97,9 @@ export function check_profile_incomplete() {if (!page_params.is_admin) {return false;}+ if (!should_display_profile_incomplete_alert(page_params.realm_date_created)) {+ return false;+ }// Eventually, we might also check page_params.realm_icon_source,// but it feels too aggressive to ask users to do change thatdiff --git a/web/src/timerender.ts b/web/src/timerender.tsindex 1edde3402e8..c8d2569b6ca 100644--- a/web/src/timerender.ts+++ b/web/src/timerender.ts@@ -490,3 +490,14 @@ export function get_time_limit_setting_in_appropriate_unit(const time_limit_in_days = Math.floor(time_limit_in_hours / 24);return {value: time_limit_in_days, unit: "day"};}++export function should_display_profile_incomplete_alert(timestamp: number): boolean {+ const today = new Date(Date.now());+ const time = new Date(timestamp);+ const days_old = differenceInCalendarDays(today, time);++ if (days_old >= 15) {+ return true;+ }+ return false;+}diff --git a/web/tests/navbar_alerts.test.js b/web/tests/navbar_alerts.test.jsindex 4aebaa7e8e1..5d3c52379c9 100644--- a/web/tests/navbar_alerts.test.js+++ b/web/tests/navbar_alerts.test.js@@ -12,6 +12,7 @@ page_params.is_spectator = false;const notifications = mock_esm("../src/notifications");const util = mock_esm("../src/util");+const timerender = mock_esm("../src/timerender");const {localstorage} = zrequire("localstorage");const navbar_alerts = zrequire("navbar_alerts");@@ -62,7 +63,10 @@ test("allow_notification_alert", ({disallow, override}) => {assert.equal(navbar_alerts.should_show_notifications(ls), false);});-test("profile_incomplete_alert", () => {+test("profile_incomplete_alert", ({override}) => {+ // Don't test time related conditions+ override(timerender, "should_display_profile_incomplete_alert", () => true);+// Show alert.page_params.is_admin = true;page_params.realm_description = "Organization imported from Slack!";diff --git a/web/tests/timerender.test.js b/web/tests/timerender.test.jsindex 809f08a7de3..3eed481ac56 100644--- a/web/tests/timerender.test.js+++ b/web/tests/timerender.test.js@@ -597,3 +597,17 @@ run_test("set_full_datetime", () => {expected = "10:52 AM";assert.equal(time_str, expected);});++run_test("should_display_profile_incomplete_alert", () => {+ // Organization created < 15 days ago+ let realm_date_created = new Date();+ realm_date_created.setDate(realm_date_created.getDate() - 5);++ assert.equal(timerender.should_display_profile_incomplete_alert(realm_date_created), false);++ // Organization created > 15 days ago+ realm_date_created = new Date();+ realm_date_created.setDate(realm_date_created.getDate() - 15);++ assert.equal(timerender.should_display_profile_incomplete_alert(realm_date_created), true);+});diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex 8020d6c9efa..27a58887442 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -359,6 +359,7 @@ def fetch_initial_state_data(state["demo_organization_scheduled_deletion_date"] = datetime_to_timestamp(realm.demo_organization_scheduled_deletion_date)+ state["realm_date_created"] = datetime_to_timestamp(realm.date_created)# Presence system parameters for client behavior.state["server_presence_ping_interval_seconds"] = settings.PRESENCE_PING_INTERVAL_SECSdiff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 8121958f088..3165f2e8db3 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -11195,6 +11195,13 @@ paths:type: stringdescription: |The name of the custom profile field type.+ realm_date_created:+ type: integer+ description: |+ The UNIX timestamp (UTC) for when the organization was+ created.++ **Changes**: New in Zulip 8.0 (feature level 203).demo_organization_scheduled_deletion_date:type: integerdescription: |diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex 98dcea61d77..b1521e194e3 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -118,6 +118,7 @@ class HomeTest(ZulipTestCase):"realm_create_private_stream_policy","realm_create_public_stream_policy","realm_create_web_public_stream_policy",+ "realm_date_created","realm_default_code_block_language","realm_default_external_accounts","realm_default_language",