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];
|
||||
}
|
||||
|
||||
function get_subsection_property_elements(subsection) {
|
||||
export function get_subsection_property_elements(subsection) {
|
||||
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 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 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) {
|
||||
case "realm_authentication_methods":
|
||||
|
@ -566,6 +566,7 @@ function discard_property_element_changes(elem, for_realm_default_settings) {
|
|||
break;
|
||||
case "emojiset":
|
||||
case "user_list_style":
|
||||
case "stream_privacy":
|
||||
// Because this widget has a radio button structure, it
|
||||
// needs custom reset code.
|
||||
$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);
|
||||
break;
|
||||
case "realm_message_retention_days":
|
||||
set_message_retention_setting_dropdown();
|
||||
case "message_retention_days":
|
||||
set_message_retention_setting_dropdown(sub);
|
||||
break;
|
||||
default:
|
||||
if (property_value !== undefined) {
|
||||
|
|
|
@ -788,4 +788,23 @@ export function initialize() {
|
|||
const $subsection = $(e.target).closest(".settings-subsection-parent");
|
||||
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