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.

left_sidebar: Add Channel display options to left sidebar three dot.

Amit Patilfd5d37b4408a
diff --git a/starlight_help/src/content/include/_ConfigureChannelLinks.mdx b/starlight_help/src/content/include/_ConfigureChannelLinks.mdx
index 817b6e8bc11..e793b9339c1 100644
--- a/starlight_help/src/content/include/_ConfigureChannelLinks.mdx
+++ b/starlight_help/src/content/include/_ConfigureChannelLinks.mdx
@@ -13,7 +13,7 @@ channel, the top topic, or the top unread topic.
<NavigationSteps target="settings/preferences" />
1. Under **Navigation**, select your preferred option from the
- **Channel links in the left sidebar go to** dropdown.
+ **Clicking on a channel in the left sidebar navigates to** dropdown.
</FlattenedSteps>
</TabItem>
</Tabs>
diff --git a/web/src/channel_folders_popover.ts b/web/src/channel_folders_popover.ts
index 89b43c9db2a..3b8145c6f8a 100644
--- a/web/src/channel_folders_popover.ts
+++ b/web/src/channel_folders_popover.ts
@@ -10,6 +10,7 @@ import * as channel_folders_ui from "./channel_folders_ui.ts";
import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area.ts";
import * as pm_list from "./pm_list.ts";
import * as popover_menus from "./popover_menus.ts";
+import * as settings_config from "./settings_config.ts";
import * as settings_data from "./settings_data.ts";
import {current_user} from "./state_data.ts";
import * as stream_list from "./stream_list.ts";
@@ -29,6 +30,45 @@ function do_change_show_channel_folders_left_sidebar(instance: tippy.Instance):
popover_menus.hide_current_popover_if_visible(instance);
}
+function do_change_web_stream_unreads_count_display_policy(
+ instance: tippy.Instance,
+ value: number,
+): void {
+ if (user_settings.web_stream_unreads_count_display_policy === value) {
+ popover_menus.hide_current_popover_if_visible(instance);
+ return;
+ }
+
+ const data = {
+ web_stream_unreads_count_display_policy: value,
+ };
+
+ void channel.patch({
+ url: "/json/settings",
+ data,
+ });
+
+ popover_menus.hide_current_popover_if_visible(instance);
+}
+
+function do_change_web_channel_default_view(instance: tippy.Instance, value: number): void {
+ if (user_settings.web_channel_default_view === value) {
+ popover_menus.hide_current_popover_if_visible(instance);
+ return;
+ }
+
+ const data = {
+ web_channel_default_view: value,
+ };
+
+ void channel.patch({
+ url: "/json/settings",
+ data,
+ });
+
+ popover_menus.hide_current_popover_if_visible(instance);
+}
+
function do_change_show_channel_folders_inbox(instance: tippy.Instance): void {
const show_channel_folders = user_settings.web_inbox_show_channel_folders;
const data = {
@@ -86,6 +126,16 @@ export function initialize(): void {
$popper.one("click", "#left_sidebar_collapse_all", () => {
collapse_all_sections(instance);
});
+
+ $popper.one("click", ".web_stream_unreads_count_display_policy_selector", (e) => {
+ const value = Number($(e.currentTarget).attr("value"));
+ do_change_web_stream_unreads_count_display_policy(instance, value);
+ });
+
+ $popper.one("click", ".web_channel_default_view_selector", (e) => {
+ const value = Number($(e.currentTarget).attr("value"));
+ do_change_web_channel_default_view(instance, value);
+ });
},
onShow(instance) {
const show_channel_folders = user_settings.web_left_sidebar_show_channel_folders;
@@ -99,6 +149,13 @@ export function initialize(): void {
show_channel_folders,
channel_folders_id: "left_sidebar_channel_folders",
show_collapse_expand_all_options,
+ web_stream_unreads_count_display_policy_values:
+ settings_config.web_stream_unreads_count_display_policy_values,
+ web_stream_unreads_count_display_policy:
+ user_settings.web_stream_unreads_count_display_policy,
+ web_channel_default_view_values:
+ settings_config.web_channel_default_view_values,
+ web_channel_default_view: user_settings.web_channel_default_view,
}),
),
);
diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.css
index 42810ed6ef7..e5f74db6488 100644
--- a/web/styles/left_sidebar.css
+++ b/web/styles/left_sidebar.css
@@ -2551,3 +2551,24 @@ body:not(.spectator-view)
color: var(--color-vdots-visible);
}
}
+
+#left-sidebar-menu-popover {
+ /* No hover effect on the label */
+ .display-style-selector-header:hover {
+ background: inherit;
+ cursor: default;
+ }
+
+ .popover-menu-link:not(.display-style-selector-header) {
+ display: grid;
+ grid-template: "left-icon row-content" auto / 1.125em minmax(
+ max-content,
+ 1fr
+ );
+ align-items: center;
+
+ .popover-menu-label {
+ grid-area: row-content;
+ }
+ }
+}
diff --git a/web/templates/popovers/left_sidebar_menu_popover.hbs b/web/templates/popovers/left_sidebar_menu_popover.hbs
index 5857710298e..13406f6f366 100644
--- a/web/templates/popovers/left_sidebar_menu_popover.hbs
+++ b/web/templates/popovers/left_sidebar_menu_popover.hbs
@@ -1,4 +1,4 @@
-<div class="popover-menu" data-simplebar data-simplebar-tab-index="-1">
+<div class="popover-menu" id="left-sidebar-menu-popover" data-simplebar data-simplebar-tab-index="-1">
<ul role="menu" class="popover-menu-list">
{{#if show_collapse_expand_all_options }}
<li role="none" class="link-item popover-menu-list-item">
@@ -24,5 +24,38 @@
{{/if}}
</a>
</li>
+ <li role="separator" class="popover-menu-separator"></li>
+ <li role="none" class="link-item">
+ <label class="display-style-selector-header popover-menu-link" role="menuitem">
+ <span class="popover-menu-label">
+ {{t "Show unread counts for"}}
+ </span>
+ </label>
+ </li>
+ {{#each (object_values web_stream_unreads_count_display_policy_values)}}
+ <li role="none" class="web_stream_unreads_count_display_policy_selector link-item" value="{{this.code}}">
+ <label class="popover-menu-link" role="menuitem" tabindex="0">
+ <input type="radio" class="web_stream_unreads_count_display_policy_choice" name="web_stream_unreads_count_display_policy_values" value="{{this.code}}" {{#if (eq this.code ../web_stream_unreads_count_display_policy)}}checked{{/if}}/>
+ <span class="popover-menu-label">{{this.description}}</span>
+ </label>
+ </li>
+ {{/each}}
+
+ <li role="separator" class="popover-menu-separator"></li>
+ <li role="none" class="link-item">
+ <label class="display-style-selector-header popover-menu-link" role="menuitem">
+ <span class="popover-menu-label">
+ {{t "Clicking on a channel navigates to"}}
+ </span>
+ </label>
+ </li>
+ {{#each (object_values web_channel_default_view_values)}}
+ <li role="none" class="web_channel_default_view_selector link-item" value="{{this.code}}">
+ <label class="popover-menu-link" role="menuitem" tabindex="0">
+ <input type="radio" class="web_channel_default_view_choice" name="web_channel_default_view_values" value="{{this.code}}" {{#if (eq this.code ../web_channel_default_view)}}checked{{/if}}/>
+ <span class="popover-menu-label">{{this.description}}</span>
+ </label>
+ </li>
+ {{/each}}
</ul>
</div>
diff --git a/web/templates/settings/preferences_navigation.hbs b/web/templates/settings/preferences_navigation.hbs
index 6c06bac4ec4..c16bbe37219 100644
--- a/web/templates/settings/preferences_navigation.hbs
+++ b/web/templates/settings/preferences_navigation.hbs
@@ -44,7 +44,7 @@
<div class="input-group">
<label for="{{prefix}}web_channel_default_view" class="settings-field-label">
- {{t "Channel links in the left sidebar go to" }}
+ {{t "Clicking on a channel in the left sidebar navigates to" }}
{{#if for_realm_settings}}
{{> ../components/icon_button icon="reset" intent="neutral" custom_classes="reset-user-setting-to-default" data-tippy-content=(t "Reset users to default") aria-label=(t "Reset users to default") }}
{{/if}}