mirror of https://github.com/zulip/zulip.git
settings: Move time limit properties.
We have to extract a local `config` due to line length restrictions. (Or do something else ugly.)
This commit is contained in:
parent
720e9728db
commit
8abff20ce8
|
@ -80,8 +80,8 @@ exports.build_page = function () {
|
|||
};
|
||||
|
||||
options.admin_settings_label = admin_settings_label;
|
||||
options.msg_edit_limit_dropdown_values = settings_org.msg_edit_limit_dropdown_values;
|
||||
options.msg_delete_limit_dropdown_values = settings_org.msg_delete_limit_dropdown_values;
|
||||
options.msg_edit_limit_dropdown_values = settings_config.msg_edit_limit_dropdown_values;
|
||||
options.msg_delete_limit_dropdown_values = settings_config.msg_delete_limit_dropdown_values;
|
||||
options.bot_creation_policy_values = settings_bots.bot_creation_policy_values;
|
||||
options.email_address_visibility_values = settings_config.email_address_visibility_values;
|
||||
_.extend(options, settings_org.get_organization_settings_options());
|
||||
|
|
|
@ -116,3 +116,38 @@ exports.private_message_policy_values = {
|
|||
description: i18n.t("Private messages disabled"),
|
||||
},
|
||||
};
|
||||
|
||||
const time_limit_dropdown_values = {
|
||||
any_time: {
|
||||
text: i18n.t("Any time"),
|
||||
seconds: 0,
|
||||
},
|
||||
never: {
|
||||
text: i18n.t("Never"),
|
||||
},
|
||||
upto_two_min: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
|
||||
seconds: 2 * 60,
|
||||
},
|
||||
upto_ten_min: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
|
||||
seconds: 10 * 60,
|
||||
},
|
||||
upto_one_hour: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
|
||||
seconds: 60 * 60,
|
||||
},
|
||||
upto_one_day: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
|
||||
seconds: 24 * 60 * 60,
|
||||
},
|
||||
upto_one_week: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
|
||||
seconds: 7 * 24 * 60 * 60,
|
||||
},
|
||||
custom_limit: {
|
||||
text: i18n.t("Up to N minutes after posting"),
|
||||
},
|
||||
};
|
||||
exports.msg_edit_limit_dropdown_values = time_limit_dropdown_values;
|
||||
exports.msg_delete_limit_dropdown_values = time_limit_dropdown_values;
|
||||
|
|
|
@ -124,7 +124,7 @@ function get_property_value(property_name) {
|
|||
if (!page_params.realm_allow_message_editing) {
|
||||
return "never";
|
||||
}
|
||||
value = _.findKey(exports.msg_edit_limit_dropdown_values, function (elem) {
|
||||
value = _.findKey(settings_config.msg_edit_limit_dropdown_values, function (elem) {
|
||||
return elem.seconds === page_params.realm_message_content_edit_limit_seconds;
|
||||
});
|
||||
if (value === undefined) {
|
||||
|
@ -137,7 +137,7 @@ function get_property_value(property_name) {
|
|||
if (!page_params.realm_allow_message_deleting) {
|
||||
return "never";
|
||||
}
|
||||
value = _.findKey(exports.msg_delete_limit_dropdown_values, function (elem) {
|
||||
value = _.findKey(settings_config.msg_delete_limit_dropdown_values, function (elem) {
|
||||
return elem.seconds === page_params.realm_message_content_delete_limit_seconds;
|
||||
});
|
||||
if (value === undefined) {
|
||||
|
@ -238,41 +238,6 @@ function set_video_chat_provider_dropdown() {
|
|||
}
|
||||
}
|
||||
|
||||
const time_limit_dropdown_values = {
|
||||
any_time: {
|
||||
text: i18n.t("Any time"),
|
||||
seconds: 0,
|
||||
},
|
||||
never: {
|
||||
text: i18n.t("Never"),
|
||||
},
|
||||
upto_two_min: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("2 minutes")}),
|
||||
seconds: 2 * 60,
|
||||
},
|
||||
upto_ten_min: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("10 minutes")}),
|
||||
seconds: 10 * 60,
|
||||
},
|
||||
upto_one_hour: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 hour")}),
|
||||
seconds: 60 * 60,
|
||||
},
|
||||
upto_one_day: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 day")}),
|
||||
seconds: 24 * 60 * 60,
|
||||
},
|
||||
upto_one_week: {
|
||||
text: i18n.t("Up to __time_limit__ after posting", {time_limit: i18n.t("1 week")}),
|
||||
seconds: 7 * 24 * 60 * 60,
|
||||
},
|
||||
custom_limit: {
|
||||
text: i18n.t("Up to N minutes after posting"),
|
||||
},
|
||||
};
|
||||
exports.msg_edit_limit_dropdown_values = time_limit_dropdown_values;
|
||||
exports.msg_delete_limit_dropdown_values = time_limit_dropdown_values;
|
||||
|
||||
function set_msg_edit_limit_dropdown() {
|
||||
const value = get_property_value("realm_msg_edit_limit_setting");
|
||||
$("#id_realm_msg_edit_limit_setting").val(value);
|
||||
|
@ -717,6 +682,10 @@ exports.build_page = function () {
|
|||
|
||||
function get_complete_data_for_subsection(subsection) {
|
||||
let data = {};
|
||||
// Hacky extra name created to avoid linter.
|
||||
// TODO: Fix this properly by just de-nesting this function outside build_page.
|
||||
const config = settings_config;
|
||||
|
||||
if (subsection === 'msg_editing') {
|
||||
const edit_limit_setting_value = $("#id_realm_msg_edit_limit_setting").val();
|
||||
if (edit_limit_setting_value === 'never') {
|
||||
|
@ -728,7 +697,7 @@ exports.build_page = function () {
|
|||
} else {
|
||||
data.allow_message_editing = true;
|
||||
data.message_content_edit_limit_seconds =
|
||||
exports.msg_edit_limit_dropdown_values[edit_limit_setting_value].seconds;
|
||||
config.msg_edit_limit_dropdown_values[edit_limit_setting_value].seconds;
|
||||
}
|
||||
const delete_limit_setting_value = $("#id_realm_msg_delete_limit_setting").val();
|
||||
if (delete_limit_setting_value === 'never') {
|
||||
|
@ -740,7 +709,7 @@ exports.build_page = function () {
|
|||
} else {
|
||||
data.allow_message_deleting = true;
|
||||
data.message_content_delete_limit_seconds =
|
||||
exports.msg_delete_limit_dropdown_values[delete_limit_setting_value].seconds;
|
||||
config.msg_delete_limit_dropdown_values[delete_limit_setting_value].seconds;
|
||||
}
|
||||
} else if (subsection === 'notifications') {
|
||||
data.notifications_stream_id = JSON.stringify(
|
||||
|
|
Loading…
Reference in New Issue