Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
drafts: Add placeholder text for drafts with no channel selected.
Sayam Samal0d9e503adde4
diff --git a/web/src/drafts.ts b/web/src/drafts.tsindex ac02703c661..1166df981f4 100644--- a/web/src/drafts.ts+++ b/web/src/drafts.ts@@ -646,13 +646,20 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | ulet draft_topic_display_name = draft.topic;let is_empty_string_topic = false;- // If the channel is not known (recipient was not specified while the creation of the- // draft) and the topic is empty, the draft_topic_display_name will always be empty string- // and the draft title will appear as "# >". We don't use the term "general chat" until- // the channel is known.- if (sub && draft.topic === "" && stream_data.can_use_empty_topic(draft.stream_id)) {- draft_topic_display_name = util.get_final_topic_display_name("");+ if (draft.topic === "") {is_empty_string_topic = true;+ if (sub && stream_data.can_use_empty_topic(draft.stream_id)) {+ // If the channel is known and it allows empty topic, we display+ // the realm_empty_topic_display_name.+ draft_topic_display_name = util.get_final_topic_display_name("");+ } else {+ // If the channel is not known (channel field was empty during the+ // creation of the draft) or it doesn't allow empty topics, we display+ // "No topic entered". We can't use realm_empty_topic_display_name+ // for empty topics in unknown channels, since we are unaware of the+ // channel's configuration.+ draft_topic_display_name = $t({defaultMessage: "No topic entered"});+ }}return {diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex 2ab9d192cfe..b2e65970f76 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -2460,7 +2460,8 @@ body:not(.spectator-view) {.default-language-display,.empty-topic-display,-.empty-topic-placeholder-display::placeholder {+.empty-topic-placeholder-display::placeholder,+.drafts-unknown-msg-header-field {font-style: italic;}diff --git a/web/templates/draft.hbs b/web/templates/draft.hbsindex 2c2c67fd8fc..849591002ab 100644--- a/web/templates/draft.hbs+++ b/web/templates/draft.hbs@@ -10,7 +10,7 @@{{#if stream_name}}{{stream_name}}{{else}}- + <span class="drafts-unknown-msg-header-field">{{t "No channel selected" }}</span>{{/if}}</div><span class="stream_topic_separator"><i class="zulip-icon zulip-icon-chevron-right"></i></span>diff --git a/web/tests/drafts.test.cjs b/web/tests/drafts.test.cjsindex f23bda22311..400c4cb51f1 100644--- a/web/tests/drafts.test.cjs+++ b/web/tests/drafts.test.cjs@@ -633,8 +633,8 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {assert.deepEqual(draft_model.get(), data);override(realm, "realm_topics_policy", "disable_empty_topic");- expected[5].topic_display_name = "";- expected[5].is_empty_string_topic = false;+ expected[5].topic_display_name = "translated: No topic entered";+ expected[5].is_empty_string_topic = true;assert.deepEqual(draft_model.get(), data);const stub_render_now = timerender.render_now;