mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
message_edit: Make topic editing independent of allow_message_editing.
We now allow editing stream and topic of message even if allow_message_editing if False using webapp given that is allowed as per other topic and stream edit specific settings. Fixes a part of #21739.
This commit is contained in:
@@ -34,7 +34,6 @@ const dark_theme = mock_esm("../../static/js/dark_theme");
|
|||||||
const emoji_picker = mock_esm("../../static/js/emoji_picker");
|
const emoji_picker = mock_esm("../../static/js/emoji_picker");
|
||||||
const hotspots = mock_esm("../../static/js/hotspots");
|
const hotspots = mock_esm("../../static/js/hotspots");
|
||||||
const linkifiers = mock_esm("../../static/js/linkifiers");
|
const linkifiers = mock_esm("../../static/js/linkifiers");
|
||||||
const message_edit = mock_esm("../../static/js/message_edit");
|
|
||||||
const message_events = mock_esm("../../static/js/message_events");
|
const message_events = mock_esm("../../static/js/message_events");
|
||||||
const message_lists = mock_esm("../../static/js/message_lists");
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const muted_topics_ui = mock_esm("../../static/js/muted_topics_ui");
|
const muted_topics_ui = mock_esm("../../static/js/muted_topics_ui");
|
||||||
@@ -469,7 +468,6 @@ run_test("realm settings", ({override}) => {
|
|||||||
page_params.realm_allow_message_editing = false;
|
page_params.realm_allow_message_editing = false;
|
||||||
page_params.realm_message_content_edit_limit_seconds = 0;
|
page_params.realm_message_content_edit_limit_seconds = 0;
|
||||||
override(settings_org, "populate_auth_methods", noop);
|
override(settings_org, "populate_auth_methods", noop);
|
||||||
override(message_edit, "update_message_topic_editing_pencil", noop);
|
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.realm_allow_message_editing, true);
|
assert_same(page_params.realm_allow_message_editing, true);
|
||||||
assert_same(page_params.realm_message_content_edit_limit_seconds, 5);
|
assert_same(page_params.realm_message_content_edit_limit_seconds, 5);
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ run_test("get_editability", ({override}) => {
|
|||||||
page_params.realm_allow_message_editing = false;
|
page_params.realm_allow_message_editing = false;
|
||||||
assert.equal(get_editability(message), editability_types.NO);
|
assert.equal(get_editability(message), editability_types.NO);
|
||||||
|
|
||||||
|
message.type = "stream";
|
||||||
|
assert.equal(get_editability(message), editability_types.TOPIC_ONLY);
|
||||||
|
|
||||||
page_params.realm_allow_message_editing = true;
|
page_params.realm_allow_message_editing = true;
|
||||||
// Limit of 0 means no time limit on editing messages
|
// Limit of 0 means no time limit on editing messages
|
||||||
page_params.realm_message_content_edit_limit_seconds = null;
|
page_params.realm_message_content_edit_limit_seconds = null;
|
||||||
@@ -143,7 +146,7 @@ run_test("is_topic_editable", ({override}) => {
|
|||||||
assert.equal(message_edit.is_topic_editable(message), true);
|
assert.equal(message_edit.is_topic_editable(message), true);
|
||||||
|
|
||||||
page_params.realm_allow_message_editing = false;
|
page_params.realm_allow_message_editing = false;
|
||||||
assert.equal(message_edit.is_topic_editable(message), false);
|
assert.equal(message_edit.is_topic_editable(message), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("get_deletability", ({override}) => {
|
run_test("get_deletability", ({override}) => {
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ export function is_topic_editable(message, edit_limit_seconds_buffer = 0) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!page_params.realm_allow_message_editing) {
|
|
||||||
// If message editing is disabled, so is topic editing.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// message senders can edit message topics indefinitely.
|
// message senders can edit message topics indefinitely.
|
||||||
if (message.sent_by_me) {
|
if (message.sent_by_me) {
|
||||||
return true;
|
return true;
|
||||||
@@ -140,6 +135,9 @@ export function get_editability(message, edit_limit_seconds_buffer = 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!page_params.realm_allow_message_editing) {
|
if (!page_params.realm_allow_message_editing) {
|
||||||
|
if (message.type === "stream") {
|
||||||
|
return editability_types.TOPIC_ONLY;
|
||||||
|
}
|
||||||
return editability_types.NO;
|
return editability_types.NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,10 +198,6 @@ export function get_deletability(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function can_move_message(message) {
|
export function can_move_message(message) {
|
||||||
if (!page_params.realm_allow_message_editing) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message.is_stream) {
|
if (!message.is_stream) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -265,14 +259,6 @@ export function stream_and_topic_exist_in_edit_history(message, stream_id, topic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_message_topic_editing_pencil() {
|
|
||||||
if (page_params.realm_allow_message_editing) {
|
|
||||||
$(".on_hover_topic_edit, .always_visible_topic_edit").show();
|
|
||||||
} else {
|
|
||||||
$(".on_hover_topic_edit, .always_visible_topic_edit").hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hide_message_edit_spinner($row) {
|
export function hide_message_edit_spinner($row) {
|
||||||
$row.find(".loader").hide();
|
$row.find(".loader").hide();
|
||||||
$row.find(".message_edit_save span").show();
|
$row.find(".message_edit_save span").show();
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ function set_timestr(message_container) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_topic_edit_properties(group, message) {
|
function set_topic_edit_properties(group, message) {
|
||||||
group.realm_allow_message_editing = page_params.realm_allow_message_editing;
|
|
||||||
group.always_visible_topic_edit = false;
|
group.always_visible_topic_edit = false;
|
||||||
group.on_hover_topic_edit = false;
|
group.on_hover_topic_edit = false;
|
||||||
// if a user who can edit a topic, can resolve it as well
|
// if a user who can edit a topic, can resolve it as well
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import * as emoji_picker from "./emoji_picker";
|
|||||||
import * as giphy from "./giphy";
|
import * as giphy from "./giphy";
|
||||||
import * as hotspots from "./hotspots";
|
import * as hotspots from "./hotspots";
|
||||||
import * as linkifiers from "./linkifiers";
|
import * as linkifiers from "./linkifiers";
|
||||||
import * as message_edit from "./message_edit";
|
|
||||||
import * as message_events from "./message_events";
|
import * as message_events from "./message_events";
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
@@ -260,9 +259,6 @@ export function dispatch_normal_event(event) {
|
|||||||
case "default":
|
case "default":
|
||||||
for (const [key, value] of Object.entries(event.data)) {
|
for (const [key, value] of Object.entries(event.data)) {
|
||||||
page_params["realm_" + key] = value;
|
page_params["realm_" + key] = value;
|
||||||
if (key === "allow_message_editing") {
|
|
||||||
message_edit.update_message_topic_editing_pencil();
|
|
||||||
}
|
|
||||||
if (Object.hasOwn(realm_settings, key)) {
|
if (Object.hasOwn(realm_settings, key)) {
|
||||||
settings_org.sync_realm_settings(key);
|
settings_org.sync_realm_settings(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,6 @@ function update_message_edit_sub_settings(is_checked) {
|
|||||||
"id_realm_message_content_edit_limit_minutes",
|
"id_realm_message_content_edit_limit_minutes",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
settings_ui.disable_sub_setting_onchange(is_checked, "id_realm_edit_topic_policy", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_custom_value_input(property_name) {
|
function update_custom_value_input(property_name) {
|
||||||
|
|||||||
@@ -50,9 +50,9 @@
|
|||||||
|
|
||||||
{{! edit topic pencil icon }}
|
{{! edit topic pencil icon }}
|
||||||
{{#if always_visible_topic_edit}}
|
{{#if always_visible_topic_edit}}
|
||||||
<i class="fa fa-pencil always_visible_topic_edit recipient_bar_icon hidden-for-spectators" {{#unless realm_allow_message_editing}}style="display: none"{{/unless}} data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
|
<i class="fa fa-pencil always_visible_topic_edit recipient_bar_icon hidden-for-spectators" data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
|
||||||
{{else if on_hover_topic_edit}}
|
{{else if on_hover_topic_edit}}
|
||||||
<i class="fa fa-pencil on_hover_topic_edit recipient_bar_icon hidden-for-spectators" {{#unless realm_allow_message_editing}}style="display: none"{{/unless}} data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
|
<i class="fa fa-pencil on_hover_topic_edit recipient_bar_icon hidden-for-spectators" data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if user_can_resolve_topic}}
|
{{#if user_can_resolve_topic}}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="realm_edit_topic_policy" class="dropdown-title">{{t "Who can edit the topic of any message" }}</label>
|
<label for="realm_edit_topic_policy" class="dropdown-title">{{t "Who can edit the topic of any message" }}</label>
|
||||||
<select name="realm_edit_topic_policy" id="id_realm_edit_topic_policy" class="prop-element" data-setting-widget-type="number" {{#unless realm_allow_message_editing}}disabled{{/unless}}>
|
<select name="realm_edit_topic_policy" id="id_realm_edit_topic_policy" class="prop-element" data-setting-widget-type="number">
|
||||||
{{> dropdown_options_widget option_values=edit_topic_policy_values}}
|
{{> dropdown_options_widget option_values=edit_topic_policy_values}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user