2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-06-21 10:52:02 +02:00
|
|
|
import render_settings_deactivate_realm_modal from "../templates/confirm_dialog/confirm_deactivate_realm.hbs";
|
2021-02-28 01:20:46 +01:00
|
|
|
import render_settings_admin_auth_methods_list from "../templates/settings/admin_auth_methods_list.hbs";
|
|
|
|
|
2023-10-07 00:09:47 +02:00
|
|
|
import * as audible_notifications from "./audible_notifications";
|
2021-03-16 23:38:59 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as channel from "./channel";
|
2021-03-25 23:20:18 +01:00
|
|
|
import {csrf_token} from "./csrf";
|
2022-10-11 14:20:27 +02:00
|
|
|
import * as dialog_widget from "./dialog_widget";
|
2023-07-19 16:14:00 +02:00
|
|
|
import * as dropdown_widget from "./dropdown_widget";
|
2022-05-03 08:06:40 +02:00
|
|
|
import {$t, $t_html, get_language_name} from "./i18n";
|
2022-09-28 08:27:24 +02:00
|
|
|
import * as keydown_util from "./keydown_util";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as loading from "./loading";
|
2024-01-13 21:01:07 +01:00
|
|
|
import * as pygments_data from "./pygments_data";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as realm_icon from "./realm_icon";
|
|
|
|
import * as realm_logo from "./realm_logo";
|
2021-09-28 09:09:52 +02:00
|
|
|
import {realm_user_settings_defaults} from "./realm_user_settings_defaults";
|
2023-10-09 23:29:16 +02:00
|
|
|
import * as settings_components from "./settings_components";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as settings_config from "./settings_config";
|
2023-01-20 18:29:34 +01:00
|
|
|
import * as settings_data from "./settings_data";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as settings_notifications from "./settings_notifications";
|
2021-07-20 14:51:48 +02:00
|
|
|
import * as settings_realm_domains from "./settings_realm_domains";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as settings_ui from "./settings_ui";
|
2024-02-13 02:08:24 +01:00
|
|
|
import {current_user, realm} from "./state_data";
|
2021-04-04 15:15:18 +02:00
|
|
|
import * as stream_settings_data from "./stream_settings_data";
|
2021-02-28 01:20:46 +01:00
|
|
|
import * as ui_report from "./ui_report";
|
2023-08-03 16:06:40 +02:00
|
|
|
import * as user_groups from "./user_groups";
|
2024-01-05 15:27:32 +01:00
|
|
|
import * as util from "./util";
|
2021-02-28 01:20:46 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const meta = {
|
2017-04-08 18:13:39 +02:00
|
|
|
loaded: false,
|
|
|
|
};
|
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function reset() {
|
2017-04-17 16:51:27 +02:00
|
|
|
meta.loaded = false;
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2017-04-17 16:51:27 +02:00
|
|
|
|
2023-07-19 16:14:00 +02:00
|
|
|
const DISABLED_STATE_ID = -1;
|
2023-01-20 13:25:32 +01:00
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function maybe_disable_widgets() {
|
2024-02-13 02:08:16 +01:00
|
|
|
if (current_user.is_owner) {
|
2020-06-11 13:26:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-11 16:24:15 +02:00
|
|
|
$(".organization-box [data-name='auth-methods']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find("input, button, select, checked")
|
2020-07-22 02:59:06 +02:00
|
|
|
.prop("disabled", true);
|
2020-06-11 16:24:15 +02:00
|
|
|
|
2024-02-13 02:08:16 +01:00
|
|
|
if (current_user.is_admin) {
|
2022-10-11 14:20:27 +02:00
|
|
|
$(".deactivate_realm_button").prop("disabled", true);
|
2023-01-25 18:50:46 +01:00
|
|
|
$("#deactivate_realm_button_container").addClass("disabled_setting_tooltip");
|
2020-07-22 02:59:06 +02:00
|
|
|
$("#org-message-retention").find("input, select").prop("disabled", true);
|
2023-08-03 16:06:40 +02:00
|
|
|
$("#org-join-settings").find("input, select, button").prop("disabled", true);
|
2021-07-29 13:53:27 +02:00
|
|
|
$("#id_realm_invite_required_label").parent().addClass("control-label-disabled");
|
2018-12-08 17:37:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$(".organization-box [data-name='organization-profile']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find("input, textarea, button, select")
|
2020-07-22 02:59:06 +02:00
|
|
|
.prop("disabled", true);
|
2018-12-08 17:37:57 +01:00
|
|
|
|
2023-01-05 16:59:18 +01:00
|
|
|
$(".organization-box [data-name='organization-profile']").find(".image_upload_button").hide();
|
|
|
|
|
2018-12-08 17:37:57 +01:00
|
|
|
$(".organization-box [data-name='organization-settings']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find("input, textarea, button, select")
|
2020-07-22 02:59:06 +02:00
|
|
|
.prop("disabled", true);
|
2018-12-08 17:37:57 +01:00
|
|
|
|
2021-11-16 10:40:36 +01:00
|
|
|
$(".organization-box [data-name='organization-settings']")
|
|
|
|
.find(".dropdown_list_reset_button")
|
|
|
|
.hide();
|
|
|
|
|
2018-12-08 17:37:57 +01:00
|
|
|
$(".organization-box [data-name='organization-settings']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find(".control-label-disabled")
|
|
|
|
.addClass("enabled");
|
2018-12-08 17:37:57 +01:00
|
|
|
|
|
|
|
$(".organization-box [data-name='organization-permissions']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find("input, textarea, button, select")
|
2020-07-22 02:59:06 +02:00
|
|
|
.prop("disabled", true);
|
2018-12-08 17:37:57 +01:00
|
|
|
|
|
|
|
$(".organization-box [data-name='organization-permissions']")
|
2020-07-15 00:34:28 +02:00
|
|
|
.find(".control-label-disabled")
|
|
|
|
.addClass("enabled");
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2018-12-08 17:37:57 +01:00
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function get_organization_settings_options() {
|
2020-01-23 07:01:34 +01:00
|
|
|
const options = {};
|
2023-10-09 23:29:16 +02:00
|
|
|
options.common_policy_values = settings_components.get_sorted_options_list(
|
|
|
|
settings_config.common_policy_values,
|
|
|
|
);
|
|
|
|
options.private_message_policy_values = settings_components.get_sorted_options_list(
|
2020-07-15 00:34:28 +02:00
|
|
|
settings_config.private_message_policy_values,
|
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
options.wildcard_mention_policy_values = settings_components.get_sorted_options_list(
|
2020-09-14 19:26:42 +02:00
|
|
|
settings_config.wildcard_mention_policy_values,
|
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
options.common_message_policy_values = settings_components.get_sorted_options_list(
|
2021-05-26 12:21:37 +02:00
|
|
|
settings_config.common_message_policy_values,
|
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
options.invite_to_realm_policy_values = settings_components.get_sorted_options_list(
|
2023-06-26 23:38:08 +02:00
|
|
|
settings_config.email_invite_to_realm_policy_values,
|
2021-07-18 18:18:28 +02:00
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
options.edit_topic_policy_values = settings_components.get_sorted_options_list(
|
2022-09-28 16:30:10 +02:00
|
|
|
settings_config.edit_topic_policy_values,
|
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
options.move_messages_between_streams_policy_values =
|
|
|
|
settings_components.get_sorted_options_list(
|
|
|
|
settings_config.move_messages_between_streams_policy_values,
|
|
|
|
);
|
2020-01-23 07:01:34 +01:00
|
|
|
return options;
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2020-01-23 07:01:34 +01:00
|
|
|
|
2022-04-12 17:41:07 +02:00
|
|
|
export function get_org_type_dropdown_options() {
|
2024-02-13 02:08:24 +01:00
|
|
|
const current_org_type = realm.realm_org_type;
|
2022-04-12 17:41:07 +02:00
|
|
|
if (current_org_type !== 0) {
|
|
|
|
return settings_config.defined_org_type_values;
|
|
|
|
}
|
|
|
|
return settings_config.all_org_type_values;
|
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const simple_dropdown_properties = [
|
2021-03-27 05:48:37 +01:00
|
|
|
"realm_create_private_stream_policy",
|
|
|
|
"realm_create_public_stream_policy",
|
2021-11-19 10:29:39 +01:00
|
|
|
"realm_create_web_public_stream_policy",
|
2020-07-15 00:34:28 +02:00
|
|
|
"realm_invite_to_stream_policy",
|
|
|
|
"realm_user_group_edit_policy",
|
|
|
|
"realm_private_message_policy",
|
2021-05-04 19:02:24 +02:00
|
|
|
"realm_add_custom_emoji_policy",
|
2021-05-23 21:40:20 +02:00
|
|
|
"realm_invite_to_realm_policy",
|
2020-09-14 19:26:42 +02:00
|
|
|
"realm_wildcard_mention_policy",
|
2021-04-30 09:35:20 +02:00
|
|
|
"realm_move_messages_between_streams_policy",
|
2021-05-26 12:21:37 +02:00
|
|
|
"realm_edit_topic_policy",
|
2022-04-12 17:41:07 +02:00
|
|
|
"realm_org_type",
|
2020-07-15 00:34:28 +02:00
|
|
|
];
|
2020-02-03 12:40:36 +01:00
|
|
|
|
2022-12-12 18:21:08 +01:00
|
|
|
function set_realm_waiting_period_setting() {
|
2024-02-13 02:08:24 +01:00
|
|
|
const setting_value = realm.realm_waiting_period_threshold;
|
2022-12-12 18:21:08 +01:00
|
|
|
const valid_limit_values = settings_config.waiting_period_threshold_dropdown_values.map(
|
|
|
|
(x) => x.code,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (valid_limit_values.includes(setting_value)) {
|
|
|
|
$("#id_realm_waiting_period_threshold").val(setting_value);
|
|
|
|
} else {
|
|
|
|
$("#id_realm_waiting_period_threshold").val("custom_period");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#id_realm_waiting_period_threshold_custom_input").val(setting_value);
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2022-12-13 12:32:01 +01:00
|
|
|
"id_realm_waiting_period_threshold_custom_input",
|
2022-12-12 18:21:08 +01:00
|
|
|
$("#id_realm_waiting_period_threshold").val() === "custom_period",
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2018-04-01 08:49:10 +02:00
|
|
|
}
|
2018-01-05 15:34:10 +01:00
|
|
|
|
2023-09-19 18:10:23 +02:00
|
|
|
function update_jitsi_server_url_custom_input(dropdown_val) {
|
|
|
|
const custom_input = "id_realm_jitsi_server_url_custom_input";
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
|
|
|
custom_input,
|
|
|
|
dropdown_val === "custom",
|
|
|
|
);
|
2023-09-19 18:10:23 +02:00
|
|
|
|
|
|
|
if (dropdown_val !== "custom") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const $custom_input_elem = $(`#${CSS.escape(custom_input)}`);
|
2024-02-13 02:08:24 +01:00
|
|
|
$custom_input_elem.val(realm.realm_jitsi_server_url);
|
2023-09-19 18:10:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_jitsi_server_url_dropdown() {
|
2023-10-09 23:29:16 +02:00
|
|
|
if (!settings_components.is_video_chat_provider_jitsi_meet()) {
|
2023-09-19 18:10:23 +02:00
|
|
|
$("#realm_jitsi_server_url_setting").hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#realm_jitsi_server_url_setting").show();
|
|
|
|
|
|
|
|
let dropdown_val = "server_default";
|
2024-02-13 02:08:24 +01:00
|
|
|
if (realm.realm_jitsi_server_url) {
|
2023-09-19 18:10:23 +02:00
|
|
|
dropdown_val = "custom";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#id_realm_jitsi_server_url").val(dropdown_val);
|
|
|
|
update_jitsi_server_url_custom_input(dropdown_val);
|
|
|
|
}
|
|
|
|
|
2018-04-23 14:51:30 +02:00
|
|
|
function set_video_chat_provider_dropdown() {
|
2024-02-13 02:08:24 +01:00
|
|
|
const chat_provider_id = realm.realm_video_chat_provider;
|
2019-05-09 09:54:38 +02:00
|
|
|
$("#id_realm_video_chat_provider").val(chat_provider_id);
|
2023-09-19 18:10:23 +02:00
|
|
|
|
|
|
|
set_jitsi_server_url_dropdown();
|
2018-04-23 14:51:30 +02:00
|
|
|
}
|
|
|
|
|
2021-04-27 21:58:19 +02:00
|
|
|
function set_giphy_rating_dropdown() {
|
2024-02-13 02:08:24 +01:00
|
|
|
const rating_id = realm.realm_giphy_rating;
|
2021-04-27 21:58:19 +02:00
|
|
|
$("#id_realm_giphy_rating").val(rating_id);
|
|
|
|
}
|
|
|
|
|
2022-04-12 09:56:58 +02:00
|
|
|
function update_message_edit_sub_settings(is_checked) {
|
2022-08-19 16:14:15 +02:00
|
|
|
settings_ui.disable_sub_setting_onchange(
|
|
|
|
is_checked,
|
|
|
|
"id_realm_message_content_edit_limit_seconds",
|
|
|
|
true,
|
|
|
|
);
|
2022-04-12 09:56:58 +02:00
|
|
|
settings_ui.disable_sub_setting_onchange(
|
|
|
|
is_checked,
|
|
|
|
"id_realm_message_content_edit_limit_minutes",
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-08 12:19:16 +02:00
|
|
|
function set_msg_edit_limit_dropdown() {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_time_limit_setting("realm_message_content_edit_limit_seconds");
|
2022-09-08 12:19:16 +02:00
|
|
|
}
|
|
|
|
|
2022-12-22 19:14:23 +01:00
|
|
|
function message_move_limit_setting_enabled(related_setting_name) {
|
|
|
|
const setting_value = Number.parseInt($(`#id_${CSS.escape(related_setting_name)}`).val(), 10);
|
|
|
|
|
|
|
|
let settings_options;
|
|
|
|
if (related_setting_name === "realm_edit_topic_policy") {
|
|
|
|
settings_options = settings_config.edit_topic_policy_values;
|
|
|
|
} else {
|
|
|
|
settings_options = settings_config.move_messages_between_streams_policy_values;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setting_value === settings_options.by_admins_only.code) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setting_value === settings_options.by_moderators_only.code) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setting_value === settings_options.nobody.code) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function enable_or_disable_related_message_move_time_limit_setting(setting_name, disable_setting) {
|
|
|
|
const $setting_elem = $(`#id_${CSS.escape(setting_name)}`);
|
|
|
|
const $custom_input_elem = $setting_elem.parent().find(".time-limit-custom-input");
|
|
|
|
|
|
|
|
settings_ui.disable_sub_setting_onchange(disable_setting, $setting_elem.attr("id"), true);
|
|
|
|
settings_ui.disable_sub_setting_onchange(disable_setting, $custom_input_elem.attr("id"), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_msg_move_limit_setting(property_name) {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_time_limit_setting(property_name);
|
2023-01-30 12:15:36 +01:00
|
|
|
|
|
|
|
let disable_setting;
|
|
|
|
if (property_name === "realm_move_messages_within_stream_limit_seconds") {
|
|
|
|
disable_setting = message_move_limit_setting_enabled("realm_edit_topic_policy");
|
|
|
|
} else {
|
|
|
|
disable_setting = message_move_limit_setting_enabled(
|
|
|
|
"realm_move_messages_between_streams_policy",
|
|
|
|
);
|
|
|
|
}
|
2022-12-22 19:14:23 +01:00
|
|
|
enable_or_disable_related_message_move_time_limit_setting(property_name, disable_setting);
|
|
|
|
}
|
|
|
|
|
2022-08-18 16:14:05 +02:00
|
|
|
function message_delete_limit_setting_enabled(setting_value) {
|
2021-06-23 12:53:38 +02:00
|
|
|
// This function is used to check whether the time-limit setting
|
|
|
|
// should be enabled. The setting is disabled when delete_own_message_policy
|
|
|
|
// is set to 'admins only' as admins can delete messages irrespective of
|
|
|
|
// time limit.
|
2022-08-18 16:14:05 +02:00
|
|
|
if (setting_value === settings_config.common_message_policy_values.by_admins_only.code) {
|
2021-06-23 12:53:38 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-08-18 16:14:05 +02:00
|
|
|
function set_delete_own_message_policy_dropdown(setting_value) {
|
|
|
|
$("#id_realm_delete_own_message_policy").val(setting_value);
|
2021-06-08 13:45:14 +02:00
|
|
|
settings_ui.disable_sub_setting_onchange(
|
2022-08-18 16:14:05 +02:00
|
|
|
message_delete_limit_setting_enabled(setting_value),
|
2022-08-19 16:47:26 +02:00
|
|
|
"id_realm_message_content_delete_limit_seconds",
|
2021-06-08 13:45:14 +02:00
|
|
|
true,
|
|
|
|
);
|
2023-10-09 23:29:16 +02:00
|
|
|
const limit_setting_dropdown_value = settings_components.get_time_limit_dropdown_setting_value(
|
2022-09-02 13:07:11 +02:00
|
|
|
"realm_message_content_delete_limit_seconds",
|
|
|
|
);
|
|
|
|
if (limit_setting_dropdown_value === "custom_period") {
|
2021-06-08 13:45:14 +02:00
|
|
|
settings_ui.disable_sub_setting_onchange(
|
2022-08-18 16:14:05 +02:00
|
|
|
message_delete_limit_setting_enabled(setting_value),
|
2021-06-08 13:45:14 +02:00
|
|
|
"id_realm_message_content_delete_limit_minutes",
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-26 09:12:10 +01:00
|
|
|
function set_msg_delete_limit_dropdown() {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_time_limit_setting("realm_message_content_delete_limit_seconds");
|
2022-11-04 11:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_dropdown_value_for_message_retention_setting(setting_value) {
|
|
|
|
if (setting_value === settings_config.retain_message_forever) {
|
2022-11-04 11:11:33 +01:00
|
|
|
return "unlimited";
|
2022-11-04 11:11:33 +01:00
|
|
|
}
|
|
|
|
|
2022-10-18 11:03:09 +02:00
|
|
|
if (setting_value === null) {
|
|
|
|
return "realm_default";
|
|
|
|
}
|
|
|
|
|
2022-11-04 11:11:33 +01:00
|
|
|
return "custom_period";
|
2022-11-04 11:11:33 +01:00
|
|
|
}
|
|
|
|
|
2022-10-18 11:03:09 +02:00
|
|
|
export function set_message_retention_setting_dropdown(sub) {
|
|
|
|
let property_name = "realm_message_retention_days";
|
2024-05-20 21:36:38 +02:00
|
|
|
let setting_value;
|
2022-10-18 11:03:09 +02:00
|
|
|
if (sub !== undefined) {
|
|
|
|
property_name = "message_retention_days";
|
2024-05-20 21:36:38 +02:00
|
|
|
setting_value = settings_components.get_stream_settings_property_value(property_name, sub);
|
|
|
|
} else {
|
|
|
|
setting_value = settings_components.get_realm_settings_property_value(property_name);
|
2022-10-18 11:03:09 +02:00
|
|
|
}
|
2022-11-04 11:11:33 +01:00
|
|
|
const dropdown_val = get_dropdown_value_for_message_retention_setting(setting_value);
|
2022-11-04 11:11:33 +01:00
|
|
|
|
2022-11-04 11:11:33 +01:00
|
|
|
const $dropdown_elem = $(`#id_${CSS.escape(property_name)}`);
|
|
|
|
$dropdown_elem.val(dropdown_val);
|
2022-11-04 11:11:33 +01:00
|
|
|
|
2022-11-04 11:11:33 +01:00
|
|
|
const $custom_input_elem = $dropdown_elem
|
|
|
|
.parent()
|
|
|
|
.find(".message-retention-setting-custom-input")
|
|
|
|
.val("");
|
|
|
|
if (dropdown_val === "custom_period") {
|
|
|
|
$custom_input_elem.val(setting_value);
|
2020-06-21 11:35:02 +02:00
|
|
|
}
|
2022-11-04 11:11:33 +01:00
|
|
|
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2022-11-04 11:11:33 +01:00
|
|
|
$custom_input_elem.attr("id"),
|
|
|
|
dropdown_val === "custom_period",
|
|
|
|
);
|
2020-05-07 13:19:54 +02:00
|
|
|
}
|
|
|
|
|
2018-04-05 00:54:31 +02:00
|
|
|
function set_org_join_restrictions_dropdown() {
|
2024-05-20 21:36:38 +02:00
|
|
|
const value = settings_components.get_realm_settings_property_value(
|
|
|
|
"realm_org_join_restrictions",
|
|
|
|
);
|
2018-04-05 00:54:31 +02:00
|
|
|
$("#id_realm_org_join_restrictions").val(value);
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2020-07-15 00:34:28 +02:00
|
|
|
"allowed_domains_label",
|
|
|
|
value === "only_selected_domain",
|
|
|
|
);
|
2018-04-05 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
2023-01-02 20:50:23 +01:00
|
|
|
function set_message_content_in_email_notifications_visibility() {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2020-07-15 01:29:15 +02:00
|
|
|
"message_content_in_email_notifications_label",
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.realm_message_content_allowed_in_email_notifications,
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2019-01-14 14:04:08 +01:00
|
|
|
}
|
|
|
|
|
2019-05-08 08:11:30 +02:00
|
|
|
function set_digest_emails_weekday_visibility() {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2020-07-15 00:34:28 +02:00
|
|
|
"id_realm_digest_weekday",
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.realm_digest_emails_enabled,
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2019-05-08 08:11:30 +02:00
|
|
|
}
|
|
|
|
|
2021-11-19 10:29:39 +01:00
|
|
|
function set_create_web_public_stream_dropdown_visibility() {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2021-11-19 10:29:39 +01:00
|
|
|
"id_realm_create_web_public_stream_policy",
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.server_web_public_streams_enabled &&
|
|
|
|
realm.zulip_plan_is_not_limited &&
|
|
|
|
realm.realm_enable_spectator_access,
|
2021-11-19 10:29:39 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-20 14:51:48 +02:00
|
|
|
export function populate_realm_domains_label(realm_domains) {
|
2017-04-08 18:13:39 +02:00
|
|
|
if (!meta.loaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const domains_list = realm_domains.map((realm_domain) =>
|
|
|
|
realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain,
|
js: Convert _.map(a, …) to a.map(…).
And convert the corresponding function expressions to arrow style
while we’re here.
import * as babelParser from "recast/parsers/babel";
import * as recast from "recast";
import * as tsParser from "recast/parsers/typescript";
import { builders as b, namedTypes as n } from "ast-types";
import K from "ast-types/gen/kinds";
import fs from "fs";
import path from "path";
import process from "process";
const checkExpression = (node: n.Node): node is K.ExpressionKind =>
n.Expression.check(node);
for (const file of process.argv.slice(2)) {
console.log("Parsing", file);
const ast = recast.parse(fs.readFileSync(file, { encoding: "utf8" }), {
parser: path.extname(file) === ".ts" ? tsParser : babelParser,
});
let changed = false;
recast.visit(ast, {
visitCallExpression(path) {
const { callee, arguments: args } = path.node;
if (
n.MemberExpression.check(callee) &&
!callee.computed &&
n.Identifier.check(callee.object) &&
callee.object.name === "_" &&
n.Identifier.check(callee.property) &&
callee.property.name === "map" &&
args.length === 2 &&
checkExpression(args[0]) &&
checkExpression(args[1])
) {
const [arr, fn] = args;
path.replace(
b.callExpression(b.memberExpression(arr, b.identifier("map")), [
n.FunctionExpression.check(fn) ||
n.ArrowFunctionExpression.check(fn)
? b.arrowFunctionExpression(
fn.params,
n.BlockStatement.check(fn.body) &&
fn.body.body.length === 1 &&
n.ReturnStatement.check(fn.body.body[0])
? fn.body.body[0].argument || b.identifier("undefined")
: fn.body
)
: fn,
])
);
changed = true;
}
this.traverse(path);
},
});
if (changed) {
console.log("Writing", file);
fs.writeFileSync(file, recast.print(ast).code, { encoding: "utf8" });
}
}
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-08 02:43:49 +01:00
|
|
|
);
|
2024-01-05 15:27:32 +01:00
|
|
|
let domains = util.format_array_as_list(domains_list, "long", "conjunction");
|
2017-04-08 18:13:39 +02:00
|
|
|
if (domains.length === 0) {
|
2021-04-13 06:51:54 +02:00
|
|
|
domains = $t({defaultMessage: "None"});
|
2017-04-08 18:13:39 +02:00
|
|
|
}
|
2021-04-13 06:51:54 +02:00
|
|
|
$("#allowed_domains_label").text($t({defaultMessage: "Allowed domains: {domains}"}, {domains}));
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
|
|
|
|
2023-01-20 18:29:34 +01:00
|
|
|
function can_configure_auth_methods() {
|
|
|
|
if (settings_data.user_email_not_configured()) {
|
|
|
|
return false;
|
|
|
|
}
|
2024-02-13 02:08:16 +01:00
|
|
|
if (current_user.is_owner) {
|
2023-01-20 18:29:34 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:52:25 +01:00
|
|
|
export function populate_auth_methods(auth_method_to_bool_map) {
|
2017-04-08 18:13:39 +02:00
|
|
|
if (!meta.loaded) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-07 10:14:13 +02:00
|
|
|
const $auth_methods_list = $("#id_realm_authentication_methods").expectOne();
|
2019-11-02 00:06:25 +01:00
|
|
|
let rendered_auth_method_rows = "";
|
2024-02-05 23:52:25 +01:00
|
|
|
for (const [auth_method, value] of Object.entries(auth_method_to_bool_map)) {
|
|
|
|
// Certain authentication methods are not available to be enabled without
|
|
|
|
// purchasing a plan, so we need to disable them in this UI.
|
|
|
|
// The restriction only applies to **enabling** the auth method, so this
|
|
|
|
// logic is dependent on the current value.
|
|
|
|
// The reason for that is that if for any reason, the auth method is already
|
|
|
|
// enabled (for example, because it was manually enabled for the organization
|
|
|
|
// by request, as an exception) - the organization should be able to disable it
|
|
|
|
// if they don't want it anymore.
|
|
|
|
const cant_be_enabled =
|
|
|
|
!realm.realm_authentication_methods[auth_method].available && !value;
|
|
|
|
|
|
|
|
const render_args = {
|
2019-04-06 08:43:34 +02:00
|
|
|
method: auth_method,
|
|
|
|
enabled: value,
|
2024-02-05 23:52:25 +01:00
|
|
|
disable_configure_auth_method: !can_configure_auth_methods() || cant_be_enabled,
|
2022-07-07 10:12:16 +02:00
|
|
|
// The negated character class regexp serves as an allowlist - the replace() will
|
|
|
|
// remove *all* symbols *but* digits (\d) and lowecase letters (a-z),
|
|
|
|
// so that we can make assumptions on this string elsewhere in the code.
|
|
|
|
// As a result, the only two "incoming" assumptions on the auth method name are:
|
|
|
|
// 1) It contains at least one allowed symbol
|
|
|
|
// 2) No two auth method names are identical after this allowlist filtering
|
2023-05-11 21:49:10 +02:00
|
|
|
prefix: "id_authmethod" + auth_method.toLowerCase().replaceAll(/[^\da-z]/g, "") + "_",
|
2024-02-05 23:52:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if (cant_be_enabled) {
|
|
|
|
render_args.unavailable_reason =
|
|
|
|
realm.realm_authentication_methods[auth_method].unavailable_reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
rendered_auth_method_rows += render_settings_admin_auth_methods_list(render_args);
|
2020-02-06 04:27:31 +01:00
|
|
|
}
|
2022-07-07 10:14:13 +02:00
|
|
|
$auth_methods_list.html(rendered_auth_method_rows);
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2017-04-08 18:13:39 +02:00
|
|
|
|
2018-04-01 08:56:18 +02:00
|
|
|
function update_dependent_subsettings(property_name) {
|
js: Convert a.indexOf(…) !== -1 to a.includes(…).
Babel polyfills this for us for Internet Explorer.
import * as babelParser from "recast/parsers/babel";
import * as recast from "recast";
import * as tsParser from "recast/parsers/typescript";
import { builders as b, namedTypes as n } from "ast-types";
import K from "ast-types/gen/kinds";
import fs from "fs";
import path from "path";
import process from "process";
const checkExpression = (node: n.Node): node is K.ExpressionKind =>
n.Expression.check(node);
for (const file of process.argv.slice(2)) {
console.log("Parsing", file);
const ast = recast.parse(fs.readFileSync(file, { encoding: "utf8" }), {
parser: path.extname(file) === ".ts" ? tsParser : babelParser,
});
let changed = false;
recast.visit(ast, {
visitBinaryExpression(path) {
const { operator, left, right } = path.node;
if (
n.CallExpression.check(left) &&
n.MemberExpression.check(left.callee) &&
!left.callee.computed &&
n.Identifier.check(left.callee.property) &&
left.callee.property.name === "indexOf" &&
left.arguments.length === 1 &&
checkExpression(left.arguments[0]) &&
((["===", "!==", "==", "!=", ">", "<="].includes(operator) &&
n.UnaryExpression.check(right) &&
right.operator == "-" &&
n.Literal.check(right.argument) &&
right.argument.value === 1) ||
([">=", "<"].includes(operator) &&
n.Literal.check(right) &&
right.value === 0))
) {
const test = b.callExpression(
b.memberExpression(left.callee.object, b.identifier("includes")),
[left.arguments[0]]
);
path.replace(
["!==", "!=", ">", ">="].includes(operator)
? test
: b.unaryExpression("!", test)
);
changed = true;
}
this.traverse(path);
},
});
if (changed) {
console.log("Writing", file);
fs.writeFileSync(file, recast.print(ast).code, { encoding: "utf8" });
}
}
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-08 04:55:06 +01:00
|
|
|
if (simple_dropdown_properties.includes(property_name)) {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_property_dropdown_value(property_name);
|
2021-05-09 23:36:58 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (property_name) {
|
2022-04-12 09:56:58 +02:00
|
|
|
case "realm_allow_message_editing":
|
2024-02-13 02:08:24 +01:00
|
|
|
update_message_edit_sub_settings(realm.realm_allow_message_editing);
|
2022-04-12 09:56:58 +02:00
|
|
|
break;
|
2021-06-08 13:45:14 +02:00
|
|
|
case "realm_delete_own_message_policy":
|
2024-02-13 02:08:24 +01:00
|
|
|
set_delete_own_message_policy_dropdown(realm.realm_delete_own_message_policy);
|
2021-06-08 13:45:14 +02:00
|
|
|
break;
|
2021-05-09 23:36:58 +02:00
|
|
|
case "realm_org_join_restrictions":
|
|
|
|
set_org_join_restrictions_dropdown();
|
|
|
|
break;
|
|
|
|
case "realm_message_content_allowed_in_email_notifications":
|
2023-01-02 20:50:23 +01:00
|
|
|
set_message_content_in_email_notifications_visibility();
|
2021-05-09 23:36:58 +02:00
|
|
|
break;
|
|
|
|
case "realm_digest_emails_enabled":
|
2021-08-26 13:04:03 +02:00
|
|
|
settings_notifications.set_enable_digest_emails_visibility(
|
2023-10-10 02:07:30 +02:00
|
|
|
$("#user-notification-settings"),
|
|
|
|
false,
|
2021-08-26 13:04:03 +02:00
|
|
|
);
|
2021-09-16 12:47:12 +02:00
|
|
|
settings_notifications.set_enable_digest_emails_visibility(
|
2023-10-10 02:07:30 +02:00
|
|
|
$("#realm-user-default-settings"),
|
|
|
|
true,
|
2021-09-16 12:47:12 +02:00
|
|
|
);
|
2021-05-09 23:36:58 +02:00
|
|
|
set_digest_emails_weekday_visibility();
|
|
|
|
break;
|
2021-11-19 10:29:39 +01:00
|
|
|
case "realm_enable_spectator_access":
|
|
|
|
set_create_web_public_stream_dropdown_visibility();
|
|
|
|
break;
|
2018-03-29 12:52:57 +02:00
|
|
|
}
|
2018-04-01 08:49:10 +02:00
|
|
|
}
|
2018-03-29 12:52:57 +02:00
|
|
|
|
2024-05-20 21:36:38 +02:00
|
|
|
export function discard_realm_property_element_changes(elem) {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $elem = $(elem);
|
2024-05-20 21:36:38 +02:00
|
|
|
const property_name = settings_components.extract_property_name($elem);
|
|
|
|
const property_value = settings_components.get_realm_settings_property_value(property_name);
|
2018-03-29 12:58:35 +02:00
|
|
|
|
2021-05-09 23:36:58 +02:00
|
|
|
switch (property_name) {
|
|
|
|
case "realm_authentication_methods":
|
2024-03-27 11:03:24 +01:00
|
|
|
populate_auth_methods(
|
|
|
|
settings_components.realm_authentication_methods_to_boolean_dict(),
|
|
|
|
);
|
2021-05-09 23:36:58 +02:00
|
|
|
break;
|
2024-02-07 12:13:02 +01:00
|
|
|
case "realm_new_stream_announcements_stream_id":
|
2024-02-07 17:11:43 +01:00
|
|
|
case "realm_signup_announcements_stream_id":
|
2024-01-26 14:45:37 +01:00
|
|
|
case "realm_zulip_update_announcements_stream_id":
|
2021-05-09 23:36:58 +02:00
|
|
|
case "realm_default_code_block_language":
|
2023-08-03 16:06:40 +02:00
|
|
|
case "realm_create_multiuse_invite_group":
|
2023-11-23 10:14:35 +01:00
|
|
|
case "realm_can_access_all_users_group":
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_dropdown_list_widget_setting_value(
|
|
|
|
property_name,
|
|
|
|
property_value,
|
|
|
|
);
|
2021-05-09 23:36:58 +02:00
|
|
|
break;
|
2022-05-03 08:06:40 +02:00
|
|
|
case "realm_default_language":
|
|
|
|
$("#org-notifications .language_selection_widget .language_selection_button span").attr(
|
|
|
|
"data-language-code",
|
|
|
|
property_value,
|
|
|
|
);
|
|
|
|
$("#org-notifications .language_selection_widget .language_selection_button span").text(
|
|
|
|
get_language_name(property_value),
|
|
|
|
);
|
|
|
|
break;
|
2022-04-12 17:41:07 +02:00
|
|
|
case "realm_org_type":
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
2022-04-12 17:41:07 +02:00
|
|
|
// Remove 'unspecified' option (value=0) from realm_org_type
|
2024-02-13 02:08:24 +01:00
|
|
|
// dropdown menu options whenever realm.realm_org_type
|
2022-04-12 17:41:07 +02:00
|
|
|
// returns another value.
|
|
|
|
if (property_value !== 0) {
|
|
|
|
$("#id_realm_org_type option[value=0]").remove();
|
|
|
|
}
|
|
|
|
break;
|
2022-09-02 13:07:11 +02:00
|
|
|
case "realm_message_content_edit_limit_seconds":
|
|
|
|
case "realm_message_content_delete_limit_seconds":
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_time_limit_setting(property_name);
|
2022-06-03 19:20:32 +02:00
|
|
|
break;
|
2022-12-22 19:14:23 +01:00
|
|
|
case "realm_move_messages_within_stream_limit_seconds":
|
2023-01-30 12:15:36 +01:00
|
|
|
case "realm_move_messages_between_streams_limit_seconds":
|
2022-12-22 19:14:23 +01:00
|
|
|
set_msg_move_limit_setting(property_name);
|
|
|
|
break;
|
2023-09-03 05:17:14 +02:00
|
|
|
case "realm_video_chat_provider":
|
|
|
|
set_video_chat_provider_dropdown();
|
|
|
|
break;
|
2023-09-19 18:10:23 +02:00
|
|
|
case "realm_jitsi_server_url":
|
|
|
|
set_jitsi_server_url_dropdown();
|
|
|
|
break;
|
2022-11-04 11:11:33 +01:00
|
|
|
case "realm_message_retention_days":
|
2024-05-21 15:06:33 +02:00
|
|
|
set_message_retention_setting_dropdown(undefined);
|
|
|
|
break;
|
2022-12-12 18:21:08 +01:00
|
|
|
case "realm_waiting_period_threshold":
|
|
|
|
set_realm_waiting_period_setting();
|
|
|
|
break;
|
2021-05-09 23:36:58 +02:00
|
|
|
default:
|
|
|
|
if (property_value !== undefined) {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
2021-05-09 23:36:58 +02:00
|
|
|
} else {
|
2023-04-24 15:57:45 +02:00
|
|
|
blueslip.error("Element refers to unknown property", {property_name});
|
2021-05-09 23:36:58 +02:00
|
|
|
}
|
2018-03-29 12:58:35 +02:00
|
|
|
}
|
2024-05-20 21:36:38 +02:00
|
|
|
update_dependent_subsettings(property_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function discard_stream_property_element_changes(elem, sub) {
|
|
|
|
const $elem = $(elem);
|
|
|
|
const property_name = settings_components.extract_property_name($elem);
|
|
|
|
const property_value = settings_components.get_stream_settings_property_value(
|
|
|
|
property_name,
|
|
|
|
sub,
|
|
|
|
);
|
|
|
|
switch (property_name) {
|
|
|
|
case "can_remove_subscribers_group":
|
|
|
|
settings_components.set_dropdown_list_widget_setting_value(
|
|
|
|
property_name,
|
|
|
|
property_value,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case "stream_privacy": {
|
|
|
|
$elem.find(`input[value='${CSS.escape(property_value)}']`).prop("checked", true);
|
2018-03-29 12:58:35 +02:00
|
|
|
|
2024-05-20 21:36:38 +02:00
|
|
|
// Hide stream privacy warning banner
|
|
|
|
const $stream_permissions_warning_banner = $(
|
|
|
|
"#stream_permission_settings .stream-permissions-warning-banner",
|
|
|
|
);
|
|
|
|
if (!$stream_permissions_warning_banner.is(":empty")) {
|
|
|
|
$stream_permissions_warning_banner.empty();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "message_retention_days":
|
|
|
|
set_message_retention_setting_dropdown(sub);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (property_value !== undefined) {
|
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
|
|
|
} else {
|
|
|
|
blueslip.error("Element refers to unknown property", {property_name});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update_dependent_subsettings(property_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function discard_group_property_element_changes(elem, group) {
|
|
|
|
const $elem = $(elem);
|
|
|
|
const property_name = settings_components.extract_property_name($elem);
|
|
|
|
const property_value = settings_components.get_group_property_value(property_name, group);
|
|
|
|
|
|
|
|
if (property_name === "can_mention_group") {
|
|
|
|
settings_components.set_dropdown_list_widget_setting_value(property_name, property_value);
|
|
|
|
} else if (property_value !== undefined) {
|
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
|
|
|
} else {
|
|
|
|
blueslip.error("Element refers to unknown property", {property_name});
|
|
|
|
}
|
|
|
|
update_dependent_subsettings(property_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function discard_realm_default_property_element_changes(elem) {
|
|
|
|
const $elem = $(elem);
|
|
|
|
const property_name = settings_components.extract_property_name($elem, true);
|
|
|
|
const property_value =
|
|
|
|
settings_components.get_realm_default_setting_property_value(property_name);
|
|
|
|
switch (property_name) {
|
|
|
|
case "notification_sound":
|
|
|
|
audible_notifications.update_notification_sound_source(
|
|
|
|
$("audio#realm-default-notification-sound-audio"),
|
|
|
|
{
|
|
|
|
notification_sound: property_value,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
|
|
|
break;
|
|
|
|
case "emojiset":
|
|
|
|
case "user_list_style":
|
|
|
|
// Because this widget has a radio button structure, it
|
|
|
|
// needs custom reset code.
|
|
|
|
$elem.find(`input[value='${CSS.escape(property_value)}']`).prop("checked", true);
|
|
|
|
break;
|
|
|
|
case "email_notifications_batching_period_seconds":
|
|
|
|
case "email_notification_batching_period_edit_minutes":
|
|
|
|
settings_notifications.set_notification_batching_ui(
|
|
|
|
$("#realm-user-default-settings"),
|
|
|
|
realm_user_settings_defaults.email_notifications_batching_period_seconds,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (property_value !== undefined) {
|
|
|
|
settings_components.set_input_element_value($elem, property_value);
|
|
|
|
} else {
|
|
|
|
blueslip.error("Element refers to unknown property", {property_name});
|
|
|
|
}
|
|
|
|
}
|
2018-04-01 08:56:18 +02:00
|
|
|
update_dependent_subsettings(property_name);
|
2018-03-29 12:58:35 +02:00
|
|
|
}
|
|
|
|
|
2022-10-11 14:20:27 +02:00
|
|
|
export function deactivate_organization(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
function do_deactivate_realm() {
|
|
|
|
channel.post({
|
|
|
|
url: "/json/realm/deactivate",
|
|
|
|
error(xhr) {
|
|
|
|
ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $("#dialog_error"));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const html_body = render_settings_deactivate_realm_modal();
|
|
|
|
|
|
|
|
dialog_widget.launch({
|
|
|
|
html_heading: $t_html({defaultMessage: "Deactivate organization"}),
|
|
|
|
help_link: "/help/deactivate-your-organization",
|
|
|
|
html_body,
|
|
|
|
on_click: do_deactivate_realm,
|
|
|
|
close_on_submit: false,
|
|
|
|
focus_submit_on_open: true,
|
|
|
|
html_submit_button: $t_html({defaultMessage: "Confirm"}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function sync_realm_settings(property) {
|
2022-11-02 19:39:58 +01:00
|
|
|
if (!meta.loaded) {
|
2018-03-29 13:15:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-09 23:36:58 +02:00
|
|
|
switch (property) {
|
|
|
|
case "emails_restricted_to_domains":
|
|
|
|
case "disallow_disposable_email_addresses":
|
|
|
|
property = "org_join_restrictions";
|
|
|
|
break;
|
2020-07-15 01:29:15 +02:00
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
const $element = $(`#id_realm_${CSS.escape(property)}`);
|
|
|
|
if ($element.length) {
|
2024-05-20 21:36:38 +02:00
|
|
|
discard_realm_property_element_changes($element);
|
2018-03-29 13:15:50 +02:00
|
|
|
}
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2019-03-07 15:18:10 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
export function save_organization_settings(data, $save_button, patch_url) {
|
2022-11-03 13:18:42 +01:00
|
|
|
const $subsection_parent = $save_button.closest(".settings-subsection-parent");
|
2022-01-25 11:36:19 +01:00
|
|
|
const $save_btn_container = $subsection_parent.find(".save-button-controls");
|
|
|
|
const $failed_alert_elem = $subsection_parent.find(".subsection-failed-status p");
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_save_button_state($save_btn_container, "saving");
|
2021-09-28 15:56:47 +02:00
|
|
|
channel.patch({
|
2021-09-29 11:25:28 +02:00
|
|
|
url: patch_url,
|
2021-09-28 15:56:47 +02:00
|
|
|
data,
|
|
|
|
success() {
|
2022-01-25 11:36:19 +01:00
|
|
|
$failed_alert_elem.hide();
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_save_button_state($save_btn_container, "succeeded");
|
2021-09-28 15:56:47 +02:00
|
|
|
},
|
|
|
|
error(xhr) {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_save_button_state($save_btn_container, "failed");
|
2022-01-25 11:36:19 +01:00
|
|
|
$save_button.hide();
|
|
|
|
ui_report.error($t_html({defaultMessage: "Save failed"}), xhr, $failed_alert_elem);
|
2021-09-28 15:56:47 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function set_up() {
|
|
|
|
build_page();
|
|
|
|
maybe_disable_widgets();
|
|
|
|
}
|
2018-12-08 18:16:37 +01:00
|
|
|
|
2021-02-28 01:20:46 +01:00
|
|
|
export function init_dropdown_widgets() {
|
2023-07-19 16:14:00 +02:00
|
|
|
const notification_stream_options = () => {
|
|
|
|
const streams = stream_settings_data.get_streams_for_settings_page();
|
|
|
|
const options = streams.map((stream) => ({
|
|
|
|
name: stream.name,
|
|
|
|
unique_id: stream.stream_id,
|
|
|
|
stream,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const disabled_option = {
|
|
|
|
is_setting_disabled: true,
|
|
|
|
unique_id: DISABLED_STATE_ID,
|
2023-11-22 10:53:37 +01:00
|
|
|
name: $t({defaultMessage: "Disabled"}),
|
2023-07-19 16:14:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
options.unshift(disabled_option);
|
|
|
|
return options;
|
2020-04-10 09:38:55 +02:00
|
|
|
};
|
2023-07-19 16:14:00 +02:00
|
|
|
|
2024-02-07 12:13:02 +01:00
|
|
|
const new_stream_announcements_stream_widget = new dropdown_widget.DropdownWidget({
|
|
|
|
widget_name: "realm_new_stream_announcements_stream_id",
|
2023-07-19 16:14:00 +02:00
|
|
|
get_options: notification_stream_options,
|
|
|
|
$events_container: $("#settings_overlay_container #organization-settings"),
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2024-02-07 12:13:02 +01:00
|
|
|
settings_components.new_stream_announcements_stream_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-notifications"),
|
|
|
|
);
|
2023-07-19 16:14:00 +02:00
|
|
|
},
|
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
2024-02-07 12:13:02 +01:00
|
|
|
default_id: realm.realm_new_stream_announcements_stream_id,
|
2024-02-19 14:22:38 +01:00
|
|
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
2024-04-18 15:20:36 +02:00
|
|
|
text_if_current_value_not_in_options: $t({defaultMessage: "Cannot view channel"}),
|
2020-12-22 00:37:36 +01:00
|
|
|
});
|
2024-02-07 12:13:02 +01:00
|
|
|
settings_components.set_new_stream_announcements_stream_widget(
|
|
|
|
new_stream_announcements_stream_widget,
|
|
|
|
);
|
|
|
|
new_stream_announcements_stream_widget.setup();
|
2023-07-19 16:14:00 +02:00
|
|
|
|
2024-02-07 17:11:43 +01:00
|
|
|
const signup_announcements_stream_widget = new dropdown_widget.DropdownWidget({
|
|
|
|
widget_name: "realm_signup_announcements_stream_id",
|
2023-07-19 16:14:00 +02:00
|
|
|
get_options: notification_stream_options,
|
|
|
|
$events_container: $("#settings_overlay_container #organization-settings"),
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2024-02-07 17:11:43 +01:00
|
|
|
settings_components.signup_announcements_stream_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-notifications"),
|
|
|
|
);
|
2023-07-19 16:14:00 +02:00
|
|
|
},
|
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
2024-02-07 17:11:43 +01:00
|
|
|
default_id: realm.realm_signup_announcements_stream_id,
|
2024-02-19 14:22:38 +01:00
|
|
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
2024-04-18 15:20:36 +02:00
|
|
|
text_if_current_value_not_in_options: $t({defaultMessage: "Cannot view channel"}),
|
2020-12-22 00:37:36 +01:00
|
|
|
});
|
2024-02-07 17:11:43 +01:00
|
|
|
settings_components.set_signup_announcements_stream_widget(signup_announcements_stream_widget);
|
|
|
|
signup_announcements_stream_widget.setup();
|
2023-07-19 16:14:00 +02:00
|
|
|
|
2024-01-26 14:45:37 +01:00
|
|
|
const zulip_update_announcements_stream_widget = new dropdown_widget.DropdownWidget({
|
|
|
|
widget_name: "realm_zulip_update_announcements_stream_id",
|
|
|
|
get_options: notification_stream_options,
|
|
|
|
$events_container: $("#settings_overlay_container #organization-settings"),
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
settings_components.zulip_update_announcements_stream_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-notifications"),
|
|
|
|
);
|
2024-01-26 14:45:37 +01:00
|
|
|
},
|
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
|
|
|
default_id: realm.realm_zulip_update_announcements_stream_id,
|
|
|
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
2024-04-18 15:20:36 +02:00
|
|
|
text_if_current_value_not_in_options: $t({defaultMessage: "Cannot view channel"}),
|
2024-01-26 14:45:37 +01:00
|
|
|
});
|
|
|
|
settings_components.set_zulip_update_announcements_stream_widget(
|
|
|
|
zulip_update_announcements_stream_widget,
|
|
|
|
);
|
|
|
|
zulip_update_announcements_stream_widget.setup();
|
|
|
|
|
2023-10-09 23:29:16 +02:00
|
|
|
const default_code_language_widget = new dropdown_widget.DropdownWidget({
|
2020-07-15 01:29:15 +02:00
|
|
|
widget_name: "realm_default_code_block_language",
|
2023-07-19 16:14:00 +02:00
|
|
|
get_options() {
|
|
|
|
const options = Object.keys(pygments_data.langs).map((x) => ({
|
|
|
|
name: x,
|
|
|
|
unique_id: x,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const disabled_option = {
|
|
|
|
is_setting_disabled: true,
|
|
|
|
unique_id: "",
|
|
|
|
name: $t({defaultMessage: "No language set"}),
|
|
|
|
};
|
|
|
|
|
|
|
|
options.unshift(disabled_option);
|
|
|
|
return options;
|
|
|
|
},
|
|
|
|
$events_container: $("#settings_overlay_container #organization-settings"),
|
2024-02-13 02:08:24 +01:00
|
|
|
default_id: realm.realm_default_code_block_language,
|
2024-02-19 14:22:38 +01:00
|
|
|
unique_id_type: dropdown_widget.DataTypes.STRING,
|
2023-07-19 16:14:00 +02:00
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.default_code_language_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-other-settings"),
|
|
|
|
);
|
2020-04-30 13:09:48 +02:00
|
|
|
},
|
2020-04-10 09:38:55 +02:00
|
|
|
});
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_default_code_language_widget(default_code_language_widget);
|
2022-04-28 00:12:57 +02:00
|
|
|
default_code_language_widget.setup();
|
2023-08-03 16:06:40 +02:00
|
|
|
|
2023-10-09 23:29:16 +02:00
|
|
|
const create_multiuse_invite_group_widget = new dropdown_widget.DropdownWidget({
|
2023-08-03 16:06:40 +02:00
|
|
|
widget_name: "realm_create_multiuse_invite_group",
|
|
|
|
get_options: () =>
|
|
|
|
user_groups.get_realm_user_groups_for_dropdown_list_widget(
|
|
|
|
"create_multiuse_invite_group",
|
2023-10-31 04:36:05 +01:00
|
|
|
"realm",
|
2023-08-03 16:06:40 +02:00
|
|
|
),
|
|
|
|
$events_container: $("#settings_overlay_container #organization-permissions"),
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.create_multiuse_invite_group_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-join-settings"),
|
|
|
|
);
|
2023-08-03 16:06:40 +02:00
|
|
|
},
|
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
2024-02-13 02:08:24 +01:00
|
|
|
default_id: realm.realm_create_multiuse_invite_group,
|
2024-02-19 14:22:38 +01:00
|
|
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
2023-08-03 16:06:40 +02:00
|
|
|
on_mount_callback(dropdown) {
|
|
|
|
$(dropdown.popper).css("min-width", "300px");
|
|
|
|
},
|
|
|
|
});
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_create_multiuse_invite_group_widget(
|
|
|
|
create_multiuse_invite_group_widget,
|
|
|
|
);
|
2023-08-03 16:06:40 +02:00
|
|
|
create_multiuse_invite_group_widget.setup();
|
2023-11-23 10:14:35 +01:00
|
|
|
|
|
|
|
const can_access_all_users_group_widget = new dropdown_widget.DropdownWidget({
|
|
|
|
widget_name: "realm_can_access_all_users_group",
|
|
|
|
get_options: () =>
|
|
|
|
user_groups.get_realm_user_groups_for_dropdown_list_widget(
|
|
|
|
"can_access_all_users_group",
|
|
|
|
"realm",
|
|
|
|
),
|
|
|
|
$events_container: $("#settings_overlay_container #organization-permissions"),
|
|
|
|
item_click_callback(event, dropdown) {
|
|
|
|
dropdown.hide();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
settings_components.can_access_all_users_group_widget.render();
|
2024-05-20 21:36:38 +02:00
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler(
|
|
|
|
$("#org-guest-settings"),
|
|
|
|
);
|
2023-11-23 10:14:35 +01:00
|
|
|
},
|
|
|
|
tippy_props: {
|
|
|
|
placement: "bottom-start",
|
|
|
|
},
|
2024-02-13 02:08:24 +01:00
|
|
|
default_id: realm.realm_can_access_all_users_group,
|
2024-02-19 14:22:38 +01:00
|
|
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
2023-11-23 10:14:35 +01:00
|
|
|
on_mount_callback(dropdown) {
|
|
|
|
$(dropdown.popper).css("min-width", "300px");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
settings_components.set_can_access_all_users_group_widget(can_access_all_users_group_widget);
|
|
|
|
can_access_all_users_group_widget.setup();
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|
2020-04-10 04:43:37 +02:00
|
|
|
|
2021-09-28 09:09:52 +02:00
|
|
|
export function register_save_discard_widget_handlers(
|
2022-01-25 11:36:19 +01:00
|
|
|
$container,
|
2021-09-28 09:09:52 +02:00
|
|
|
patch_url,
|
|
|
|
for_realm_default_settings,
|
|
|
|
) {
|
2022-01-25 11:36:19 +01:00
|
|
|
$container.on("change input", "input, select, textarea", (e) => {
|
2018-03-14 23:50:17 +01:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2019-08-22 01:48:38 +02:00
|
|
|
// This event handler detects whether after these input
|
|
|
|
// changes, any fields have different values from the current
|
|
|
|
// official values stored in the database and page_params. If
|
|
|
|
// they do, we transition to the "unsaved" state showing the
|
|
|
|
// save/discard widget; otherwise, we hide that widget (the
|
|
|
|
// "discarded" state).
|
2019-08-05 21:11:30 +02:00
|
|
|
|
|
|
|
if ($(e.target).hasClass("no-input-change-detection")) {
|
|
|
|
// This is to prevent input changes detection in elements
|
|
|
|
// within a subsection whose changes should not affect the
|
|
|
|
// visibility of the discard button
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-02 15:56:34 +01:00
|
|
|
if ($(e.target).hasClass("setting_email_notifications_batching_period_seconds")) {
|
|
|
|
const show_elem = $(e.target).val() === "custom_period";
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2021-12-02 15:56:34 +01:00
|
|
|
"realm_email_notification_batching_period_edit_minutes",
|
|
|
|
show_elem,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-03 13:18:42 +01:00
|
|
|
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
2024-05-20 21:36:38 +02:00
|
|
|
if (for_realm_default_settings) {
|
|
|
|
settings_components.save_discard_default_realm_settings_widget_status_handler(
|
|
|
|
$subsection,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
settings_components.save_discard_realm_settings_widget_status_handler($subsection);
|
|
|
|
}
|
|
|
|
|
2020-09-24 07:50:36 +02:00
|
|
|
return undefined;
|
2018-03-14 23:50:17 +01:00
|
|
|
});
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
$container.on("click", ".subsection-header .subsection-changes-discard button", (e) => {
|
2021-06-03 18:15:17 +02:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2022-11-03 13:18:42 +01:00
|
|
|
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
2023-10-09 23:29:16 +02:00
|
|
|
for (const elem of settings_components.get_subsection_property_elements($subsection)) {
|
2024-05-20 21:36:38 +02:00
|
|
|
if (for_realm_default_settings) {
|
|
|
|
discard_realm_default_property_element_changes(elem);
|
|
|
|
} else {
|
|
|
|
discard_realm_property_element_changes(elem);
|
|
|
|
}
|
2021-06-03 18:15:17 +02:00
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
const $save_btn_controls = $(e.target).closest(".save-button-controls");
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_save_button_state($save_btn_controls, "discarded");
|
2021-06-03 18:15:17 +02:00
|
|
|
});
|
2018-03-14 23:52:36 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
$container.on("click", ".subsection-header .subsection-changes-save button", (e) => {
|
2018-03-21 00:50:00 +01:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2022-01-25 11:36:19 +01:00
|
|
|
const $save_button = $(e.currentTarget);
|
2022-11-03 13:18:42 +01:00
|
|
|
const $subsection_elem = $save_button.closest(".settings-subsection-parent");
|
2024-05-20 21:36:38 +02:00
|
|
|
let data;
|
|
|
|
if (!for_realm_default_settings) {
|
|
|
|
data = settings_components.populate_data_for_realm_settings_request($subsection_elem);
|
|
|
|
} else {
|
|
|
|
data =
|
|
|
|
settings_components.populate_data_for_default_realm_settings_request(
|
|
|
|
$subsection_elem,
|
|
|
|
);
|
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
save_organization_settings(data, $save_button, patch_url);
|
2017-05-25 00:50:07 +02:00
|
|
|
});
|
2021-09-29 13:03:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function build_page() {
|
|
|
|
meta.loaded = true;
|
|
|
|
|
|
|
|
loading.make_indicator($("#admin_page_auth_methods_loading_indicator"));
|
|
|
|
|
|
|
|
// Initialize all the dropdown list widgets.
|
|
|
|
init_dropdown_widgets();
|
|
|
|
// Populate realm domains
|
2024-02-13 02:08:24 +01:00
|
|
|
populate_realm_domains_label(realm.realm_domains);
|
2021-09-29 13:03:35 +02:00
|
|
|
|
|
|
|
// Populate authentication methods table
|
2024-02-05 23:52:25 +01:00
|
|
|
|
|
|
|
populate_auth_methods(settings_components.realm_authentication_methods_to_boolean_dict());
|
2021-09-29 13:03:35 +02:00
|
|
|
|
|
|
|
for (const property_name of simple_dropdown_properties) {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.set_property_dropdown_value(property_name);
|
2021-09-29 13:03:35 +02:00
|
|
|
}
|
|
|
|
|
2022-12-12 18:21:08 +01:00
|
|
|
set_realm_waiting_period_setting();
|
2021-09-29 13:03:35 +02:00
|
|
|
set_video_chat_provider_dropdown();
|
|
|
|
set_giphy_rating_dropdown();
|
|
|
|
set_msg_edit_limit_dropdown();
|
2022-12-22 19:14:23 +01:00
|
|
|
set_msg_move_limit_setting("realm_move_messages_within_stream_limit_seconds");
|
2023-01-30 12:15:36 +01:00
|
|
|
set_msg_move_limit_setting("realm_move_messages_between_streams_limit_seconds");
|
2021-09-29 13:03:35 +02:00
|
|
|
set_msg_delete_limit_dropdown();
|
2024-02-13 02:08:24 +01:00
|
|
|
set_delete_own_message_policy_dropdown(realm.realm_delete_own_message_policy);
|
2021-09-29 13:03:35 +02:00
|
|
|
set_message_retention_setting_dropdown();
|
|
|
|
set_org_join_restrictions_dropdown();
|
2023-01-02 20:50:23 +01:00
|
|
|
set_message_content_in_email_notifications_visibility();
|
2021-09-29 13:03:35 +02:00
|
|
|
set_digest_emails_weekday_visibility();
|
2021-11-19 10:29:39 +01:00
|
|
|
set_create_web_public_stream_dropdown_visibility();
|
2021-09-29 13:03:35 +02:00
|
|
|
|
2021-09-28 09:09:52 +02:00
|
|
|
register_save_discard_widget_handlers($(".admin-realm-form"), "/json/realm", false);
|
2017-08-18 01:23:55 +02:00
|
|
|
|
2022-11-03 13:18:42 +01:00
|
|
|
$(".settings-subsection-parent").on("keydown", "input", (e) => {
|
2018-03-22 14:16:53 +01:00
|
|
|
e.stopPropagation();
|
2022-09-28 08:27:24 +02:00
|
|
|
if (keydown_util.is_enter_event(e)) {
|
2018-03-22 14:16:53 +01:00
|
|
|
e.preventDefault();
|
2020-07-15 00:34:28 +02:00
|
|
|
$(e.target)
|
2022-11-03 13:18:42 +01:00
|
|
|
.closest(".settings-subsection-parent")
|
2021-06-03 18:15:17 +02:00
|
|
|
.find(".subsection-changes-save button")
|
2020-07-20 21:24:26 +02:00
|
|
|
.trigger("click");
|
2018-03-22 14:16:53 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-02 13:58:03 +02:00
|
|
|
$("#id_realm_message_content_edit_limit_seconds").on("change", () => {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.update_custom_value_input("realm_message_content_edit_limit_seconds");
|
2018-04-02 11:18:40 +02:00
|
|
|
});
|
|
|
|
|
2023-01-30 12:15:36 +01:00
|
|
|
$("#id_realm_move_messages_between_streams_limit_seconds").on("change", () => {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.update_custom_value_input(
|
|
|
|
"realm_move_messages_between_streams_limit_seconds",
|
|
|
|
);
|
2023-01-30 12:15:36 +01:00
|
|
|
});
|
|
|
|
|
2022-12-22 19:14:23 +01:00
|
|
|
$("#id_realm_move_messages_within_stream_limit_seconds").on("change", () => {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.update_custom_value_input(
|
|
|
|
"realm_move_messages_within_stream_limit_seconds",
|
|
|
|
);
|
2022-12-22 19:14:23 +01:00
|
|
|
});
|
|
|
|
|
2022-09-02 13:58:03 +02:00
|
|
|
$("#id_realm_message_content_delete_limit_seconds").on("change", () => {
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.update_custom_value_input("realm_message_content_delete_limit_seconds");
|
2017-11-26 09:12:10 +01:00
|
|
|
});
|
|
|
|
|
2023-09-19 18:10:23 +02:00
|
|
|
$("#id_realm_video_chat_provider").on("change", () => {
|
|
|
|
set_jitsi_server_url_dropdown();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#id_realm_jitsi_server_url").on("change", (e) => {
|
|
|
|
const dropdown_val = e.target.value;
|
|
|
|
update_jitsi_server_url_custom_input(dropdown_val);
|
|
|
|
});
|
|
|
|
|
2022-11-04 11:11:33 +01:00
|
|
|
$("#id_realm_message_retention_days").on("change", (e) => {
|
2020-05-07 13:19:54 +02:00
|
|
|
const message_retention_setting_dropdown_value = e.target.value;
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2022-11-04 11:11:33 +01:00
|
|
|
"id_realm_message_retention_custom_input",
|
2022-11-04 11:11:33 +01:00
|
|
|
message_retention_setting_dropdown_value === "custom_period",
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2020-05-07 13:19:54 +02:00
|
|
|
});
|
|
|
|
|
2022-12-13 12:32:01 +01:00
|
|
|
$("#id_realm_waiting_period_threshold").on("change", function () {
|
2019-11-02 00:06:25 +01:00
|
|
|
const waiting_period_threshold = this.value;
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2022-12-12 18:21:08 +01:00
|
|
|
"id_realm_waiting_period_threshold_custom_input",
|
2022-12-09 15:42:11 +01:00
|
|
|
waiting_period_threshold === "custom_period",
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2018-01-05 15:34:10 +01:00
|
|
|
});
|
|
|
|
|
2022-02-20 12:06:19 +01:00
|
|
|
$("#id_realm_digest_emails_enabled").on("change", (e) => {
|
|
|
|
const digest_emails_enabled = $(e.target).is(":checked");
|
2023-10-09 23:29:16 +02:00
|
|
|
settings_components.change_element_block_display_property(
|
2022-02-20 12:06:19 +01:00
|
|
|
"id_realm_digest_weekday",
|
|
|
|
digest_emails_enabled === true,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#id_realm_org_join_restrictions").on("change", (e) => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const org_join_restrictions = e.target.value;
|
2022-01-25 11:36:19 +01:00
|
|
|
const $node = $("#allowed_domains_label").parent();
|
2020-07-15 01:29:15 +02:00
|
|
|
if (org_join_restrictions === "only_selected_domain") {
|
2022-01-25 11:36:19 +01:00
|
|
|
$node.show();
|
2024-02-13 02:08:24 +01:00
|
|
|
if (realm.realm_domains.length === 0) {
|
2021-07-20 14:51:48 +02:00
|
|
|
settings_realm_domains.show_realm_domains_modal();
|
2018-04-05 00:54:31 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-01-25 11:36:19 +01:00
|
|
|
$node.hide();
|
2018-04-05 00:54:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-04-12 09:56:58 +02:00
|
|
|
$("#id_realm_allow_message_editing").on("change", (e) => {
|
|
|
|
const is_checked = $(e.target).prop("checked");
|
|
|
|
update_message_edit_sub_settings(is_checked);
|
|
|
|
});
|
|
|
|
|
2022-12-22 19:14:23 +01:00
|
|
|
$("#org-moving-msgs").on("change", ".move-message-policy-setting", (e) => {
|
|
|
|
const $policy_dropdown_elem = $(e.target);
|
2023-10-09 23:29:16 +02:00
|
|
|
const property_name = settings_components.extract_property_name($policy_dropdown_elem);
|
2022-12-22 19:14:23 +01:00
|
|
|
const disable_time_limit_setting = message_move_limit_setting_enabled(property_name);
|
2023-01-30 12:15:36 +01:00
|
|
|
|
|
|
|
let time_limit_setting_name;
|
|
|
|
if (property_name === "realm_edit_topic_policy") {
|
|
|
|
time_limit_setting_name = "realm_move_messages_within_stream_limit_seconds";
|
|
|
|
} else {
|
|
|
|
time_limit_setting_name = "realm_move_messages_between_streams_limit_seconds";
|
|
|
|
}
|
2022-12-22 19:14:23 +01:00
|
|
|
|
|
|
|
enable_or_disable_related_message_move_time_limit_setting(
|
|
|
|
time_limit_setting_name,
|
|
|
|
disable_time_limit_setting,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-04-25 12:58:35 +02:00
|
|
|
$("#id_realm_delete_own_message_policy").on("change", (e) => {
|
|
|
|
const setting_value = Number.parseInt($(e.target).val(), 10);
|
2022-08-18 16:22:46 +02:00
|
|
|
set_delete_own_message_policy_dropdown(setting_value);
|
2022-04-25 12:58:35 +02:00
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#id_realm_org_join_restrictions").on("click", (e) => {
|
2018-04-05 00:54:31 +02:00
|
|
|
// This prevents the disappearance of modal when there are
|
|
|
|
// no allowed domains otherwise it gets closed due to
|
|
|
|
// the click event handler attached to `#settings_overlay_container`
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
2021-07-20 14:51:48 +02:00
|
|
|
$("#show_realm_domains_modal").on("click", (e) => {
|
2017-04-08 18:13:39 +02:00
|
|
|
e.stopPropagation();
|
2021-07-20 14:51:48 +02:00
|
|
|
settings_realm_domains.show_realm_domains_modal();
|
2017-04-08 18:13:39 +02:00
|
|
|
});
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
function realm_icon_logo_upload_complete($spinner, $upload_text, $delete_button) {
|
|
|
|
$spinner.css({visibility: "hidden"});
|
|
|
|
$upload_text.show();
|
|
|
|
$delete_button.show();
|
2020-05-27 14:16:04 +02:00
|
|
|
}
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
function realm_icon_logo_upload_start($spinner, $upload_text, $delete_button) {
|
|
|
|
$spinner.css({visibility: "visible"});
|
|
|
|
$upload_text.hide();
|
|
|
|
$delete_button.hide();
|
2020-05-27 14:16:04 +02:00
|
|
|
}
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
function upload_realm_logo_or_icon($file_input, night, icon) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const form_data = new FormData();
|
2020-06-17 08:02:33 +02:00
|
|
|
let widget;
|
2020-06-11 01:04:12 +02:00
|
|
|
let url;
|
2018-08-16 01:26:55 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
form_data.append("csrfmiddlewaretoken", csrf_token);
|
2022-01-25 11:36:19 +01:00
|
|
|
for (const [i, file] of Array.prototype.entries.call($file_input[0].files)) {
|
2020-07-15 01:29:15 +02:00
|
|
|
form_data.append("file-" + i, file);
|
2020-02-08 01:53:49 +01:00
|
|
|
}
|
2020-06-11 01:04:12 +02:00
|
|
|
if (icon) {
|
2020-07-15 01:29:15 +02:00
|
|
|
url = "/json/realm/icon";
|
|
|
|
widget = "#realm-icon-upload-widget";
|
2019-01-27 08:25:10 +01:00
|
|
|
} else {
|
2020-06-11 01:04:12 +02:00
|
|
|
if (night) {
|
2020-07-15 01:29:15 +02:00
|
|
|
widget = "#realm-night-logo-upload-widget";
|
2020-06-11 01:04:12 +02:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
widget = "#realm-day-logo-upload-widget";
|
2020-06-11 01:04:12 +02:00
|
|
|
}
|
2020-07-15 01:29:15 +02:00
|
|
|
url = "/json/realm/logo";
|
|
|
|
form_data.append("night", JSON.stringify(night));
|
2019-01-27 08:25:10 +01:00
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
const $spinner = $(`${widget} .upload-spinner-background`).expectOne();
|
|
|
|
const $upload_text = $(`${widget} .image-upload-text`).expectOne();
|
|
|
|
const $delete_button = $(`${widget} .image-delete-button`).expectOne();
|
|
|
|
const $error_field = $(`${widget} .image_file_input_error`).expectOne();
|
|
|
|
realm_icon_logo_upload_start($spinner, $upload_text, $delete_button);
|
|
|
|
$error_field.hide();
|
2018-08-16 01:26:55 +02:00
|
|
|
channel.post({
|
2020-07-20 22:18:43 +02:00
|
|
|
url,
|
2018-08-16 01:26:55 +02:00
|
|
|
data: form_data,
|
|
|
|
cache: false,
|
|
|
|
processData: false,
|
|
|
|
contentType: false,
|
2020-07-20 22:18:43 +02:00
|
|
|
success() {
|
2022-01-25 11:36:19 +01:00
|
|
|
realm_icon_logo_upload_complete($spinner, $upload_text, $delete_button);
|
2018-08-16 01:26:55 +02:00
|
|
|
},
|
2020-07-20 22:18:43 +02:00
|
|
|
error(xhr) {
|
2022-01-25 11:36:19 +01:00
|
|
|
realm_icon_logo_upload_complete($spinner, $upload_text, $delete_button);
|
|
|
|
ui_report.error("", xhr, $error_field);
|
2018-08-16 01:26:55 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-02-27 15:45:26 +01:00
|
|
|
|
2020-06-11 01:04:12 +02:00
|
|
|
realm_icon.build_realm_icon_widget(upload_realm_logo_or_icon, null, true);
|
2024-02-13 02:08:24 +01:00
|
|
|
if (realm.zulip_plan_is_not_limited) {
|
2020-06-11 01:04:12 +02:00
|
|
|
realm_logo.build_realm_logo_widget(upload_realm_logo_or_icon, false);
|
|
|
|
realm_logo.build_realm_logo_widget(upload_realm_logo_or_icon, true);
|
2019-06-12 14:22:37 +02:00
|
|
|
}
|
2019-03-11 16:48:59 +01:00
|
|
|
|
2022-10-11 14:20:27 +02:00
|
|
|
$("#organization-profile .deactivate_realm_button").on("click", deactivate_organization);
|
2021-02-28 01:20:46 +01:00
|
|
|
}
|