mirror of https://github.com/zulip/zulip.git
stream_settings: Add code to discard changes in stream permissions.
This commit adds code to discard changes in stream permission settings. This commit makes some changes to code in settings_org.js to handle stream settings and add corresponding handler for discard button in stream_edit.js. Fixes part of #19519.
This commit is contained in:
parent
445957df05
commit
a2a92b52f6
|
@ -204,7 +204,7 @@ export function extract_property_name($elem, for_realm_default_settings) {
|
||||||
return /^id_(.*)$/.exec($elem.attr("id").replace(/-/g, "_"))[1];
|
return /^id_(.*)$/.exec($elem.attr("id").replace(/-/g, "_"))[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_subsection_property_elements(subsection) {
|
export function get_subsection_property_elements(subsection) {
|
||||||
return Array.from($(subsection).find(".prop-element"));
|
return Array.from($(subsection).find(".prop-element"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,10 +537,10 @@ export let default_code_language_widget = null;
|
||||||
export let notifications_stream_widget = null;
|
export let notifications_stream_widget = null;
|
||||||
export let signup_notifications_stream_widget = null;
|
export let signup_notifications_stream_widget = null;
|
||||||
|
|
||||||
function discard_property_element_changes(elem, for_realm_default_settings) {
|
export function discard_property_element_changes(elem, for_realm_default_settings, sub) {
|
||||||
const $elem = $(elem);
|
const $elem = $(elem);
|
||||||
const property_name = extract_property_name($elem, for_realm_default_settings);
|
const property_name = extract_property_name($elem, for_realm_default_settings);
|
||||||
const property_value = get_property_value(property_name, for_realm_default_settings);
|
const property_value = get_property_value(property_name, for_realm_default_settings, sub);
|
||||||
|
|
||||||
switch (property_name) {
|
switch (property_name) {
|
||||||
case "realm_authentication_methods":
|
case "realm_authentication_methods":
|
||||||
|
@ -566,6 +566,7 @@ function discard_property_element_changes(elem, for_realm_default_settings) {
|
||||||
break;
|
break;
|
||||||
case "emojiset":
|
case "emojiset":
|
||||||
case "user_list_style":
|
case "user_list_style":
|
||||||
|
case "stream_privacy":
|
||||||
// Because this widget has a radio button structure, it
|
// Because this widget has a radio button structure, it
|
||||||
// needs custom reset code.
|
// needs custom reset code.
|
||||||
$elem.find(`input[value='${CSS.escape(property_value)}']`).prop("checked", true);
|
$elem.find(`input[value='${CSS.escape(property_value)}']`).prop("checked", true);
|
||||||
|
@ -591,7 +592,8 @@ function discard_property_element_changes(elem, for_realm_default_settings) {
|
||||||
set_time_limit_setting(property_name);
|
set_time_limit_setting(property_name);
|
||||||
break;
|
break;
|
||||||
case "realm_message_retention_days":
|
case "realm_message_retention_days":
|
||||||
set_message_retention_setting_dropdown();
|
case "message_retention_days":
|
||||||
|
set_message_retention_setting_dropdown(sub);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (property_value !== undefined) {
|
if (property_value !== undefined) {
|
||||||
|
|
|
@ -788,4 +788,23 @@ export function initialize() {
|
||||||
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
||||||
settings_org.save_discard_widget_status_handler($subsection, false, sub);
|
settings_org.save_discard_widget_status_handler($subsection, false, sub);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#manage_streams_container").on(
|
||||||
|
"click",
|
||||||
|
".subsection-header .subsection-changes-discard button",
|
||||||
|
(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
const stream_id = $(e.target).closest(".subscription_settings.show").data("stream-id");
|
||||||
|
const sub = sub_store.get(stream_id);
|
||||||
|
|
||||||
|
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
||||||
|
for (const elem of settings_org.get_subsection_property_elements($subsection)) {
|
||||||
|
settings_org.discard_property_element_changes(elem, false, sub);
|
||||||
|
}
|
||||||
|
const $save_btn_controls = $(e.target).closest(".save-button-controls");
|
||||||
|
settings_org.change_save_button_state($save_btn_controls, "discarded");
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue