2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-04-24 20:39:08 +02:00
|
|
|
import render_admin_tab from "../templates/settings/admin_tab.hbs";
|
2021-02-28 01:23:35 +01:00
|
|
|
import render_settings_organization_settings_tip from "../templates/settings/organization_settings_tip.hbs";
|
2020-08-01 03:43:15 +02:00
|
|
|
|
2022-05-03 08:06:40 +02:00
|
|
|
import {$t, get_language_name, language_list} from "./i18n";
|
2021-02-28 01:23:35 +01:00
|
|
|
import * as overlays from "./overlays";
|
2021-03-25 22:35:45 +01:00
|
|
|
import {page_params} from "./page_params";
|
2021-08-17 14:43:29 +02:00
|
|
|
import {realm_user_settings_defaults} from "./realm_user_settings_defaults";
|
2021-02-28 01:23:35 +01:00
|
|
|
import * as settings from "./settings";
|
|
|
|
import * as settings_bots from "./settings_bots";
|
|
|
|
import * as settings_config from "./settings_config";
|
|
|
|
import * as settings_data from "./settings_data";
|
|
|
|
import * as settings_org from "./settings_org";
|
|
|
|
import * as settings_panel_menu from "./settings_panel_menu";
|
|
|
|
import * as settings_sections from "./settings_sections";
|
|
|
|
import * as settings_toggle from "./settings_toggle";
|
2020-07-24 06:02:07 +02:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const admin_settings_label = {
|
2022-04-22 18:45:30 +02:00
|
|
|
// Organization profile
|
|
|
|
realm_want_advertise_in_communities_directory: $t({
|
|
|
|
defaultMessage: "Advertise organization in the Zulip communities directory",
|
|
|
|
}),
|
2018-05-30 19:03:39 +02:00
|
|
|
// Organization settings
|
2021-04-13 06:51:54 +02:00
|
|
|
realm_allow_edit_history: $t({defaultMessage: "Enable message edit history"}),
|
|
|
|
realm_mandatory_topics: $t({defaultMessage: "Require topics in stream messages"}),
|
2022-06-27 22:34:52 +02:00
|
|
|
realm_notifications_stream: $t({defaultMessage: "New stream announcements"}),
|
|
|
|
realm_signup_notifications_stream: $t({defaultMessage: "New user announcements"}),
|
2021-04-13 06:51:54 +02:00
|
|
|
realm_inline_image_preview: $t({defaultMessage: "Show previews of uploaded and linked images"}),
|
|
|
|
realm_inline_url_embed_preview: $t({defaultMessage: "Show previews of linked websites"}),
|
|
|
|
realm_send_welcome_emails: $t({defaultMessage: "Send emails introducing Zulip to new users"}),
|
|
|
|
realm_message_content_allowed_in_email_notifications: $t({
|
2021-04-20 23:27:25 +02:00
|
|
|
defaultMessage: "Allow message content in message notification emails",
|
2021-04-13 06:51:54 +02:00
|
|
|
}),
|
2021-10-03 14:16:07 +02:00
|
|
|
realm_enable_spectator_access: $t({
|
|
|
|
defaultMessage: "Allow creating web-public streams (visible to anyone on the Internet)",
|
|
|
|
}),
|
2021-04-13 06:51:54 +02:00
|
|
|
realm_digest_emails_enabled: $t({
|
|
|
|
defaultMessage: "Send weekly digest emails to inactive users",
|
|
|
|
}),
|
2022-03-16 00:08:41 +01:00
|
|
|
realm_default_code_block_language: $t({defaultMessage: "Default language for code blocks"}),
|
2018-05-30 19:03:39 +02:00
|
|
|
|
|
|
|
// Organization permissions
|
2021-04-13 06:51:54 +02:00
|
|
|
realm_name_changes_disabled: $t({defaultMessage: "Prevent users from changing their name"}),
|
|
|
|
realm_email_changes_disabled: $t({
|
|
|
|
defaultMessage: "Prevent users from changing their email address",
|
|
|
|
}),
|
|
|
|
realm_avatar_changes_disabled: $t({defaultMessage: "Prevent users from changing their avatar"}),
|
2021-05-23 21:40:20 +02:00
|
|
|
realm_invite_required: $t({
|
|
|
|
defaultMessage: "Invitations are required for joining this organization",
|
|
|
|
}),
|
2022-06-27 22:34:52 +02:00
|
|
|
realm_default_language: $t({
|
|
|
|
defaultMessage: "Language for automated messages and invitation emails",
|
|
|
|
}),
|
2022-04-12 09:56:58 +02:00
|
|
|
realm_allow_message_editing: $t({defaultMessage: "Allow message editing"}),
|
2022-09-24 12:34:41 +02:00
|
|
|
realm_enable_read_receipts: $t({defaultMessage: "Enable read receipts"}),
|
|
|
|
realm_enable_read_receipts_parens_text: $t({
|
|
|
|
defaultMessage: "Users can always disable their personal read receipts.",
|
|
|
|
}),
|
2018-05-30 19:03:39 +02:00
|
|
|
};
|
|
|
|
|
settings: Call insert_tip_box from admin.build_page and move it to admin.js.
The organization_settings_tip is not visible if organization settings
overlay is opened with any section other than organization profile,
settings and permissions. This is because insert_tip_box is called from
settings_org.build_page, which is called only when we open any of the
above three sections after opening the overlay and not others.
We should call insert_tip_box function from admin.build_page instead
of settings_org.build_page because we need to insert the admin tips
each time the organization settings overlay is opened, irrespective
of the section which opens first.
The function insert_tip_box is moved to admin.js from settings_org.js,
because settings_org.js file handles the organization profile,
settings and permissions page only, while we display the tips in many
other sections including bots, custom emoji, etc.
Thus, it makes sense to move insert_tip_box function to admin.js, which
renders the complete organization settings overlay using render_admin_tab.
2020-06-28 16:27:54 +02:00
|
|
|
function insert_tip_box() {
|
|
|
|
if (page_params.is_admin) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const tip_box = render_settings_organization_settings_tip({is_admin: page_params.is_admin});
|
2020-07-15 00:34:28 +02:00
|
|
|
$(".organization-box")
|
|
|
|
.find(".settings-section")
|
settings: Call insert_tip_box from admin.build_page and move it to admin.js.
The organization_settings_tip is not visible if organization settings
overlay is opened with any section other than organization profile,
settings and permissions. This is because insert_tip_box is called from
settings_org.build_page, which is called only when we open any of the
above three sections after opening the overlay and not others.
We should call insert_tip_box function from admin.build_page instead
of settings_org.build_page because we need to insert the admin tips
each time the organization settings overlay is opened, irrespective
of the section which opens first.
The function insert_tip_box is moved to admin.js from settings_org.js,
because settings_org.js file handles the organization profile,
settings and permissions page only, while we display the tips in many
other sections including bots, custom emoji, etc.
Thus, it makes sense to move insert_tip_box function to admin.js, which
renders the complete organization settings overlay using render_admin_tab.
2020-06-28 16:27:54 +02:00
|
|
|
.not("#emoji-settings")
|
|
|
|
.not("#user-groups-admin")
|
|
|
|
.not("#organization-auth-settings")
|
2022-07-28 23:54:59 +02:00
|
|
|
.not("#admin-bot-list")
|
|
|
|
.not("#admin-invites-list")
|
settings: Call insert_tip_box from admin.build_page and move it to admin.js.
The organization_settings_tip is not visible if organization settings
overlay is opened with any section other than organization profile,
settings and permissions. This is because insert_tip_box is called from
settings_org.build_page, which is called only when we open any of the
above three sections after opening the overlay and not others.
We should call insert_tip_box function from admin.build_page instead
of settings_org.build_page because we need to insert the admin tips
each time the organization settings overlay is opened, irrespective
of the section which opens first.
The function insert_tip_box is moved to admin.js from settings_org.js,
because settings_org.js file handles the organization profile,
settings and permissions page only, while we display the tips in many
other sections including bots, custom emoji, etc.
Thus, it makes sense to move insert_tip_box function to admin.js, which
renders the complete organization settings overlay using render_admin_tab.
2020-06-28 16:27:54 +02:00
|
|
|
.prepend(tip_box);
|
|
|
|
}
|
|
|
|
|
2021-08-26 21:03:27 +02:00
|
|
|
function get_realm_level_notification_settings(options) {
|
|
|
|
const all_notifications_settings = settings_config.all_notifications(
|
|
|
|
realm_user_settings_defaults,
|
|
|
|
);
|
|
|
|
|
2021-09-28 10:03:43 +02:00
|
|
|
// We remove enable_marketing_emails and enable_login_emails
|
|
|
|
// setting from all_notification_settings, since there are no
|
|
|
|
// realm-level defaults for these setting.
|
|
|
|
all_notifications_settings.settings.other_email_settings = ["enable_digest_emails"];
|
2021-08-26 21:03:27 +02:00
|
|
|
|
|
|
|
options.general_settings = all_notifications_settings.general_settings;
|
|
|
|
options.notification_settings = all_notifications_settings.settings;
|
|
|
|
options.show_push_notifications_tooltip =
|
|
|
|
all_notifications_settings.show_push_notifications_tooltip;
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:23:35 +01:00
|
|
|
export function build_page() {
|
2019-11-02 00:06:25 +01:00
|
|
|
const options = {
|
2017-12-14 05:51:45 +01:00
|
|
|
custom_profile_field_types: page_params.custom_profile_field_types,
|
2022-08-12 22:41:06 +02:00
|
|
|
full_name: page_params.full_name,
|
2016-07-28 06:17:31 +02:00
|
|
|
realm_name: page_params.realm_name,
|
2022-04-12 17:41:07 +02:00
|
|
|
realm_org_type: page_params.realm_org_type,
|
2018-04-23 14:51:30 +02:00
|
|
|
realm_available_video_chat_providers: page_params.realm_available_video_chat_providers,
|
2021-04-27 21:58:19 +02:00
|
|
|
giphy_rating_options: page_params.giphy_rating_options,
|
2021-05-19 05:18:33 +02:00
|
|
|
giphy_api_key_empty: page_params.giphy_api_key === "",
|
2017-03-18 20:19:44 +01:00
|
|
|
realm_description: page_params.realm_description,
|
2017-03-13 14:42:03 +01:00
|
|
|
realm_inline_image_preview: page_params.realm_inline_image_preview,
|
|
|
|
server_inline_image_preview: page_params.server_inline_image_preview,
|
|
|
|
realm_inline_url_embed_preview: page_params.realm_inline_url_embed_preview,
|
|
|
|
server_inline_url_embed_preview: page_params.server_inline_url_embed_preview,
|
2016-11-02 21:51:56 +01:00
|
|
|
realm_authentication_methods: page_params.realm_authentication_methods,
|
2019-11-02 17:58:55 +01:00
|
|
|
realm_user_group_edit_policy: page_params.realm_user_group_edit_policy,
|
2017-03-13 18:33:49 +01:00
|
|
|
realm_name_changes_disabled: page_params.realm_name_changes_disabled,
|
2017-03-04 06:39:45 +01:00
|
|
|
realm_email_changes_disabled: page_params.realm_email_changes_disabled,
|
2019-04-23 04:51:04 +02:00
|
|
|
realm_avatar_changes_disabled: page_params.realm_avatar_changes_disabled,
|
2021-05-04 19:02:24 +02:00
|
|
|
realm_add_custom_emoji_policy: page_params.realm_add_custom_emoji_policy,
|
2021-05-17 19:32:35 +02:00
|
|
|
can_add_emojis: settings_data.user_can_add_custom_emoji(),
|
2022-09-16 12:40:13 +02:00
|
|
|
can_create_new_bots: settings_bots.can_create_new_bots(),
|
2020-07-15 00:34:28 +02:00
|
|
|
realm_message_content_edit_limit_minutes: settings_org.get_realm_time_limits_in_minutes(
|
|
|
|
"realm_message_content_edit_limit_seconds",
|
|
|
|
),
|
|
|
|
realm_message_content_delete_limit_minutes: settings_org.get_realm_time_limits_in_minutes(
|
|
|
|
"realm_message_content_delete_limit_seconds",
|
|
|
|
),
|
2016-11-30 10:42:58 +01:00
|
|
|
realm_message_retention_days: page_params.realm_message_retention_days,
|
2017-07-16 11:00:44 +02:00
|
|
|
realm_allow_edit_history: page_params.realm_allow_edit_history,
|
2022-04-12 09:56:58 +02:00
|
|
|
realm_allow_message_editing: page_params.realm_allow_message_editing,
|
2021-06-18 02:48:45 +02:00
|
|
|
language_list,
|
2022-05-03 08:06:40 +02:00
|
|
|
realm_default_language_name: get_language_name(page_params.realm_default_language),
|
|
|
|
realm_default_language_code: page_params.realm_default_language,
|
2017-01-12 00:17:43 +01:00
|
|
|
realm_waiting_period_threshold: page_params.realm_waiting_period_threshold,
|
2017-06-10 07:03:53 +02:00
|
|
|
realm_notifications_stream_id: page_params.realm_notifications_stream_id,
|
2017-10-20 16:55:04 +02:00
|
|
|
realm_signup_notifications_stream_id: page_params.realm_signup_notifications_stream_id,
|
2017-02-21 21:34:13 +01:00
|
|
|
is_admin: page_params.is_admin,
|
2018-06-08 14:43:27 +02:00
|
|
|
is_guest: page_params.is_guest,
|
2020-06-03 23:30:34 +02:00
|
|
|
is_owner: page_params.is_owner,
|
2020-06-17 07:43:53 +02:00
|
|
|
user_can_change_logo: settings_data.user_can_change_logo(),
|
2017-02-21 03:41:20 +01:00
|
|
|
realm_icon_source: page_params.realm_icon_source,
|
2017-02-26 20:35:23 +01:00
|
|
|
realm_icon_url: page_params.realm_icon_url,
|
2018-08-16 01:26:55 +02:00
|
|
|
realm_logo_source: page_params.realm_logo_source,
|
|
|
|
realm_logo_url: page_params.realm_logo_url,
|
2019-01-27 08:25:10 +01:00
|
|
|
realm_night_logo_source: page_params.realm_night_logo_source,
|
|
|
|
realm_night_logo_url: page_params.realm_night_logo_url,
|
2017-07-04 20:04:27 +02:00
|
|
|
realm_mandatory_topics: page_params.realm_mandatory_topics,
|
2018-02-18 09:34:54 +01:00
|
|
|
realm_send_welcome_emails: page_params.realm_send_welcome_emails,
|
2019-01-14 14:04:08 +01:00
|
|
|
realm_message_content_allowed_in_email_notifications:
|
|
|
|
page_params.realm_message_content_allowed_in_email_notifications,
|
2021-10-03 14:16:07 +02:00
|
|
|
realm_enable_spectator_access: page_params.realm_enable_spectator_access,
|
2019-04-06 06:34:49 +02:00
|
|
|
settings_send_digest_emails: page_params.settings_send_digest_emails,
|
|
|
|
realm_digest_emails_enabled: page_params.realm_digest_emails_enabled,
|
2019-03-31 12:13:42 +02:00
|
|
|
realm_digest_weekday: page_params.realm_digest_weekday,
|
2018-08-03 22:52:21 +02:00
|
|
|
development: page_params.development_environment,
|
2020-05-08 13:30:34 +02:00
|
|
|
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
2019-06-12 14:22:37 +02:00
|
|
|
upgrade_text_for_wide_organization_logo:
|
|
|
|
page_params.upgrade_text_for_wide_organization_logo,
|
2019-05-27 10:59:55 +02:00
|
|
|
realm_default_external_accounts: page_params.realm_default_external_accounts,
|
2020-12-22 00:37:36 +01:00
|
|
|
admin_settings_label,
|
|
|
|
msg_edit_limit_dropdown_values: settings_config.msg_edit_limit_dropdown_values,
|
|
|
|
msg_delete_limit_dropdown_values: settings_config.msg_delete_limit_dropdown_values,
|
|
|
|
bot_creation_policy_values: settings_bots.bot_creation_policy_values,
|
|
|
|
email_address_visibility_values: settings_config.email_address_visibility_values,
|
2021-04-28 20:54:03 +02:00
|
|
|
can_invite_others_to_realm: settings_data.user_can_invite_others_to_realm(),
|
2021-05-23 21:40:20 +02:00
|
|
|
realm_invite_required: page_params.realm_invite_required,
|
2021-06-03 15:47:03 +02:00
|
|
|
can_edit_user_groups: settings_data.user_can_edit_user_groups(),
|
|
|
|
policy_values: settings_config.common_policy_values,
|
2021-06-23 12:53:38 +02:00
|
|
|
realm_delete_own_message_policy: page_params.realm_delete_own_message_policy,
|
|
|
|
DELETE_OWN_MESSAGE_POLICY_ADMINS_ONLY:
|
|
|
|
settings_config.common_message_policy_values.by_admins_only.code,
|
2020-12-22 00:37:36 +01:00
|
|
|
...settings_org.get_organization_settings_options(),
|
2021-08-17 14:43:29 +02:00
|
|
|
demote_inactive_streams_values: settings_config.demote_inactive_streams_values,
|
2022-08-12 22:41:06 +02:00
|
|
|
user_list_style_values: settings_config.user_list_style_values,
|
2021-08-17 14:43:29 +02:00
|
|
|
color_scheme_values: settings_config.color_scheme_values,
|
|
|
|
default_view_values: settings_config.default_view_values,
|
|
|
|
settings_object: realm_user_settings_defaults,
|
|
|
|
display_settings: settings_config.get_all_display_settings(),
|
2021-08-26 21:03:27 +02:00
|
|
|
settings_label: settings_config.realm_user_settings_defaults_labels,
|
|
|
|
desktop_icon_count_display_values: settings_config.desktop_icon_count_display_values,
|
|
|
|
enable_sound_select:
|
|
|
|
realm_user_settings_defaults.enable_sounds ||
|
|
|
|
realm_user_settings_defaults.enable_stream_audible_notifications,
|
|
|
|
email_notifications_batching_period_values:
|
|
|
|
settings_config.email_notifications_batching_period_values,
|
2021-09-17 18:11:37 +02:00
|
|
|
twenty_four_hour_time_values: settings_config.twenty_four_hour_time_values,
|
2021-11-19 10:29:39 +01:00
|
|
|
create_web_public_stream_policy_values:
|
|
|
|
settings_config.create_web_public_stream_policy_values,
|
2022-05-26 11:43:42 +02:00
|
|
|
disable_enable_spectator_access_setting:
|
|
|
|
!page_params.server_web_public_streams_enabled ||
|
|
|
|
!page_params.zulip_plan_is_not_limited,
|
2022-03-09 07:56:47 +01:00
|
|
|
can_sort_by_email: settings_data.show_email(),
|
2022-03-30 11:39:21 +02:00
|
|
|
realm_push_notifications_enabled: page_params.realm_push_notifications_enabled,
|
2022-04-12 17:41:07 +02:00
|
|
|
realm_org_type_values: settings_org.get_org_type_dropdown_options(),
|
2022-04-22 18:45:30 +02:00
|
|
|
realm_want_advertise_in_communities_directory:
|
|
|
|
page_params.realm_want_advertise_in_communities_directory,
|
|
|
|
disable_want_advertise_in_communities_directory:
|
2022-05-24 01:33:11 +02:00
|
|
|
!page_params.realm_push_notifications_enabled,
|
2022-06-01 16:52:40 +02:00
|
|
|
is_business_type_org:
|
|
|
|
page_params.realm_org_type === settings_config.all_org_type_values.business.code,
|
2022-08-04 13:49:15 +02:00
|
|
|
realm_enable_read_receipts: page_params.realm_enable_read_receipts,
|
2015-08-20 02:38:32 +02:00
|
|
|
};
|
2016-12-03 01:12:52 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {
|
2021-11-26 10:29:05 +01:00
|
|
|
// If no dark theme logo is specified but a light theme one is,
|
|
|
|
// use the light theme one. See also similar code in realm_logo.js.
|
2019-02-21 02:55:48 +01:00
|
|
|
options.realm_night_logo_url = options.realm_logo_url;
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:56:53 +02:00
|
|
|
options.giphy_help_link = "/help/animated-gifs-from-giphy";
|
|
|
|
if (options.giphy_api_key_empty) {
|
|
|
|
options.giphy_help_link =
|
|
|
|
"https://zulip.readthedocs.io/en/latest/production/giphy-gif-integration.html";
|
|
|
|
}
|
|
|
|
|
2021-08-26 21:03:27 +02:00
|
|
|
get_realm_level_notification_settings(options);
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const rendered_admin_tab = render_admin_tab(options);
|
2018-03-22 22:10:08 +01:00
|
|
|
$("#settings_content .organization-box").html(rendered_admin_tab);
|
2017-03-23 20:37:08 +01:00
|
|
|
$("#settings_content .alert").removeClass("show");
|
2014-01-27 21:48:23 +01:00
|
|
|
|
2018-01-29 16:10:54 +01:00
|
|
|
settings_bots.update_bot_settings_tip();
|
settings: Call insert_tip_box from admin.build_page and move it to admin.js.
The organization_settings_tip is not visible if organization settings
overlay is opened with any section other than organization profile,
settings and permissions. This is because insert_tip_box is called from
settings_org.build_page, which is called only when we open any of the
above three sections after opening the overlay and not others.
We should call insert_tip_box function from admin.build_page instead
of settings_org.build_page because we need to insert the admin tips
each time the organization settings overlay is opened, irrespective
of the section which opens first.
The function insert_tip_box is moved to admin.js from settings_org.js,
because settings_org.js file handles the organization profile,
settings and permissions page only, while we display the tips in many
other sections including bots, custom emoji, etc.
Thus, it makes sense to move insert_tip_box function to admin.js, which
renders the complete organization settings overlay using render_admin_tab.
2020-06-28 16:27:54 +02:00
|
|
|
insert_tip_box();
|
|
|
|
|
2018-01-29 16:10:54 +01:00
|
|
|
$("#id_realm_bot_creation_policy").val(page_params.realm_bot_creation_policy);
|
2018-08-03 22:52:21 +02:00
|
|
|
$("#id_realm_email_address_visibility").val(page_params.realm_email_address_visibility);
|
2018-01-29 16:10:54 +01:00
|
|
|
|
2019-03-31 12:13:42 +02:00
|
|
|
$("#id_realm_digest_weekday").val(options.realm_digest_weekday);
|
2021-02-28 01:23:35 +01:00
|
|
|
}
|
2018-12-06 19:56:28 +01:00
|
|
|
|
2021-02-28 01:23:35 +01:00
|
|
|
export function launch(section) {
|
2018-12-06 20:18:56 +01:00
|
|
|
settings.build_page();
|
2021-02-28 01:23:35 +01:00
|
|
|
build_page();
|
2018-12-08 19:28:26 +01:00
|
|
|
settings_sections.reset_sections();
|
2016-06-10 09:03:36 +02:00
|
|
|
|
2017-05-27 15:40:54 +02:00
|
|
|
overlays.open_settings();
|
2020-06-25 00:51:20 +02:00
|
|
|
settings_panel_menu.org_settings.activate_section_or_default(section);
|
2020-07-15 01:29:15 +02:00
|
|
|
settings_toggle.highlight_toggle("organization");
|
2021-02-28 01:23:35 +01:00
|
|
|
}
|