mirror of https://github.com/zulip/zulip.git
navbar_alerts: Delay showing "Complete the organization profile" banner.
Currently, we are displaying the "Complete the organization profile" banner immediately after the organization was created. It's important to strongly encourage orgs to configure their profile, so we should delay showing the banner if the profile has not been configured after 15 days. Thus also allows the users to check out Zulip and see how it works before configuring the organization settings. Fixes: #24122.
This commit is contained in:
parent
255e382750
commit
eb78264162
|
@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
## Changes in Zulip 8.0
|
## Changes in Zulip 8.0
|
||||||
|
|
||||||
|
**Feature level 203**
|
||||||
|
|
||||||
|
* [`POST /register`](/api/register-queue): Add
|
||||||
|
`realm_date_created` field to realm data.
|
||||||
|
|
||||||
**Feature level 202**
|
**Feature level 202**
|
||||||
|
|
||||||
* [`PATCH /realm/linkifiers`](/api/reorder-linkifiers): Added new endpoint
|
* [`PATCH /realm/linkifiers`](/api/reorder-linkifiers): Added new endpoint
|
||||||
|
|
|
@ -15,6 +15,7 @@ import * as keydown_util from "./keydown_util";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
import * as notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
|
import {should_display_profile_incomplete_alert} from "./timerender";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
import * as unread_ui from "./unread_ui";
|
import * as unread_ui from "./unread_ui";
|
||||||
|
@ -96,6 +97,9 @@ export function check_profile_incomplete() {
|
||||||
if (!page_params.is_admin) {
|
if (!page_params.is_admin) {
|
||||||
return false;
|
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,
|
// Eventually, we might also check page_params.realm_icon_source,
|
||||||
// but it feels too aggressive to ask users to do change that
|
// but it feels too aggressive to ask users to do change that
|
||||||
|
|
|
@ -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);
|
const time_limit_in_days = Math.floor(time_limit_in_hours / 24);
|
||||||
return {value: time_limit_in_days, unit: "day"};
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ page_params.is_spectator = false;
|
||||||
|
|
||||||
const notifications = mock_esm("../src/notifications");
|
const notifications = mock_esm("../src/notifications");
|
||||||
const util = mock_esm("../src/util");
|
const util = mock_esm("../src/util");
|
||||||
|
const timerender = mock_esm("../src/timerender");
|
||||||
|
|
||||||
const {localstorage} = zrequire("localstorage");
|
const {localstorage} = zrequire("localstorage");
|
||||||
const navbar_alerts = zrequire("navbar_alerts");
|
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);
|
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.
|
// Show alert.
|
||||||
page_params.is_admin = true;
|
page_params.is_admin = true;
|
||||||
page_params.realm_description = "Organization imported from Slack!";
|
page_params.realm_description = "Organization imported from Slack!";
|
||||||
|
|
|
@ -597,3 +597,17 @@ run_test("set_full_datetime", () => {
|
||||||
expected = "10:52 AM";
|
expected = "10:52 AM";
|
||||||
assert.equal(time_str, expected);
|
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);
|
||||||
|
});
|
||||||
|
|
|
@ -359,6 +359,7 @@ def fetch_initial_state_data(
|
||||||
state["demo_organization_scheduled_deletion_date"] = datetime_to_timestamp(
|
state["demo_organization_scheduled_deletion_date"] = datetime_to_timestamp(
|
||||||
realm.demo_organization_scheduled_deletion_date
|
realm.demo_organization_scheduled_deletion_date
|
||||||
)
|
)
|
||||||
|
state["realm_date_created"] = datetime_to_timestamp(realm.date_created)
|
||||||
|
|
||||||
# Presence system parameters for client behavior.
|
# Presence system parameters for client behavior.
|
||||||
state["server_presence_ping_interval_seconds"] = settings.PRESENCE_PING_INTERVAL_SECS
|
state["server_presence_ping_interval_seconds"] = settings.PRESENCE_PING_INTERVAL_SECS
|
||||||
|
|
|
@ -11195,6 +11195,13 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
The name of the custom profile field type.
|
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:
|
demo_organization_scheduled_deletion_date:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -118,6 +118,7 @@ class HomeTest(ZulipTestCase):
|
||||||
"realm_create_private_stream_policy",
|
"realm_create_private_stream_policy",
|
||||||
"realm_create_public_stream_policy",
|
"realm_create_public_stream_policy",
|
||||||
"realm_create_web_public_stream_policy",
|
"realm_create_web_public_stream_policy",
|
||||||
|
"realm_date_created",
|
||||||
"realm_default_code_block_language",
|
"realm_default_code_block_language",
|
||||||
"realm_default_external_accounts",
|
"realm_default_external_accounts",
|
||||||
"realm_default_language",
|
"realm_default_language",
|
||||||
|
|
Loading…
Reference in New Issue