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 UI to manage and view channels in folder.

Sahil Batrac4a5074f09fe
diff --git a/web/src/channel_folders_popover.ts b/web/src/channel_folders_popover.ts
index b530da1091b..2fed93734fe 100644
--- a/web/src/channel_folders_popover.ts
+++ b/web/src/channel_folders_popover.ts
@@ -3,13 +3,18 @@ import assert from "minimalistic-assert";
import type * as tippy from "tippy.js";
import render_channel_folder_setting_popover from "../templates/popovers/channel_folder_setting_popover.hbs";
+import render_left_sidebar_folder_popover from "../templates/popovers/left_sidebar/left_sidebar_folder_popover.hbs";
import * as channel from "./channel.ts";
+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_data from "./settings_data.ts";
+import {current_user} from "./state_data.ts";
import * as stream_list from "./stream_list.ts";
-import {parse_html} from "./ui_util.ts";
+import * as stream_settings_ui from "./stream_settings_ui.ts";
+import * as ui_util from "./ui_util.ts";
import {user_settings} from "./user_settings.ts";
function do_change_show_channel_folders_left_sidebar(instance: tippy.Instance): void {
@@ -89,7 +94,7 @@ export function initialize(): void {
// prep the instance for showing
popover_menus.popover_instances.show_folders_sidebar = instance;
instance.setContent(
- parse_html(
+ ui_util.parse_html(
render_channel_folder_setting_popover({
show_channel_folders,
channel_folders_id: "left_sidebar_channel_folders",
@@ -124,7 +129,7 @@ export function initialize(): void {
// prep the instance for showing
popover_menus.popover_instances.show_folders_inbox = instance;
instance.setContent(
- parse_html(
+ ui_util.parse_html(
render_channel_folder_setting_popover({
show_channel_folders,
channel_folders_id: "inbox_channel_folders",
@@ -141,4 +146,53 @@ export function initialize(): void {
popover_menus.popover_instances.show_folders_inbox = null;
},
});
+
+ $("#streams_list").on(
+ "click",
+ ".stream-list-section-container .folder-section-sidebar-menu-icon",
+ function (this: HTMLElement, e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ const folder_id = Number.parseInt(
+ $(this).closest(".stream-list-section-container").attr("data-section-id")!,
+ 10,
+ );
+ popover_menus.toggle_popover_menu(this, {
+ ...popover_menus.left_sidebar_tippy_options,
+ theme: "popover-menu",
+ onMount(instance) {
+ const $popper = $(instance.popper);
+ assert(instance.reference instanceof HTMLElement);
+ ui_util.show_left_sidebar_menu_icon(instance.reference);
+ $popper.one("click", "#folder_popover_view_channels", () => {
+ let section = "all";
+ if (current_user.is_guest) {
+ section = "subscribed";
+ }
+ stream_settings_ui.launch(section, undefined, undefined, folder_id);
+ });
+ $popper.one("click", "#folder_popover_manage_folder", () => {
+ channel_folders_ui.handle_editing_channel_folder(folder_id);
+ });
+ },
+ onShow(instance) {
+ instance.setContent(
+ ui_util.parse_html(
+ render_left_sidebar_folder_popover({
+ can_manage_folder: settings_data.can_user_manage_folder(),
+ }),
+ ),
+ );
+ popover_menus.on_show_prep(instance);
+
+ return undefined;
+ },
+ onHidden(instance) {
+ ui_util.hide_left_sidebar_menu_icon();
+ instance.destroy();
+ },
+ });
+ },
+ );
}
diff --git a/web/src/stream_list.ts b/web/src/stream_list.ts
index b22b6f4f4e9..a66f59c25b9 100644
--- a/web/src/stream_list.ts
+++ b/web/src/stream_list.ts
@@ -23,6 +23,7 @@ import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area.ts
import {localstorage} from "./localstorage.ts";
import * as mouse_drag from "./mouse_drag.ts";
import * as narrow_state from "./narrow_state.ts";
+import {page_params} from "./page_params.ts";
import * as pm_list from "./pm_list.ts";
import * as popovers from "./popovers.ts";
import * as scroll_util from "./scroll_util.ts";
@@ -252,6 +253,7 @@ export let stream_list_section_container_html = function (
id: section.id,
section_title: section.section_title,
plus_icon_url: can_create_streams ? get_section_channel_plus_icon_url(section) : undefined,
+ show_folder_action_icon: !page_params.is_spectator && section.folder_id !== null,
});
};
diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.ts
index 96fb80db556..445399bda76 100644
--- a/web/src/stream_settings_ui.ts
+++ b/web/src/stream_settings_ui.ts
@@ -1187,7 +1187,7 @@ function show_right_section(): void {
export function change_state(
section: string,
left_side_tab: string | undefined,
- right_side_tab: string,
+ right_side_tab: string | undefined,
folder_id?: number,
): void {
assert(toggler !== undefined);
@@ -1199,6 +1199,9 @@ export function change_state(
}
if (section === "all") {
+ if (folder_id !== undefined) {
+ stream_settings_components.set_folder_filter_dropdown_value(folder_id);
+ }
toggler.goto("all-streams");
stream_edit.empty_right_panel();
return;
@@ -1214,6 +1217,7 @@ export function change_state(
if (/\d+/.test(section)) {
const stream_id = Number.parseInt(section, 10);
show_right_section();
+ assert(right_side_tab !== undefined);
stream_edit_toggler.set_select_tab(right_side_tab);
if (left_side_tab === undefined) {
@@ -1262,7 +1266,7 @@ export function change_state(
export function launch(
section: string,
left_side_tab: string | undefined,
- right_side_tab: string,
+ right_side_tab: string | undefined,
folder_id?: number,
): void {
setup_page(() => {
diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.css
index 9a06532e818..b05c6fb30a7 100644
--- a/web/styles/left_sidebar.css
+++ b/web/styles/left_sidebar.css
@@ -450,6 +450,12 @@
}
}
+ &:has(.left_sidebar_menu_icon_visible) {
+ box-shadow: inset 0 0 0 1px var(--color-shadow-sidebar-row-hover);
+ background-color: var(--color-background-hover-narrow-filter);
+ border-radius: 4px;
+ }
+
.stream-list-section-toggle {
color: var(--color-text-sidebar-heading);
opacity: var(--opacity-sidebar-heading-icon);
@@ -1937,6 +1943,10 @@ li.active-sub-filter {
grid-area: ending-anchor-element;
}
+.stream-list-subsection-header .sidebar-menu-icon {
+ grid-area: three-dot-placeholder;
+}
+
.stream-name {
white-space: nowrap;
overflow-x: hidden;
@@ -1969,7 +1979,8 @@ li.active-sub-filter {
positioning. We should fix that.
*/
.bottom_left_row .sidebar-menu-icon,
-.top_left_row .sidebar-menu-icon {
+.top_left_row .sidebar-menu-icon,
+.stream-list-section-container .sidebar-menu-icon {
display: none;
cursor: pointer;
/* Use a flex container to handle
@@ -2032,6 +2043,7 @@ li.active-sub-filter {
#stream_filters li:hover .stream-sidebar-menu-icon,
.top_left_row:hover .sidebar-menu-icon,
.bottom_left_row:hover .sidebar-menu-icon,
+#stream_filters .stream-list-subsection-header:hover .sidebar-menu-icon,
.app-main .column-left .left-sidebar .left_sidebar_menu_icon_visible {
/* We push against `display: none` with
`display: flex` because the sidebar vdots
diff --git a/web/templates/popovers/left_sidebar/left_sidebar_folder_popover.hbs b/web/templates/popovers/left_sidebar/left_sidebar_folder_popover.hbs
new file mode 100644
index 00000000000..1d083b0ef6f
--- /dev/null
+++ b/web/templates/popovers/left_sidebar/left_sidebar_folder_popover.hbs
@@ -0,0 +1,18 @@
+<div class="popover-menu" data-simplebar data-simplebar-tab-index="-1">
+ <ul role="menu" class="popover-menu-list">
+ <li role="none" class="link-item popover-menu-list-item">
+ <a role="menuitem" id="folder_popover_view_channels" class="popover-menu-link" tabindex="0">
+ <i class="popover-menu-icon zulip-icon zulip-icon-hashtag" aria-hidden="true"></i>
+ <span class="popover-menu-label">{{t "View channels" }}</span>
+ </a>
+ </li>
+ {{#if can_manage_folder}}
+ <li role="none" class="link-item popover-menu-list-item">
+ <a role="menuitem" id="folder_popover_manage_folder" class="popover-menu-link" tabindex="0">
+ <i class="popover-menu-icon zulip-icon zulip-icon-folder-cog" aria-hidden="true"></i>
+ <span class="popover-menu-label">{{t "Manage folder" }}</span>
+ </a>
+ </li>
+ {{/if}}
+ </ul>
+</div>
diff --git a/web/templates/stream_list_section_container.hbs b/web/templates/stream_list_section_container.hbs
index 62326b176da..bff3c71fa54 100644
--- a/web/templates/stream_list_section_container.hbs
+++ b/web/templates/stream_list_section_container.hbs
@@ -16,6 +16,9 @@
<i class="zulip-icon zulip-icon-masked-unread"></i>
</span>
</div>
+ {{#if show_folder_action_icon}}
+ <span class="sidebar-menu-icon folder-section-sidebar-menu-icon"><i class="zulip-icon zulip-icon-more-vertical" aria-hidden="true"></i></span>
+ {{/if}}
</div>
<ul id="stream-list-{{id}}" class="stream-list-section"></ul>
</div>