mirror of https://github.com/zulip/zulip.git
stream_settings: Split code for disabling the stream-privacy choices.
This commit splits the hide_or_disable_stream_privacy_options_if_required function into three separate functions for public, private and web-public streams. This is a prep commit for live-updating the stream-privacy choices on changing the realm setting.
This commit is contained in:
parent
4eeee7296e
commit
15cf972a8e
|
@ -988,48 +988,58 @@ export function sub_or_unsub(sub, stream_row) {
|
|||
}
|
||||
}
|
||||
|
||||
export function hide_or_disable_web_public_stream_privacy_option(container) {
|
||||
const web_public_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.web_public.code)}']`,
|
||||
);
|
||||
if (!web_public_stream_elem.is(":checked")) {
|
||||
if (
|
||||
!page_params.server_web_public_streams_enabled ||
|
||||
!page_params.realm_enable_spectator_access
|
||||
) {
|
||||
web_public_stream_elem.closest(".radio-input-parent").hide();
|
||||
container
|
||||
.find(".stream-privacy-values .radio-input-parent:visible:last")
|
||||
.css("border-bottom", "none");
|
||||
} else {
|
||||
web_public_stream_elem.prop("disabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function disable_public_stream_privacy_option(container) {
|
||||
const public_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.public.code)}']`,
|
||||
);
|
||||
public_stream_elem.prop("disabled", true);
|
||||
}
|
||||
|
||||
export function disable_private_stream_privacy_option(container) {
|
||||
// Disable both "Private, shared history" and "Private, protected history" options.
|
||||
const private_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.private.code)}']`,
|
||||
);
|
||||
const private_with_public_history_elem = container.find(
|
||||
`input[value='${CSS.escape(
|
||||
stream_data.stream_privacy_policy_values.private_with_public_history.code,
|
||||
)}']`,
|
||||
);
|
||||
|
||||
private_stream_elem.prop("disabled", true);
|
||||
private_with_public_history_elem.prop("disabled", true);
|
||||
}
|
||||
|
||||
export function hide_or_disable_stream_privacy_options_if_required(container) {
|
||||
if (!settings_data.user_can_create_web_public_streams()) {
|
||||
const web_public_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(
|
||||
stream_data.stream_privacy_policy_values.web_public.code,
|
||||
)}']`,
|
||||
);
|
||||
if (!web_public_stream_elem.is(":checked")) {
|
||||
if (
|
||||
!page_params.server_web_public_streams_enabled ||
|
||||
!page_params.realm_enable_spectator_access
|
||||
) {
|
||||
web_public_stream_elem.closest(".radio-input-parent").hide();
|
||||
container
|
||||
.find(".stream-privacy-values .radio-input-parent:visible:last")
|
||||
.css("border-bottom", "none");
|
||||
} else {
|
||||
web_public_stream_elem.prop("disabled", true);
|
||||
}
|
||||
}
|
||||
hide_or_disable_web_public_stream_privacy_option(container);
|
||||
}
|
||||
|
||||
if (!settings_data.user_can_create_public_streams()) {
|
||||
const public_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.public.code)}']`,
|
||||
);
|
||||
public_stream_elem.prop("disabled", true);
|
||||
disable_public_stream_privacy_option(container);
|
||||
}
|
||||
|
||||
if (!settings_data.user_can_create_private_streams()) {
|
||||
// Disable both "Private, shared history" and "Private, protected history" options.
|
||||
const private_stream_elem = container.find(
|
||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.private.code)}']`,
|
||||
);
|
||||
const private_with_public_history_elem = container.find(
|
||||
`input[value='${CSS.escape(
|
||||
stream_data.stream_privacy_policy_values.private_with_public_history.code,
|
||||
)}']`,
|
||||
);
|
||||
|
||||
private_stream_elem.prop("disabled", true);
|
||||
private_with_public_history_elem.prop("disabled", true);
|
||||
disable_private_stream_privacy_option(container);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue