Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Update textarea placeholder with general chat.

Prakhar Pratyush29fb5ff93456
diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.ts
index 52a611866d2..4c0bb0fcf92 100644
--- a/web/src/compose_ui.ts
+++ b/web/src/compose_ui.ts
@@ -25,7 +25,7 @@ import * as people from "./people.ts";
import {postprocess_content} from "./postprocess_content.ts";
import * as rendered_markdown from "./rendered_markdown.ts";
import * as rtl from "./rtl.ts";
-import {current_user} from "./state_data.ts";
+import {current_user, realm} from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
import * as user_status from "./user_status.ts";
import * as util from "./util.ts";
@@ -426,10 +426,20 @@ export function compute_placeholder_text(opts: ComposePlaceholderOptions): strin
}
}
- if (stream_name && opts.topic) {
+ let topic_display_name: string | undefined;
+ if (opts.topic !== "") {
+ topic_display_name = opts.topic;
+ } else if (
+ !realm.realm_mandatory_topics &&
+ !$("input#stream_message_recipient_topic").is(":focus")
+ ) {
+ topic_display_name = util.get_final_topic_display_name(opts.topic);
+ }
+
+ if (stream_name && topic_display_name !== undefined) {
return $t(
{defaultMessage: "Message #{channel_name} > {topic_name}"},
- {channel_name: stream_name, topic_name: opts.topic},
+ {channel_name: stream_name, topic_name: topic_display_name},
);
} else if (stream_name) {
return $t({defaultMessage: "Message #{channel_name}"}, {channel_name: stream_name});
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js
index 225eaa6664e..672d3aa4854 100644
--- a/web/src/server_events_dispatch.js
+++ b/web/src/server_events_dispatch.js
@@ -283,6 +283,10 @@ export function dispatch_normal_event(event) {
"can_create_web_public_channel_group",
);
}
+
+ if (event.property === "mandatory_topics") {
+ compose_recipient.update_compose_area_placeholder_text();
+ }
}
break;
case "update_dict":
diff --git a/web/tests/dispatch.test.cjs b/web/tests/dispatch.test.cjs
index 693ae868051..b6e5b9cabc0 100644
--- a/web/tests/dispatch.test.cjs
+++ b/web/tests/dispatch.test.cjs
@@ -524,6 +524,9 @@ run_test("realm settings", ({override}) => {
});
assert_same(realm.realm_name, "new_realm_name");
+ event = event_fixtures.realm__update__mandatory_topics;
+ test_realm_boolean(event, "realm_mandatory_topics");
+
event = event_fixtures.realm__update__org_type;
dispatch(event);
assert_same(realm.realm_org_type, 50);
diff --git a/web/tests/lib/events.cjs b/web/tests/lib/events.cjs
index c14884149f5..83120376f48 100644
--- a/web/tests/lib/events.cjs
+++ b/web/tests/lib/events.cjs
@@ -347,6 +347,13 @@ exports.fixtures = {
value: false,
},
+ realm__update__mandatory_topics: {
+ type: "realm",
+ op: "update",
+ property: "mandatory_topics",
+ value: false,
+ },
+
realm__update__name: {
type: "realm",
op: "update",