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";
|
2022-08-25 20:13:33 +02:00
|
|
|
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
|
2022-08-25 21:06:42 +02:00
|
|
|
import type {StreamSpecificNotificationSettings} from "./sub_store";
|
2022-08-25 21:12:35 +02:00
|
|
|
import type {
|
|
|
|
PmNotificationSettings,
|
|
|
|
StreamNotificationSettings,
|
|
|
|
UserSettings,
|
|
|
|
} 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
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-08-12 22:41:06 +02:00
|
|
|
export const user_list_style_values = {
|
|
|
|
compact: {
|
|
|
|
code: 1,
|
|
|
|
description: $t({defaultMessage: "Compact"}),
|
|
|
|
},
|
|
|
|
with_status: {
|
|
|
|
code: 2,
|
|
|
|
description: $t({defaultMessage: "Show status text"}),
|
|
|
|
},
|
|
|
|
// The `with_avatar` design in still in discussion.
|
|
|
|
// with_avatar: {
|
|
|
|
// code: 3,
|
|
|
|
// description: $t({defaultMessage: "Show status text and avatar"}),
|
|
|
|
// },
|
|
|
|
};
|
|
|
|
|
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-11-18 10:15:13 +01:00
|
|
|
description: $t({defaultMessage: "Sync with computer"}),
|
2020-05-16 13:13:59 +02:00
|
|
|
},
|
|
|
|
night: {
|
|
|
|
code: 2,
|
2021-11-18 11:06:35 +01:00
|
|
|
description: $t({defaultMessage: "Dark theme"}),
|
2020-05-16 13:13:59 +02:00
|
|
|
},
|
|
|
|
day: {
|
|
|
|
code: 3,
|
2021-11-19 04:22:51 +01:00
|
|
|
description: $t({defaultMessage: "Light theme"}),
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-17 03:01:46 +01:00
|
|
|
/* istanbul ignore next */
|
2021-07-23 19:42:57 +02:00
|
|
|
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"}),
|
|
|
|
},
|
2022-07-05 16:56:12 +02:00
|
|
|
by_admins_only: {
|
2021-05-02 10:11:02 +02:00
|
|
|
order: 5,
|
2022-07-05 16:56:12 +02:00
|
|
|
code: 5,
|
2021-04-13 06:51: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-11-19 17:36:00 +01:00
|
|
|
export const create_web_public_stream_policy_values = {
|
|
|
|
by_moderators_only: {
|
|
|
|
order: 1,
|
|
|
|
code: 4,
|
|
|
|
description: $t({defaultMessage: "Admins and moderators"}),
|
|
|
|
},
|
|
|
|
by_admins_only: {
|
|
|
|
order: 2,
|
|
|
|
code: 2,
|
|
|
|
description: $t({defaultMessage: "Admins only"}),
|
|
|
|
},
|
|
|
|
by_owners_only: {
|
|
|
|
order: 3,
|
|
|
|
code: 7,
|
|
|
|
description: $t({defaultMessage: "Owners only"}),
|
|
|
|
},
|
|
|
|
nobody: {
|
|
|
|
order: 4,
|
|
|
|
code: 6,
|
|
|
|
description: $t({defaultMessage: "Nobody"}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
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"}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-08-25 10:02:54 +02:00
|
|
|
export const time_limit_dropdown_values = [
|
2022-09-01 14:19:14 +02:00
|
|
|
{
|
|
|
|
text: $t({defaultMessage: "Any time"}),
|
|
|
|
value: "any_time",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "2 minutes"})},
|
|
|
|
),
|
|
|
|
value: 2 * 60,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "10 minutes"})},
|
|
|
|
),
|
|
|
|
value: 10 * 60,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 hour"})},
|
|
|
|
),
|
|
|
|
value: 60 * 60,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 day"})},
|
|
|
|
),
|
|
|
|
value: 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t(
|
|
|
|
{defaultMessage: "Up to {time_limit} after posting"},
|
|
|
|
{time_limit: $t({defaultMessage: "1 week"})},
|
|
|
|
),
|
|
|
|
value: 7 * 24 * 60 * 60,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: $t({defaultMessage: "Custom"}),
|
|
|
|
value: "custom_period",
|
|
|
|
},
|
|
|
|
];
|
2021-02-10 17:14:06 +01:00
|
|
|
export const msg_edit_limit_dropdown_values = time_limit_dropdown_values;
|
2022-04-18 13:24:49 +02:00
|
|
|
export const msg_delete_limit_dropdown_values = time_limit_dropdown_values;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-04-12 17:41:07 +02:00
|
|
|
export const all_org_type_values = {
|
|
|
|
// When org_type was added to the database model, 'unspecified'
|
|
|
|
// was the default for existing organizations. To discourage
|
|
|
|
// organizations keeping (or selecting) it as an option, we
|
|
|
|
// use an empty string for its description.
|
|
|
|
unspecified: {
|
|
|
|
code: 0,
|
|
|
|
description: "",
|
|
|
|
},
|
|
|
|
business: {
|
|
|
|
code: 10,
|
|
|
|
description: $t({defaultMessage: "Business"}),
|
|
|
|
},
|
|
|
|
opensource: {
|
|
|
|
code: 20,
|
|
|
|
description: $t({defaultMessage: "Open-source project"}),
|
|
|
|
},
|
|
|
|
education_nonprofit: {
|
|
|
|
code: 30,
|
|
|
|
description: $t({defaultMessage: "Education (non-profit)"}),
|
|
|
|
},
|
|
|
|
education: {
|
|
|
|
code: 35,
|
|
|
|
description: $t({defaultMessage: "Education (for-profit)"}),
|
|
|
|
},
|
|
|
|
research: {
|
|
|
|
code: 40,
|
|
|
|
description: $t({defaultMessage: "Research"}),
|
|
|
|
},
|
|
|
|
event: {
|
|
|
|
code: 50,
|
|
|
|
description: $t({defaultMessage: "Event or conference"}),
|
|
|
|
},
|
|
|
|
nonprofit: {
|
|
|
|
code: 60,
|
|
|
|
description: $t({defaultMessage: "Non-profit (registered)"}),
|
|
|
|
},
|
|
|
|
government: {
|
|
|
|
code: 70,
|
|
|
|
description: $t({defaultMessage: "Government"}),
|
|
|
|
},
|
|
|
|
political_group: {
|
|
|
|
code: 80,
|
|
|
|
description: $t({defaultMessage: "Political group"}),
|
|
|
|
},
|
|
|
|
community: {
|
|
|
|
code: 90,
|
|
|
|
description: $t({defaultMessage: "Community"}),
|
|
|
|
},
|
|
|
|
personal: {
|
|
|
|
code: 100,
|
|
|
|
description: $t({defaultMessage: "Personal"}),
|
|
|
|
},
|
|
|
|
other: {
|
|
|
|
code: 1000,
|
|
|
|
description: $t({defaultMessage: "Other"}),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// Remove the 'unspecified' org_type for dropdown menu options
|
|
|
|
// when an org_type other than 'unspecified' has been selected.
|
|
|
|
export const defined_org_type_values = Object.fromEntries(
|
|
|
|
Object.entries(all_org_type_values).slice(1),
|
|
|
|
);
|
|
|
|
|
2021-09-15 11:49:36 +02:00
|
|
|
export const expires_in_values = {
|
|
|
|
// Backend support for this configuration is not available yet.
|
|
|
|
// hour: {
|
|
|
|
// value: 1,
|
|
|
|
// description: $t({defaultMessage: "1 hour"}),
|
|
|
|
// default: false,
|
|
|
|
// },
|
|
|
|
day: {
|
2022-02-10 11:52:34 +01:00
|
|
|
value: 24 * 60,
|
2021-09-15 11:49:36 +02:00
|
|
|
description: $t({defaultMessage: "1 day"}),
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
threeDays: {
|
2022-02-10 11:52:34 +01:00
|
|
|
value: 3 * 24 * 60,
|
2021-09-15 11:49:36 +02:00
|
|
|
description: $t({defaultMessage: "3 days"}),
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
tenDays: {
|
2022-02-10 11:52:34 +01:00
|
|
|
value: 10 * 24 * 60,
|
2021-09-15 11:49:36 +02:00
|
|
|
description: $t({defaultMessage: "10 days"}),
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
thirtyDays: {
|
2022-02-10 11:52:34 +01:00
|
|
|
value: 30 * 24 * 60,
|
2021-09-15 11:49:36 +02:00
|
|
|
description: $t({defaultMessage: "30 days"}),
|
|
|
|
default: false,
|
|
|
|
},
|
2021-12-01 12:10:58 +01:00
|
|
|
never: {
|
|
|
|
// Ideally we'd just store `null`, not the string `"null"`, but
|
|
|
|
// .val() will read null back as `""`. Custom logic in
|
|
|
|
// get_common_invitation_data converts this back to `null`
|
|
|
|
// before sending to the server.
|
|
|
|
value: "null",
|
|
|
|
description: $t({defaultMessage: "Never expires"}),
|
|
|
|
default: false,
|
|
|
|
},
|
2022-02-11 17:54:15 +01:00
|
|
|
custom: {
|
|
|
|
value: "custom",
|
|
|
|
description: $t({defaultMessage: "Custom"}),
|
|
|
|
default: false,
|
|
|
|
},
|
2021-09-15 11:49:36 +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 😃)",
|
|
|
|
}),
|
|
|
|
),
|
2022-04-08 16:04:22 +02:00
|
|
|
display_emoji_reaction_users: new Handlebars.SafeString(
|
|
|
|
$t_html({
|
|
|
|
defaultMessage:
|
2022-09-23 21:01:33 +02:00
|
|
|
"Display names of reacting users when few users have reacted to a message",
|
2022-04-08 16:04:22 +02:00
|
|
|
}),
|
|
|
|
),
|
2021-10-25 19:17:19 +02:00
|
|
|
escape_navigates_to_default_view: $t({defaultMessage: "Escape key navigates to default view"}),
|
2022-05-02 11:15:25 +02:00
|
|
|
default_language_settings_label: $t({defaultMessage: "Language"}),
|
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({
|
2022-01-12 08:18:12 +01:00
|
|
|
defaultMessage: "Unread count badge (appears in desktop sidebar and browser tab)",
|
2021-08-26 21:03:27 +02:00
|
|
|
}),
|
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
|
|
|
|
2022-09-21 15:49:36 +02:00
|
|
|
realm_presence_enabled: $t({
|
2022-09-24 12:40:36 +02:00
|
|
|
defaultMessage: "Display availability to other users",
|
2022-09-21 15:49:36 +02:00
|
|
|
}),
|
2022-09-24 12:40:36 +02:00
|
|
|
realm_presence_enabled_parens_text: $t({defaultMessage: "invisible mode off"}),
|
2021-09-17 12:51:31 +02:00
|
|
|
realm_enter_sends: $t({defaultMessage: "Enter sends when composing a message"}),
|
2022-08-20 08:37:49 +02:00
|
|
|
realm_send_read_receipts: $t({defaultMessage: "Allow other users to view read receipts"}),
|
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
|
|
|
|
2022-08-25 21:06:42 +02:00
|
|
|
export const stream_specific_notification_settings: (keyof StreamSpecificNotificationSettings)[] = [
|
2020-03-28 18:03:43 +01:00
|
|
|
"desktop_notifications",
|
|
|
|
"audible_notifications",
|
|
|
|
"push_notifications",
|
|
|
|
"email_notifications",
|
|
|
|
"wildcard_mentions_notify",
|
|
|
|
];
|
|
|
|
|
2022-08-25 21:12:35 +02:00
|
|
|
export const stream_notification_settings: (keyof StreamNotificationSettings)[] = [
|
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",
|
|
|
|
];
|
|
|
|
|
2022-08-25 21:09:32 +02:00
|
|
|
export const generalize_stream_notification_setting: Record<
|
|
|
|
keyof StreamSpecificNotificationSettings,
|
|
|
|
keyof StreamNotificationSettings
|
|
|
|
> = {
|
|
|
|
desktop_notifications: "enable_stream_desktop_notifications",
|
|
|
|
audible_notifications: "enable_stream_audible_notifications",
|
|
|
|
push_notifications: "enable_stream_push_notifications",
|
|
|
|
email_notifications: "enable_stream_email_notifications",
|
|
|
|
wildcard_mentions_notify: "wildcard_mentions_notify",
|
2022-08-25 21:07:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const specialize_stream_notification_setting: Record<
|
|
|
|
keyof StreamNotificationSettings,
|
|
|
|
keyof StreamSpecificNotificationSettings
|
|
|
|
> = {
|
|
|
|
enable_stream_desktop_notifications: "desktop_notifications",
|
|
|
|
enable_stream_audible_notifications: "audible_notifications",
|
|
|
|
enable_stream_push_notifications: "push_notifications",
|
|
|
|
enable_stream_email_notifications: "email_notifications",
|
|
|
|
wildcard_mentions_notify: "wildcard_mentions_notify",
|
2022-08-25 21:09:32 +02:00
|
|
|
};
|
|
|
|
|
2022-08-25 21:12:35 +02:00
|
|
|
export const pm_mention_notification_settings: (keyof PmNotificationSettings)[] = [
|
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-10-23 17:14:11 +02:00
|
|
|
{
|
|
|
|
value: "custom_period",
|
2021-11-07 10:42:11 +01:00
|
|
|
description: $t({defaultMessage: "Custom"}),
|
2021-10-23 17:14:11 +02:00
|
|
|
},
|
2021-08-14 11:31:31 +02:00
|
|
|
];
|
|
|
|
|
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
|
|
|
);
|
|
|
|
|
2022-08-25 21:12:35 +02:00
|
|
|
type Settings = UserSettings | RealmDefaultSettings;
|
|
|
|
type PageParamsItem = keyof Settings;
|
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[],
|
2022-08-25 20:13:33 +02:00
|
|
|
settings_object: Settings,
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-08-25 20:13:33 +02:00
|
|
|
export const all_notifications = (settings_object: Settings): 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
|
|
|
},
|
|
|
|
};
|