mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
drafts: Add placeholder text for drafts with no channel selected.
This commit handles the empty channel placeholder for drafts saved without a channel selected. When these drafts also do not have a topic, we display "No topic selected" in tandem with "No channel selected", since we are unable to access the channel configuration to determine if we should display realm_empty_topic_display_name.
This commit is contained in:
@@ -646,13 +646,20 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | u
|
||||
let 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 {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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>
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user