Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic_list: Add "new topic" button at the bottom of zoomed topics.
Pratik Chanda92c0f0e6b692
diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.tsindex ef229e4c248..bbb0a583831 100644--- a/web/src/compose_ui.ts+++ b/web/src/compose_ui.ts@@ -214,7 +214,8 @@ function get_focus_area(opts: ComposeTriggeredOptions): string {if (opts.trigger === "clear topic button" ||opts.trigger === "compose_hotkey" ||- opts.trigger === "inbox_nofocus"+ opts.trigger === "inbox_nofocus" ||+ opts.trigger === "zoomed new topic") {return "input#stream_message_recipient_topic";}diff --git a/web/src/stream_list.ts b/web/src/stream_list.tsindex 35cae4836bf..3503035a9f2 100644--- a/web/src/stream_list.ts+++ b/web/src/stream_list.ts@@ -28,6 +28,7 @@ import * as popovers from "./popovers.ts";import * as scroll_util from "./scroll_util.ts";import {web_channel_default_view_values} from "./settings_config.ts";import * as settings_data from "./settings_data.ts";+import {realm} from "./state_data.ts";import * as stream_data from "./stream_data.ts";import * as stream_list_sort from "./stream_list_sort.ts";import type {StreamListSection} from "./stream_list_sort.ts";@@ -1356,18 +1357,30 @@ export function set_event_handlers({on_sidebar_channel_click(stream_id, e, show_channel_feed);});- $("#stream_filters").on("click", ".channel-new-topic-button", function (this: HTMLElement, e) {- e.stopPropagation();- e.preventDefault();- const stream_id = Number.parseInt(this.getAttribute("data-stream-id")!, 10);- compose_actions.start({- message_type: "stream",- stream_id,- topic: "",- trigger: "clear topic button",- keep_composebox_empty: true,- });- });+ $("#stream_filters").on(+ "click",+ ".channel-new-topic-button, .zoomed-new-topic",+ function (this: HTMLElement, e) {+ e.stopPropagation();+ e.preventDefault();+ const stream_id = Number.parseInt(this.getAttribute("data-stream-id")!, 10);+ let trigger = "clear topic button";+ let topic = "";++ if ($(e.target).closest(".zoomed-new-topic").length > 0) {+ trigger = "zoomed new topic";+ topic = $("#topic_filter_query").text().trim().slice(0, realm.max_topic_length);+ }++ compose_actions.start({+ message_type: "stream",+ stream_id,+ topic,+ trigger,+ keep_composebox_empty: true,+ });+ },+ );function toggle_pm_header_icon(): void {if (pm_list.is_private_messages_collapsed()) {diff --git a/web/src/topic_list.ts b/web/src/topic_list.tsindex 7604919c524..d36b6019fd3 100644--- a/web/src/topic_list.ts+++ b/web/src/topic_list.ts@@ -5,6 +5,7 @@ import assert from "minimalistic-assert";import render_more_topics from "../templates/more_topics.hbs";import render_more_topics_spinner from "../templates/more_topics_spinner.hbs";import render_topic_list_item from "../templates/topic_list_item.hbs";+import render_topic_list_new_topic from "../templates/topic_list_new_topic.hbs";import {all_messages_data} from "./all_messages_data.ts";import * as blueslip from "./blueslip.ts";@@ -13,6 +14,7 @@ import type {TypeaheadInputElement} from "./bootstrap_typeahead.ts";import * as mouse_drag from "./mouse_drag.ts";import * as popover_menus from "./popover_menus.ts";import * as scroll_util from "./scroll_util.ts";+import * as stream_data from "./stream_data.ts";import * as stream_topic_history from "./stream_topic_history.ts";import * as stream_topic_history_util from "./stream_topic_history_util.ts";import type {StreamSubscription} from "./sub_store.ts";@@ -105,6 +107,9 @@ type ListInfoNodeOptions =}| {type: "spinner";+ }+ | {+ type: "new_topic";};export type ListInfoNode = vdom.Node<ListInfoNodeOptions>;@@ -167,6 +172,21 @@ export function spinner_li(): ListInfoNode {};}+export function new_topic(stream_id: number): ListInfoNode {+ const render = (): string => render_topic_list_new_topic({stream_id});++ const eq = (other: ListInfoNode): boolean => other.type === "new_topic";++ const key = "more";++ return {+ key,+ type: "new_topic",+ render,+ eq,+ };+}+export function is_full_topic_history_available(stream_id: number,num_topics_displayed: number,@@ -289,6 +309,8 @@ export class TopicListWidget {const attrs: [string, string][] = [["class", topic_list_classes.join(" ")]];const nodes = list_info.items.map((conversation) => formatter(conversation));+ const stream = stream_data.get_sub_by_id(this.my_stream_id);+ assert(stream);if (spinner) {nodes.push(spinner_li());@@ -300,6 +322,8 @@ export class TopicListWidget {list_info.more_topics_unread_count_muted,),);+ } else if (is_zoomed && stream_data.can_post_messages_in_stream(stream)) {+ nodes.push(new_topic(this.my_stream_id));}const dom = vdom.ul({diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.cssindex 7c4bd9af671..8362c2a39bc 100644--- a/web/styles/left_sidebar.css+++ b/web/styles/left_sidebar.css@@ -711,6 +711,10 @@}}+ &:has(.zoomed-new-topic):hover {+ background: var(--color-background-sidebar-action-heading-hover);+ }+&:has(.sidebar-topic-action-heading):hover {background-color: var(--color-background-sidebar-action-heading-hover);}@@ -1855,6 +1859,52 @@ li.active-sub-filter {align-self: baseline;}+.zoomed-new-topic {+ display: grid;+ grid-template:+ "starting-offset starting-anchor-element icon-content-gap row-content ending-offset"+ var(--line-height-sidebar-row-prominent)+ ". . . row-content ."+ auto+ / var(--input-icon-starting-offset) var(+ --left-sidebar-icon-column-width+ )+ var(--left-sidebar-icon-content-gap)+ minmax(0, 1fr)+ 0;+ color: var(--color-text-sidebar-action-heading);++ .topic-list-new-topic-icon {+ grid-area: starting-anchor-element;+ place-self: center end;+ }++ .new-topic-label {+ grid-area: row-content;+ margin-top: -0.06em;+ font-size: var(--font-size-sidebar-action-heading);+ font-weight: var(--font-weight-sidebar-action-heading);+ font-variant: var(--font-variant-sidebar-action-heading);+ font-feature-settings: var(+ --font-feature-settings-sidebar-action-heading+ );+ text-transform: var(--text-transform-sidebar-action-heading);+ }++ &:not(:active):focus {+ text-decoration: none;+ border: none;+ outline: none;+ }++ &:hover,+ &:focus-visible {+ border-radius: 4px;+ text-decoration: none;+ color: var(--color-text-sidebar-action-heading);+ }+}+.channel-new-topic-button {/* display: flex; is set on visible channels andchannel-row hovers. */@@ -2035,7 +2085,10 @@ ul.topic-list:has(.show-more-topics)::after {#stream_filters.narrow-filter.topic-list- .bottom_left_row:has(a.sidebar-topic-action-heading:focus-visible) {+ .bottom_left_row:has(+ a.sidebar-topic-action-heading:focus-visible,+ a.zoomed-new-topic:focus-visible+ ) {outline: 2px solid var(--color-outline-focus);outline-offset: -2px;background-color: var(--color-background-hover-narrow-filter);@@ -2052,6 +2105,15 @@ li.topic-list-item {position: relative;padding-right: 5px;margin-left: var(--left-sidebar-toggle-width-offset);++ &:has(.zoomed-new-topic) {+ /* We set a margin equal to starting-offset of filter-input to match+ its alignment */+ margin-left: calc(+ var(--left-sidebar-toggle-width-offset) -+ var(--input-icon-starting-offset)+ );+ }}.dm-box {diff --git a/web/templates/topic_list_new_topic.hbs b/web/templates/topic_list_new_topic.hbsnew file mode 100644index 00000000000..16aa5caa7ed--- /dev/null+++ b/web/templates/topic_list_new_topic.hbs@@ -0,0 +1,6 @@+<li class="bottom_left_row topic-list-item">+ <a class="zoomed-new-topic" data-stream-id="{{stream_id}}" href="">+ <i class="topic-list-new-topic-icon zulip-icon zulip-icon-square-plus" aria-hidden="true"></i>+ <span class="new-topic-label">{{~t "NEW TOPIC" ~}}</span>+ </a>+</li>