2021-08-31 12:45:21 +02:00
|
|
|
import Handlebars from "handlebars/runtime";
|
|
|
|
|
|
|
|
import {$t, $t_html} from "./i18n";
|
2021-03-25 22:35:45 +01:00
|
|
|
import {page_params} from "./page_params";
|
2021-08-26 21:03:27 +02:00
|
|
|
import type {RealmDefaultSettingsType} from "./realm_user_settings_defaults";
|
2021-08-27 15:46:23 +02:00
|
|
|
import type {UserSettingsType} from "./user_settings";
|
2021-03-25 21:38:40 +01:00
|
|
|
|
2020-02-21 14:26:11 +01:00
|
|
|
/*
|
|
|
|
This file contains translations between the integer values used in
|
|
|
|
the Zulip API to describe values in dropdowns, radio buttons, and
|
|
|
|
similar widgets and the user-facing strings that should be used to
|
|
|
|
describe them, as well as data details like sort orders that may
|
|
|
|
be useful for some widgets.
|
|
|
|
|
|
|
|
We plan to eventually transition much of this file to have a more
|
|
|
|
standard format and then to be populated using data sent from the
|
|
|
|
Zulip server in `page_params`, so that the data is available for
|
|
|
|
other parts of the ecosystem to use (including the mobile apps and
|
|
|
|
API documentation) without a ton of copying.
|
|
|
|
*/
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const demote_inactive_streams_values = {
|
2020-02-21 14:26:11 +01:00
|
|
|
automatic: {
|
|
|
|
code: 1,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Automatic"}),
|
2020-02-21 14:26:11 +01:00
|
|
|
},
|
|
|
|
always: {
|
|
|
|
code: 2,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Always"}),
|
2020-02-21 14:26:11 +01:00
|
|
|
},
|
|
|
|
never: {
|
|
|
|
code: 3,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Never"}),
|
2020-02-21 14:26:11 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-03-10 13:56:10 +01:00
|
|
|
export const default_view_values = {
|
|
|
|
recent_topics: {
|
|
|
|
code: "recent_topics",
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Recent topics"}),
|
2021-03-10 13:56:10 +01:00
|
|
|
},
|
|
|
|
all_messages: {
|
|
|
|
code: "all_messages",
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "All messages"}),
|
2021-03-10 13:56:10 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const color_scheme_values = {
|
2020-05-16 13:13:59 +02:00
|
|
|
automatic: {
|
|
|
|
code: 1,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Automatic"}),
|
2020-05-16 13:13:59 +02:00
|
|
|
},
|
|
|
|
night: {
|
|
|
|
code: 2,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Night mode"}),
|
2020-05-16 13:13:59 +02:00
|
|
|
},
|
|
|
|
day: {
|
|
|
|
code: 3,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Day mode"}),
|
2020-05-16 13:13:59 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const twenty_four_hour_time_values = {
|
2020-02-21 14:26:11 +01:00
|
|
|
twenty_four_hour_clock: {
|
|
|
|
value: true,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "24-hour clock (17:00)"}),
|
2020-02-21 14:26:11 +01:00
|
|
|
},
|
|
|
|
twelve_hour_clock: {
|
|
|
|
value: false,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "12-hour clock (5:00 PM)"}),
|
2020-02-21 14:26:11 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-07-23 19:42:57 +02:00
|
|
|
export interface DisplaySettings {
|
|
|
|
settings: {
|
|
|
|
user_display_settings: string[];
|
|
|
|
};
|
|
|
|
render_only: {
|
|
|
|
high_contrast_mode: boolean;
|
|
|
|
dense_mode: boolean;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const get_all_display_settings = (): DisplaySettings => ({
|
2020-02-21 14:26:11 +01:00
|
|
|
settings: {
|
|
|
|
user_display_settings: [
|
|
|
|
"dense_mode",
|
|
|
|
"high_contrast_mode",
|
|
|
|
"left_side_userlist",
|
|
|
|
"fluid_layout_width",
|
2021-10-21 14:11:19 +02:00
|
|
|
"starred_message_counts",
|
2020-02-21 14:26:11 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
render_only: {
|
|
|
|
high_contrast_mode: page_params.development_environment,
|
|
|
|
dense_mode: page_params.development_environment,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const email_address_visibility_values = {
|
2020-02-21 20:46:35 +01:00
|
|
|
everyone: {
|
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators, members and guests"}),
|
2020-02-21 20:46:35 +01:00
|
|
|
},
|
2021-03-26 20:38:59 +01:00
|
|
|
// // Backend support for this configuration is not available yet.
|
2020-02-21 20:46:35 +01:00
|
|
|
// admins_and_members: {
|
|
|
|
// code: 2,
|
2021-04-10 10:09:54 +02:00
|
|
|
// description: $t({defaultMessage: "Members and admins"}),
|
2020-02-21 20:46:35 +01:00
|
|
|
// },
|
2021-05-21 18:07:30 +02:00
|
|
|
moderators: {
|
|
|
|
code: 5,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
2020-02-21 20:46:35 +01:00
|
|
|
admins_only: {
|
|
|
|
code: 3,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Admins only"}),
|
2020-02-21 20:46:35 +01:00
|
|
|
},
|
2020-03-07 01:15:34 +01:00
|
|
|
nobody: {
|
|
|
|
code: 4,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Nobody"}),
|
2020-03-07 01:15:34 +01:00
|
|
|
},
|
2020-02-21 20:46:35 +01:00
|
|
|
};
|
2020-02-21 20:58:17 +01:00
|
|
|
|
2021-04-28 20:39:24 +02:00
|
|
|
export const common_policy_values = {
|
2020-02-21 20:58:17 +01:00
|
|
|
by_admins_only: {
|
|
|
|
order: 1,
|
|
|
|
code: 2,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Admins"}),
|
2020-02-21 20:58:17 +01:00
|
|
|
},
|
2021-04-21 21:43:27 +02:00
|
|
|
by_moderators_only: {
|
2020-02-21 20:58:17 +01:00
|
|
|
order: 2,
|
2021-04-21 21:43:27 +02:00
|
|
|
code: 4,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
|
|
|
by_full_members: {
|
|
|
|
order: 3,
|
2020-02-21 20:58:17 +01:00
|
|
|
code: 3,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
2020-02-21 20:58:17 +01:00
|
|
|
},
|
|
|
|
by_members: {
|
2021-04-21 21:43:27 +02:00
|
|
|
order: 4,
|
2020-02-21 20:58:17 +01:00
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and members"}),
|
2020-02-21 20:58:17 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-07-18 18:18:28 +02:00
|
|
|
export const invite_to_realm_policy_values = {
|
|
|
|
nobody: {
|
|
|
|
order: 1,
|
|
|
|
code: 6,
|
|
|
|
description: $t({defaultMessage: "Nobody"}),
|
|
|
|
},
|
|
|
|
by_admins_only: {
|
|
|
|
order: 2,
|
|
|
|
code: 2,
|
|
|
|
description: $t({defaultMessage: "Admins"}),
|
|
|
|
},
|
|
|
|
by_moderators_only: {
|
|
|
|
order: 3,
|
|
|
|
code: 4,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
|
|
|
by_full_members: {
|
|
|
|
order: 4,
|
|
|
|
code: 3,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
2021-07-18 18:18:28 +02:00
|
|
|
},
|
|
|
|
by_members: {
|
|
|
|
order: 5,
|
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and members"}),
|
2021-07-18 18:18:28 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const private_message_policy_values = {
|
2020-02-21 21:42:27 +01:00
|
|
|
by_anyone: {
|
|
|
|
order: 1,
|
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators, members and guests"}),
|
2020-02-21 21:42:27 +01:00
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
order: 2,
|
|
|
|
code: 2,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Private messages disabled"}),
|
2020-02-21 21:42:27 +01:00
|
|
|
},
|
|
|
|
};
|
2020-02-21 21:45:34 +01:00
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const wildcard_mention_policy_values = {
|
2020-09-14 19:26:42 +02:00
|
|
|
by_everyone: {
|
|
|
|
order: 1,
|
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators, members and guests"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
},
|
|
|
|
by_members: {
|
|
|
|
order: 2,
|
|
|
|
code: 2,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and members"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
},
|
|
|
|
by_full_members: {
|
|
|
|
order: 3,
|
|
|
|
code: 3,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
},
|
2021-05-02 10:11:02 +02:00
|
|
|
by_moderators_only: {
|
|
|
|
order: 4,
|
|
|
|
code: 7,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
2020-09-14 19:26:42 +02:00
|
|
|
// Until we add stream administrators, we mislabel this choice
|
|
|
|
// (which we intend to be the long-term default) as "Admins only"
|
|
|
|
// and don't offer the long-term "Admins only" option.
|
|
|
|
by_stream_admins_only: {
|
2021-05-02 10:11:02 +02:00
|
|
|
order: 5,
|
2020-09-14 19:26:42 +02:00
|
|
|
code: 4,
|
2021-04-10 10:09:54 +02:00
|
|
|
// description: $t({defaultMessage: "Organization and stream admins"}),
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Admins only"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
},
|
|
|
|
// by_admins_only: {
|
|
|
|
// order: 5,
|
|
|
|
// code: 5,
|
2021-04-10 10:09:54 +02:00
|
|
|
// description: $t({defaultMessage: "Admins only"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
// },
|
|
|
|
nobody: {
|
|
|
|
order: 6,
|
|
|
|
code: 6,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Nobody"}),
|
2020-09-14 19:26:42 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-05-26 12:21:37 +02:00
|
|
|
export const common_message_policy_values = {
|
|
|
|
by_everyone: {
|
|
|
|
order: 1,
|
|
|
|
code: 5,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators, members and guests"}),
|
2021-05-26 12:21:37 +02:00
|
|
|
},
|
2021-05-26 21:20:11 +02:00
|
|
|
by_members: {
|
2021-05-26 12:21:37 +02:00
|
|
|
order: 2,
|
2021-05-26 21:20:11 +02:00
|
|
|
code: 1,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and members"}),
|
2021-05-26 21:20:11 +02:00
|
|
|
},
|
|
|
|
by_full_members: {
|
|
|
|
order: 3,
|
|
|
|
code: 3,
|
2021-08-23 14:58:02 +02:00
|
|
|
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
2021-05-26 21:20:11 +02:00
|
|
|
},
|
|
|
|
by_moderators_only: {
|
|
|
|
order: 4,
|
|
|
|
code: 4,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
|
|
|
by_admins_only: {
|
|
|
|
order: 5,
|
2021-05-26 12:21:37 +02:00
|
|
|
code: 2,
|
|
|
|
description: $t({defaultMessage: "Admins only"}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-02-09 05:23:25 +01:00
|
|
|
const time_limit_dropdown_values = new Map([
|
2020-07-15 00:34:28 +02:00
|
|
|
[
|
|
|
|
"any_time",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t({defaultMessage: "Any time"}),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 0,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"never",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t({defaultMessage: "Never"}),
|
2020-07-15 00:34:28 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_two_min",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "2 minutes"})},
|
|
|
|
),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 2 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_ten_min",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "10 minutes"})},
|
|
|
|
),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 10 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_hour",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 hour"})},
|
|
|
|
),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_day",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 day"})},
|
|
|
|
),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_week",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 week"})},
|
|
|
|
),
|
2020-07-15 00:34:28 +02:00
|
|
|
seconds: 7 * 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"custom_limit",
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
text: $t({defaultMessage: "Up to N minutes after posting"}),
|
2020-07-15 00:34:28 +02:00
|
|
|
},
|
|
|
|
],
|
2020-02-09 05:23:25 +01:00
|
|
|
]);
|
2021-02-10 17:14:06 +01:00
|
|
|
export const msg_edit_limit_dropdown_values = time_limit_dropdown_values;
|
2021-06-08 13:45:14 +02:00
|
|
|
export const msg_delete_limit_dropdown_values = new Map([
|
|
|
|
[
|
|
|
|
"any_time",
|
|
|
|
{
|
|
|
|
text: $t({defaultMessage: "Any time"}),
|
|
|
|
seconds: 0,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_two_min",
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "2 minutes"})},
|
|
|
|
),
|
|
|
|
seconds: 2 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_ten_min",
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "10 minutes"})},
|
|
|
|
),
|
|
|
|
seconds: 10 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_hour",
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 hour"})},
|
|
|
|
),
|
|
|
|
seconds: 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_day",
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 day"})},
|
|
|
|
),
|
|
|
|
seconds: 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"upto_one_week",
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 week"})},
|
|
|
|
),
|
|
|
|
seconds: 7 * 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"custom_limit",
|
|
|
|
{
|
|
|
|
text: $t({defaultMessage: "Up to N minutes after posting"}),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
]);
|
2021-02-10 17:14:06 +01:00
|
|
|
export const retain_message_forever = -1;
|
2020-03-28 18:03:43 +01:00
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const user_role_values = {
|
2020-05-29 16:12:09 +02:00
|
|
|
guest: {
|
|
|
|
code: 600,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Guest"}),
|
2020-05-29 16:12:09 +02:00
|
|
|
},
|
|
|
|
member: {
|
|
|
|
code: 400,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Member"}),
|
2020-05-29 16:12:09 +02:00
|
|
|
},
|
2021-04-22 21:07:51 +02:00
|
|
|
moderator: {
|
|
|
|
code: 300,
|
|
|
|
description: $t({defaultMessage: "Moderator"}),
|
|
|
|
},
|
2020-05-29 16:12:09 +02:00
|
|
|
admin: {
|
|
|
|
code: 200,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Administrator"}),
|
2020-05-29 16:12:09 +02:00
|
|
|
},
|
2020-06-03 23:30:34 +02:00
|
|
|
owner: {
|
|
|
|
code: 100,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Owner"}),
|
2020-06-03 23:30:34 +02:00
|
|
|
},
|
2020-05-29 16:12:09 +02:00
|
|
|
};
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
const user_role_array = Object.values(user_role_values);
|
|
|
|
export const user_role_map = new Map(user_role_array.map((role) => [role.code, role.description]));
|
2020-06-23 15:32:18 +02:00
|
|
|
|
2021-08-31 12:45:21 +02:00
|
|
|
export const display_settings_labels = {
|
|
|
|
dense_mode: $t({defaultMessage: "Dense mode"}),
|
|
|
|
fluid_layout_width: $t({defaultMessage: "Use full width on wide screens"}),
|
|
|
|
high_contrast_mode: $t({defaultMessage: "High contrast mode"}),
|
|
|
|
left_side_userlist: $t({
|
|
|
|
defaultMessage: "Show user list on left sidebar in narrow windows",
|
|
|
|
}),
|
|
|
|
starred_message_counts: $t({defaultMessage: "Show counts for starred messages"}),
|
|
|
|
twenty_four_hour_time: $t({defaultMessage: "Time format"}),
|
|
|
|
translate_emoticons: new Handlebars.SafeString(
|
|
|
|
$t_html({
|
|
|
|
defaultMessage: "Convert emoticons before sending (<code>:)</code> becomes 😃)",
|
|
|
|
}),
|
|
|
|
),
|
2021-10-25 19:17:19 +02:00
|
|
|
escape_navigates_to_default_view: $t({defaultMessage: "Escape key navigates to default view"}),
|
2021-08-31 12:45:21 +02:00
|
|
|
};
|
|
|
|
|
2021-09-17 01:07:32 +02:00
|
|
|
export const notification_settings_labels = {
|
2021-08-26 21:03:27 +02:00
|
|
|
enable_online_push_notifications: $t({
|
2021-09-17 01:07:32 +02:00
|
|
|
defaultMessage: "Send mobile notifications even if I'm online (useful for testing)",
|
2021-08-26 21:03:27 +02:00
|
|
|
}),
|
|
|
|
pm_content_in_desktop_notifications: $t({
|
|
|
|
defaultMessage: "Include content of private messages in desktop notifications",
|
|
|
|
}),
|
|
|
|
desktop_icon_count_display: $t({
|
|
|
|
defaultMessage: "Unread count summary (appears in desktop sidebar and browser tab)",
|
|
|
|
}),
|
2021-09-17 01:07:32 +02:00
|
|
|
enable_digest_emails: $t({defaultMessage: "Send digest emails when I'm away"}),
|
2021-08-26 21:03:27 +02:00
|
|
|
enable_login_emails: $t({
|
2021-09-17 01:07:32 +02:00
|
|
|
defaultMessage: "Send email notifications for new logins to my account",
|
|
|
|
}),
|
|
|
|
enable_marketing_emails: $t({
|
|
|
|
defaultMessage: "Send me Zulip's low-traffic newsletter (a few emails a year)",
|
2021-08-26 21:03:27 +02:00
|
|
|
}),
|
|
|
|
message_content_in_email_notifications: $t({
|
|
|
|
defaultMessage: "Include message content in message notification emails",
|
|
|
|
}),
|
|
|
|
realm_name_in_notifications: $t({
|
|
|
|
defaultMessage: "Include organization name in subject of message notification emails",
|
|
|
|
}),
|
2021-09-17 01:07:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const realm_user_settings_defaults_labels = {
|
|
|
|
...notification_settings_labels,
|
2021-08-26 21:03:27 +02:00
|
|
|
...display_settings_labels,
|
2021-09-17 01:07:32 +02:00
|
|
|
|
|
|
|
/* Overrides to remove "I" from labels for the realm-level versions of these labels. */
|
|
|
|
enable_online_push_notifications: $t({
|
|
|
|
defaultMessage: "Send mobile notifications even if user is online (useful for testing)",
|
|
|
|
}),
|
|
|
|
enable_digest_emails: $t({defaultMessage: "Send digest emails when user is away"}),
|
2021-08-30 09:51:38 +02:00
|
|
|
|
|
|
|
realm_presence_enabled: $t({defaultMessage: "Display availability to other users when online"}),
|
2021-09-17 12:51:31 +02:00
|
|
|
realm_enter_sends: $t({defaultMessage: "Enter sends when composing a message"}),
|
2021-08-26 21:03:27 +02:00
|
|
|
};
|
|
|
|
|
2020-03-28 18:03:43 +01:00
|
|
|
// NOTIFICATIONS
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const general_notifications_table_labels = {
|
2020-04-01 19:43:34 +02:00
|
|
|
realm: [
|
|
|
|
/* An array of notification settings of any category like
|
2020-07-15 00:34:28 +02:00
|
|
|
* `stream_notification_settings` which makes a single row of
|
|
|
|
* "Notification triggers" table should follow this order
|
|
|
|
*/
|
|
|
|
"visual",
|
|
|
|
"audio",
|
|
|
|
"mobile",
|
|
|
|
"email",
|
|
|
|
"all_mentions",
|
2020-04-01 19:43:34 +02:00
|
|
|
],
|
|
|
|
stream: {
|
2021-04-13 06:51:54 +02:00
|
|
|
is_muted: $t({defaultMessage: "Mute stream"}),
|
|
|
|
desktop_notifications: $t({defaultMessage: "Visual desktop notifications"}),
|
|
|
|
audible_notifications: $t({defaultMessage: "Audible desktop notifications"}),
|
|
|
|
push_notifications: $t({defaultMessage: "Mobile notifications"}),
|
|
|
|
email_notifications: $t({defaultMessage: "Email notifications"}),
|
|
|
|
pin_to_top: $t({defaultMessage: "Pin stream to top of left sidebar"}),
|
|
|
|
wildcard_mentions_notify: $t({defaultMessage: "Notifications for @all/@everyone mentions"}),
|
2020-04-01 19:43:34 +02:00
|
|
|
},
|
|
|
|
};
|
2020-03-28 18:03:43 +01:00
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const stream_specific_notification_settings = [
|
2020-03-28 18:03:43 +01:00
|
|
|
"desktop_notifications",
|
|
|
|
"audible_notifications",
|
|
|
|
"push_notifications",
|
|
|
|
"email_notifications",
|
|
|
|
"wildcard_mentions_notify",
|
|
|
|
];
|
|
|
|
|
2021-08-26 21:03:27 +02:00
|
|
|
type SettingsObjectType = UserSettingsType | RealmDefaultSettingsType;
|
2021-08-27 15:46:23 +02:00
|
|
|
type PageParamsItem = keyof SettingsObjectType;
|
2021-07-23 19:42:57 +02:00
|
|
|
export const stream_notification_settings: PageParamsItem[] = [
|
2020-03-28 18:03:43 +01:00
|
|
|
"enable_stream_desktop_notifications",
|
|
|
|
"enable_stream_audible_notifications",
|
|
|
|
"enable_stream_push_notifications",
|
|
|
|
"enable_stream_email_notifications",
|
|
|
|
"wildcard_mentions_notify",
|
|
|
|
];
|
|
|
|
|
2021-07-23 19:42:57 +02:00
|
|
|
export const pm_mention_notification_settings: PageParamsItem[] = [
|
2020-03-28 18:03:43 +01:00
|
|
|
"enable_desktop_notifications",
|
|
|
|
"enable_sounds",
|
|
|
|
"enable_offline_push_notifications",
|
|
|
|
"enable_offline_email_notifications",
|
|
|
|
];
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const desktop_notification_settings = ["pm_content_in_desktop_notifications"];
|
2020-03-28 18:03:43 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const mobile_notification_settings = ["enable_online_push_notifications"];
|
2020-03-28 18:03:43 +01:00
|
|
|
|
2021-08-14 11:31:31 +02:00
|
|
|
export const email_notifications_batching_period_values = [
|
|
|
|
{
|
|
|
|
value: 60 * 2,
|
|
|
|
description: $t({defaultMessage: "2 minutes"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 5,
|
|
|
|
description: $t({defaultMessage: "5 minutes"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 10,
|
|
|
|
description: $t({defaultMessage: "10 minutes"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 30,
|
|
|
|
description: $t({defaultMessage: "30 minutes"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 60,
|
|
|
|
description: $t({defaultMessage: "1 hour"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 60 * 6,
|
|
|
|
description: $t({defaultMessage: "6 hours"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 60 * 24,
|
|
|
|
description: $t({defaultMessage: "1 day"}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 60 * 60 * 24 * 7,
|
|
|
|
description: $t({defaultMessage: "1 week"}),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-09-11 13:20:07 +02:00
|
|
|
const email_message_notification_settings = [
|
2020-03-28 18:03:43 +01:00
|
|
|
"message_content_in_email_notifications",
|
|
|
|
"realm_name_in_notifications",
|
2021-09-11 13:20:07 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
const other_email_settings = [
|
|
|
|
"enable_digest_emails",
|
|
|
|
"enable_login_emails",
|
2021-04-28 00:25:27 +02:00
|
|
|
"enable_marketing_emails",
|
2020-03-28 18:03:43 +01:00
|
|
|
];
|
|
|
|
|
2021-09-11 13:20:07 +02:00
|
|
|
const email_notification_settings = other_email_settings.concat(
|
|
|
|
email_message_notification_settings,
|
|
|
|
);
|
|
|
|
|
2020-03-28 18:03:43 +01:00
|
|
|
const other_notification_settings = desktop_notification_settings.concat(
|
|
|
|
["desktop_icon_count_display"],
|
|
|
|
mobile_notification_settings,
|
|
|
|
email_notification_settings,
|
2021-09-16 09:48:27 +02:00
|
|
|
["email_notifications_batching_period_seconds"],
|
2020-07-02 02:16:03 +02:00
|
|
|
["notification_sound"],
|
2020-03-28 18:03:43 +01:00
|
|
|
);
|
|
|
|
|
2021-02-10 17:14:06 +01:00
|
|
|
export const all_notification_settings = other_notification_settings.concat(
|
2020-03-28 18:03:43 +01:00
|
|
|
pm_mention_notification_settings,
|
2021-02-10 17:14:06 +01:00
|
|
|
stream_notification_settings,
|
2020-03-28 18:03:43 +01:00
|
|
|
);
|
|
|
|
|
2021-07-23 19:42:57 +02:00
|
|
|
type NotificationSettingCheckbox = {
|
|
|
|
setting_name: string;
|
|
|
|
is_disabled: boolean;
|
|
|
|
is_checked: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function get_notifications_table_row_data(
|
|
|
|
notify_settings: PageParamsItem[],
|
2021-08-27 15:46:23 +02:00
|
|
|
settings_object: SettingsObjectType,
|
2021-07-23 19:42:57 +02:00
|
|
|
): NotificationSettingCheckbox[] {
|
2021-03-22 12:33:58 +01:00
|
|
|
return general_notifications_table_labels.realm.map((column, index) => {
|
|
|
|
const setting_name = notify_settings[index];
|
|
|
|
if (setting_name === undefined) {
|
|
|
|
return {
|
|
|
|
setting_name: "",
|
|
|
|
is_disabled: true,
|
|
|
|
is_checked: false,
|
|
|
|
};
|
|
|
|
}
|
2021-07-23 19:42:57 +02:00
|
|
|
|
2021-08-27 15:46:23 +02:00
|
|
|
const checked = settings_object[setting_name];
|
2021-07-23 19:42:57 +02:00
|
|
|
if (typeof checked !== "boolean") {
|
|
|
|
throw new TypeError(`Incorrect setting_name passed: ${setting_name}`);
|
|
|
|
}
|
|
|
|
|
2021-03-22 12:33:58 +01:00
|
|
|
const checkbox = {
|
|
|
|
setting_name,
|
|
|
|
is_disabled: false,
|
2021-07-23 19:42:57 +02:00
|
|
|
is_checked: checked,
|
2021-03-22 12:33:58 +01:00
|
|
|
};
|
|
|
|
if (column === "mobile") {
|
|
|
|
checkbox.is_disabled = !page_params.realm_push_notifications_enabled;
|
|
|
|
}
|
|
|
|
return checkbox;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-23 19:42:57 +02:00
|
|
|
export interface AllNotifications {
|
|
|
|
general_settings: {label: string; notification_settings: NotificationSettingCheckbox[]}[];
|
|
|
|
settings: {
|
|
|
|
desktop_notification_settings: string[];
|
|
|
|
mobile_notification_settings: string[];
|
2021-09-11 13:20:07 +02:00
|
|
|
email_message_notification_settings: string[];
|
|
|
|
other_email_settings: string[];
|
2021-07-23 19:42:57 +02:00
|
|
|
};
|
|
|
|
show_push_notifications_tooltip: {
|
|
|
|
push_notifications: boolean;
|
|
|
|
enable_online_push_notifications: boolean;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-27 15:46:23 +02:00
|
|
|
export const all_notifications = (settings_object: SettingsObjectType): AllNotifications => ({
|
2020-03-28 18:03:43 +01:00
|
|
|
general_settings: [
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
label: $t({defaultMessage: "Streams"}),
|
2021-08-27 15:46:23 +02:00
|
|
|
notification_settings: get_notifications_table_row_data(
|
|
|
|
stream_notification_settings,
|
|
|
|
settings_object,
|
|
|
|
),
|
2020-03-28 18:03:43 +01:00
|
|
|
},
|
|
|
|
{
|
2021-04-13 06:51:54 +02:00
|
|
|
label: $t({defaultMessage: "PMs, mentions, and alerts"}),
|
2021-03-22 12:33:58 +01:00
|
|
|
notification_settings: get_notifications_table_row_data(
|
2020-07-15 00:34:28 +02:00
|
|
|
pm_mention_notification_settings,
|
2021-08-27 15:46:23 +02:00
|
|
|
settings_object,
|
2020-07-15 00:34:28 +02:00
|
|
|
),
|
2020-03-28 18:03:43 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
settings: {
|
2020-07-20 22:18:43 +02:00
|
|
|
desktop_notification_settings,
|
|
|
|
mobile_notification_settings,
|
2021-09-11 13:20:07 +02:00
|
|
|
email_message_notification_settings,
|
|
|
|
other_email_settings,
|
2020-03-28 18:03:43 +01:00
|
|
|
},
|
|
|
|
show_push_notifications_tooltip: {
|
|
|
|
push_notifications: !page_params.realm_push_notifications_enabled,
|
|
|
|
enable_online_push_notifications: !page_params.realm_push_notifications_enabled,
|
|
|
|
},
|
|
|
|
});
|
2020-09-26 13:10:36 +02:00
|
|
|
|
2021-03-22 13:14:33 +01:00
|
|
|
export const desktop_icon_count_display_values = {
|
|
|
|
messages: {
|
|
|
|
code: 1,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "All unreads"}),
|
2021-03-22 13:14:33 +01:00
|
|
|
},
|
|
|
|
notifiable: {
|
|
|
|
code: 2,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "Private messages and mentions"}),
|
2021-03-22 13:14:33 +01:00
|
|
|
},
|
|
|
|
none: {
|
|
|
|
code: 3,
|
2021-04-13 06:51:54 +02:00
|
|
|
description: $t({defaultMessage: "None"}),
|
2021-03-22 13:14:33 +01:00
|
|
|
},
|
|
|
|
};
|