mirror of https://github.com/zulip/zulip.git
stream_settings: Remove code for stream privacy modal.
This commit deletes all the functions, CSS and other code for stream privacy modal since we have udpated the UI to show stream permission settings always in "General" section and not inside the modal. Fixes a part of #19519.
This commit is contained in:
parent
404ce8887c
commit
15dbf9742d
|
@ -7,7 +7,6 @@ import render_change_stream_info_modal from "../templates/stream_settings/change
|
|||
import render_copy_email_address_modal from "../templates/stream_settings/copy_email_address_modal.hbs";
|
||||
import render_stream_description from "../templates/stream_settings/stream_description.hbs";
|
||||
import render_stream_settings from "../templates/stream_settings/stream_settings.hbs";
|
||||
import render_stream_types from "../templates/stream_settings/stream_types.hbs";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as browser_history from "./browser_history";
|
||||
|
@ -54,38 +53,6 @@ export function setup_subscriptions_tab_hash(tab_key_value) {
|
|||
}
|
||||
}
|
||||
|
||||
export function get_retention_policy_text_for_subscription_type(sub) {
|
||||
let message_retention_days = sub.message_retention_days;
|
||||
// If both this stream and the organization-level policy are to retain forever,
|
||||
// there's no need to comment on retention policies when describing the stream.
|
||||
if (
|
||||
page_params.realm_message_retention_days === settings_config.retain_message_forever &&
|
||||
(sub.message_retention_days === null ||
|
||||
sub.message_retention_days === settings_config.retain_message_forever)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Forever for this stream, overriding the organization default
|
||||
if (sub.message_retention_days === settings_config.retain_message_forever) {
|
||||
return $t({defaultMessage: "Messages in this stream will be retained forever."});
|
||||
}
|
||||
|
||||
// If we are deleting messages, even if it's the organization
|
||||
// default, it's worth commenting on the policy.
|
||||
if (message_retention_days === null) {
|
||||
message_retention_days = page_params.realm_message_retention_days;
|
||||
}
|
||||
|
||||
return $t(
|
||||
{
|
||||
defaultMessage:
|
||||
"Messages in this stream will be automatically deleted after {retention_days} days.",
|
||||
},
|
||||
{retention_days: message_retention_days},
|
||||
);
|
||||
}
|
||||
|
||||
export function get_display_text_for_realm_message_retention_setting() {
|
||||
const realm_message_retention_days = page_params.realm_message_retention_days;
|
||||
if (realm_message_retention_days === settings_config.retain_message_forever) {
|
||||
|
@ -97,26 +64,6 @@ export function get_display_text_for_realm_message_retention_setting() {
|
|||
);
|
||||
}
|
||||
|
||||
function change_stream_message_retention_days_block_display_property(value) {
|
||||
if (value === "custom_period") {
|
||||
$("#stream_privacy_modal .stream-message-retention-days-input").show();
|
||||
} else {
|
||||
$("#stream_privacy_modal .stream-message-retention-days-input").hide();
|
||||
}
|
||||
}
|
||||
|
||||
function set_stream_message_retention_setting_dropdown(stream) {
|
||||
let value = "custom_period";
|
||||
if (stream.message_retention_days === null) {
|
||||
value = "realm_default";
|
||||
} else if (stream.message_retention_days === settings_config.retain_message_forever) {
|
||||
value = "unlimited";
|
||||
}
|
||||
|
||||
$("#stream_privacy_modal .stream_message_retention_setting").val(value);
|
||||
change_stream_message_retention_days_block_display_property(value);
|
||||
}
|
||||
|
||||
function get_stream_id(target) {
|
||||
const $row = $(target).closest(
|
||||
".stream-row, .stream_settings_header, .subscription_settings, .save-button",
|
||||
|
@ -368,16 +315,6 @@ export function set_stream_property(sub, property, value, status_element) {
|
|||
bulk_set_stream_property([sub_data], status_element);
|
||||
}
|
||||
|
||||
function get_message_retention_days_from_sub(sub) {
|
||||
if (sub.message_retention_days === null) {
|
||||
return "realm_default";
|
||||
}
|
||||
if (sub.message_retention_days === -1) {
|
||||
return "unlimited";
|
||||
}
|
||||
return sub.message_retention_days;
|
||||
}
|
||||
|
||||
export function get_request_data_for_stream_privacy(selected_val) {
|
||||
switch (selected_val) {
|
||||
case stream_data.stream_privacy_policy_values.public.code: {
|
||||
|
@ -411,91 +348,6 @@ export function get_request_data_for_stream_privacy(selected_val) {
|
|||
}
|
||||
}
|
||||
|
||||
function change_stream_privacy(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
const data = {};
|
||||
const stream_id = $(e.target).closest(".dialog_submit_button").data("stream-id");
|
||||
const url = "/json/streams/" + stream_id;
|
||||
const $status_element = $(".stream_permission_change_info");
|
||||
const sub = sub_store.get(stream_id);
|
||||
|
||||
const privacy_setting = $("#stream_privacy_modal input[name=privacy]:checked").val();
|
||||
const stream_post_policy = Number.parseInt(
|
||||
$("#stream_privacy_modal select[name=stream-post-policy]").val(),
|
||||
10,
|
||||
);
|
||||
|
||||
if (sub.stream_post_policy !== stream_post_policy) {
|
||||
data.stream_post_policy = JSON.stringify(stream_post_policy);
|
||||
}
|
||||
|
||||
let invite_only;
|
||||
let history_public_to_subscribers;
|
||||
let is_web_public;
|
||||
|
||||
switch (privacy_setting) {
|
||||
case stream_data.stream_privacy_policy_values.public.code: {
|
||||
invite_only = false;
|
||||
history_public_to_subscribers = true;
|
||||
is_web_public = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case stream_data.stream_privacy_policy_values.private.code: {
|
||||
invite_only = true;
|
||||
history_public_to_subscribers = false;
|
||||
is_web_public = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case stream_data.stream_privacy_policy_values.web_public.code: {
|
||||
invite_only = false;
|
||||
history_public_to_subscribers = true;
|
||||
is_web_public = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
invite_only = true;
|
||||
history_public_to_subscribers = true;
|
||||
is_web_public = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
sub.invite_only !== invite_only ||
|
||||
sub.history_public_to_subscribers !== history_public_to_subscribers ||
|
||||
sub.is_web_public !== is_web_public
|
||||
) {
|
||||
data.is_private = JSON.stringify(invite_only);
|
||||
data.history_public_to_subscribers = JSON.stringify(history_public_to_subscribers);
|
||||
data.is_web_public = JSON.stringify(is_web_public);
|
||||
}
|
||||
|
||||
let message_retention_days = $(
|
||||
"#stream_privacy_modal select[name=stream_message_retention_setting]",
|
||||
).val();
|
||||
if (message_retention_days === "custom_period") {
|
||||
message_retention_days = Number.parseInt(
|
||||
$("#stream_privacy_modal input[name=stream-message-retention-days]").val(),
|
||||
10,
|
||||
);
|
||||
}
|
||||
|
||||
const message_retention_days_from_sub = get_message_retention_days_from_sub(sub);
|
||||
|
||||
if (message_retention_days_from_sub !== message_retention_days) {
|
||||
data.message_retention_days = JSON.stringify(message_retention_days);
|
||||
}
|
||||
|
||||
if (Object.keys(data).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
settings_ui.do_settings_change(channel.patch, url, data, $status_element);
|
||||
}
|
||||
|
||||
export function archive_stream(stream_id, $alert_element, $stream_row) {
|
||||
channel.del({
|
||||
url: "/json/streams/" + stream_id,
|
||||
|
@ -533,59 +385,6 @@ export function initialize() {
|
|||
stream_settings_ui.sub_or_unsub(sub);
|
||||
});
|
||||
|
||||
$("#manage_streams_container").on("click", ".change-stream-privacy", (e) => {
|
||||
const stream_id = get_stream_id(e.target);
|
||||
const stream = sub_store.get(stream_id);
|
||||
|
||||
const template_data = {
|
||||
ask_to_announce_stream: false,
|
||||
stream_privacy_policy_values: stream_data.stream_privacy_policy_values,
|
||||
stream_privacy_policy: stream_data.get_stream_privacy_policy(stream_id),
|
||||
stream_post_policy_values: stream_data.stream_post_policy_values,
|
||||
stream_post_policy: stream.stream_post_policy,
|
||||
is_owner: page_params.is_owner,
|
||||
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
||||
disable_message_retention_setting:
|
||||
!page_params.zulip_plan_is_not_limited || !page_params.is_owner,
|
||||
stream_message_retention_days: stream.message_retention_days,
|
||||
org_level_message_retention_setting:
|
||||
get_display_text_for_realm_message_retention_setting(),
|
||||
upgrade_text_for_wide_organization_logo:
|
||||
page_params.upgrade_text_for_wide_organization_logo,
|
||||
is_business_type_org:
|
||||
page_params.realm_org_type === settings_config.all_org_type_values.business.code,
|
||||
is_stream_edit: true,
|
||||
};
|
||||
const change_privacy_modal = render_stream_types(template_data);
|
||||
|
||||
dialog_widget.launch({
|
||||
html_heading: $t_html(
|
||||
{defaultMessage: "Change stream permissions for #{stream_name}"},
|
||||
{stream_name: stream.name},
|
||||
),
|
||||
html_body: change_privacy_modal,
|
||||
close_on_submit: true,
|
||||
id: "stream_privacy_modal",
|
||||
on_click: change_stream_privacy,
|
||||
post_render() {
|
||||
$("#stream_privacy_modal .dialog_submit_button").attr("data-stream-id", stream_id);
|
||||
set_stream_message_retention_setting_dropdown(stream);
|
||||
|
||||
$("#stream_privacy_modal .stream_message_retention_setting").on("change", (e) => {
|
||||
const dropdown_value = e.target.value;
|
||||
change_stream_message_retention_days_block_display_property(dropdown_value);
|
||||
});
|
||||
},
|
||||
on_show() {
|
||||
stream_settings_ui.hide_or_disable_stream_privacy_options_if_required(
|
||||
$("#stream_privacy_modal"),
|
||||
);
|
||||
},
|
||||
});
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$("#manage_streams_container").on("click", "#open_stream_info_modal", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
@ -216,8 +216,6 @@ export function update_stream_privacy(slim_sub, values) {
|
|||
stream_ui_updates.update_setting_element(sub, "stream_privacy");
|
||||
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
|
||||
stream_ui_updates.update_stream_privacy_icon_in_settings(sub);
|
||||
stream_ui_updates.update_stream_subscription_type_text(sub);
|
||||
stream_ui_updates.update_change_stream_privacy_settings(sub);
|
||||
stream_ui_updates.update_settings_button_for_sub(sub);
|
||||
stream_ui_updates.update_add_subscriptions_elements(sub);
|
||||
stream_ui_updates.enable_or_disable_subscribers_tab(sub);
|
||||
|
@ -234,13 +232,11 @@ export function update_stream_privacy(slim_sub, values) {
|
|||
|
||||
export function update_stream_post_policy(sub, new_value) {
|
||||
stream_data.update_stream_post_policy(sub, new_value);
|
||||
stream_ui_updates.update_stream_subscription_type_text(sub);
|
||||
stream_ui_updates.update_setting_element(sub, "stream_post_policy");
|
||||
}
|
||||
|
||||
export function update_message_retention_setting(sub, new_value) {
|
||||
stream_data.update_message_retention_setting(sub, new_value);
|
||||
stream_ui_updates.update_stream_subscription_type_text(sub);
|
||||
stream_ui_updates.update_setting_element(sub, "message_retention_days");
|
||||
}
|
||||
|
||||
|
@ -317,7 +313,6 @@ export function update_settings_for_subscribed(slim_sub) {
|
|||
stream_ui_updates.update_toggler_for_sub(sub);
|
||||
stream_ui_updates.update_stream_row_in_settings_tab(sub);
|
||||
stream_ui_updates.update_settings_button_for_sub(sub);
|
||||
stream_ui_updates.update_change_stream_privacy_settings(sub);
|
||||
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
|
||||
} else {
|
||||
add_sub_to_table(sub);
|
||||
|
@ -346,7 +341,6 @@ export function update_settings_for_unsubscribed(slim_sub) {
|
|||
stream_ui_updates.update_toggler_for_sub(sub);
|
||||
stream_ui_updates.update_settings_button_for_sub(sub);
|
||||
stream_ui_updates.update_regular_sub_settings(sub);
|
||||
stream_ui_updates.update_change_stream_privacy_settings(sub);
|
||||
stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);
|
||||
|
||||
// If user unsubscribed from private stream then user cannot subscribe to
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import $ from "jquery";
|
||||
|
||||
import render_stream_permission_description from "../templates/stream_settings/stream_permission_description.hbs";
|
||||
import render_stream_privacy_icon from "../templates/stream_settings/stream_privacy_icon.hbs";
|
||||
import render_stream_settings_tip from "../templates/stream_settings/stream_settings_tip.hbs";
|
||||
|
||||
|
@ -126,17 +125,6 @@ export function update_regular_sub_settings(sub) {
|
|||
}
|
||||
}
|
||||
|
||||
export function update_change_stream_privacy_settings(sub) {
|
||||
// This is in the right panel.
|
||||
const $stream_privacy_btn = $(".change-stream-privacy");
|
||||
|
||||
if (sub.can_change_stream_permissions) {
|
||||
$stream_privacy_btn.show();
|
||||
} else {
|
||||
$stream_privacy_btn.hide();
|
||||
}
|
||||
}
|
||||
|
||||
export function enable_or_disable_permission_settings_in_edit_panel(sub) {
|
||||
if (!hash_util.is_editing_stream(sub.stream_id)) {
|
||||
return;
|
||||
|
@ -220,20 +208,6 @@ export function update_stream_row_in_settings_tab(sub) {
|
|||
}
|
||||
}
|
||||
|
||||
export function update_stream_subscription_type_text(sub) {
|
||||
// This is in the right panel.
|
||||
const $stream_settings = stream_settings_containers.get_edit_container(sub);
|
||||
const template_data = {
|
||||
...sub,
|
||||
stream_post_policy_values: stream_data.stream_post_policy_values,
|
||||
message_retention_text: stream_edit.get_retention_policy_text_for_subscription_type(sub),
|
||||
};
|
||||
const html = render_stream_permission_description(template_data);
|
||||
if (hash_util.is_editing_stream(sub.stream_id)) {
|
||||
$stream_settings.find(".subscription-type-text").expectOne().html(html);
|
||||
}
|
||||
}
|
||||
|
||||
export function update_add_subscriptions_elements(sub) {
|
||||
if (!hash_util.is_editing_stream(sub.stream_id)) {
|
||||
return;
|
||||
|
|
|
@ -832,7 +832,6 @@
|
|||
.member-list-box .member_list_container .member-list tr,
|
||||
#subscription_overlay .subsection-parent div,
|
||||
#subscription_overlay .settings-radio-input-parent,
|
||||
#stream_privacy_modal .settings-radio-input-parent,
|
||||
#settings_page .sidebar-wrapper,
|
||||
#settings_page .sidebar-wrapper *,
|
||||
table,
|
||||
|
|
|
@ -259,11 +259,6 @@ h4.user_group_setting_subsection_title {
|
|||
padding-top: 40px;
|
||||
}
|
||||
|
||||
.change-stream-privacy {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.subscriptions-container .subscriptions-header .fa-chevron-left,
|
||||
.user-groups-container .user-groups-header .fa-chevron-left,
|
||||
#settings_overlay_container .settings-header.mobile .fa-chevron-left {
|
||||
|
@ -851,21 +846,6 @@ h4.user_group_setting_subsection_title {
|
|||
}
|
||||
}
|
||||
|
||||
.stream_setting_subsection_header {
|
||||
display: flex;
|
||||
|
||||
.stream_permission_change_info {
|
||||
/* TODO: Deduplicate with .save-discard-widget-button. */
|
||||
margin: 12px auto 12px 3px;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: inline;
|
||||
margin-left: auto;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
.checkmark {
|
||||
display: none;
|
||||
margin-left: 5px;
|
||||
|
@ -878,18 +858,6 @@ h4.user_group_setting_subsection_title {
|
|||
}
|
||||
}
|
||||
|
||||
.subscription-type {
|
||||
margin-bottom: 10px;
|
||||
|
||||
.subscription-type-text {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
b {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.hash::after {
|
||||
position: relative;
|
||||
content: "#";
|
||||
|
@ -1193,13 +1161,5 @@ div.settings-radio-input-parent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.stream_setting_subsection_header {
|
||||
display: block;
|
||||
|
||||
.stream_permission_change_info {
|
||||
margin: 12px auto 0 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<ul>
|
||||
{{#if invite_only}}
|
||||
<li>
|
||||
{{#tr}}
|
||||
This is a <b>private stream</b>. Only people who have been invited can access its content, but any subscriber can invite others.
|
||||
{{/tr}}
|
||||
</li>
|
||||
<li>
|
||||
{{#if history_public_to_subscribers}}{{t 'New subscribers can view complete message history.' }}
|
||||
{{else}}{{t 'New subscribers can only see messages sent after they join.' }}
|
||||
{{/if}}
|
||||
</li>
|
||||
{{else if is_web_public}}
|
||||
<li>
|
||||
{{#tr}}
|
||||
This is a <b>web-public stream</b>. Any member of the organization can join without an invitation and anyone on the internet can read the content published.
|
||||
{{/tr}}
|
||||
</li>
|
||||
{{else}}
|
||||
<li>
|
||||
{{#tr}}
|
||||
This is a <b>public stream</b>. Any member of the organization can join without an invitation
|
||||
or view content sent to this stream.
|
||||
{{/tr}}
|
||||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
{{#if (eq stream_post_policy stream_post_policy_values.admins.code)}}
|
||||
{{t 'Only organization administrators can post.'}}
|
||||
{{else if (eq stream_post_policy stream_post_policy_values.moderators.code)}}
|
||||
{{t 'Only organization administrators and moderators can post.'}}
|
||||
{{else if (eq stream_post_policy stream_post_policy_values.non_new_members.code)}}
|
||||
{{t 'Only organization full members can post.'}}
|
||||
{{else}}
|
||||
{{t 'All stream subscribers can post.'}}
|
||||
{{/if}}
|
||||
</li>
|
||||
{{#if message_retention_text}}
|
||||
<li>
|
||||
{{message_retention_text}}
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
Loading…
Reference in New Issue