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.

channel_folder_ui: Add channel list in edit folder modal.

Pratik Chandaa54004db346c
diff --git a/docs/THIRDPARTY b/docs/THIRDPARTY
index 2a0959a2c6a..e6f69f999c4 100644
--- a/docs/THIRDPARTY
+++ b/docs/THIRDPARTY
@@ -258,6 +258,10 @@ Files: web/icons/folder.svg
Copyright: 2013-2023 Cole Bemis (https://lucide.dev/icons/folder)
License: ISC License
+Files: web/icons/folder-cog.svg
+Copyright: 2013-2023 Cole Bemis (https://lucide.dev/icons/folder-cog)
+License: ISC License
+
Files: web/icons/follow.svg
Copyright: 2013-2023 Cole Bemis (https://lucide.dev/icons/rss)
License: ISC License
diff --git a/web/icons/folder-cog.svg b/web/icons/folder-cog.svg
new file mode 100644
index 00000000000..ed9fafcfc1c
--- /dev/null
+++ b/web/icons/folder-cog.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path d="m 18,14 c -2.197294,0 -4,1.802706 -4,4 0,2.197294 1.802706,4 4,4 2.197294,0 4,-1.802706 4,-4 0,-2.197294 -1.802706,-4 -4,-4 z m 0,2 c 1.116414,0 2,0.883586 2,2 0,1.116414 -0.883586,2 -2,2 -1.116414,0 -2,-0.883586 -2,-2 0,-1.116414 0.883586,-2 2,-2 z m 3.960937,2.558594 c -0.09713,0.684939 -0.370525,1.316189 -0.771484,1.845703 l 0.123047,0.05078 a 1,1 0 0 0 1.306641,-0.541016 1,1 0 0 0 -0.541016,-1.30664 z M 19.875,18.703125 a 1,1 0 0 0 -0.02734,0.0625 1,1 0 0 0 -0.02734,0.07031 c 0.01975,-0.04359 0.03802,-0.08755 0.05469,-0.132812 z M 21.695312,15.46875 A 1,1 0 0 0 21.3125,15.54492 l -0.123047,0.05078 c 0.400959,0.529514 0.674358,1.160764 0.771484,1.845703 l 0.117188,-0.04883 a 1,1 0 0 0 0.541016,-1.306641 1,1 0 0 0 -0.923829,-0.617187 z m -1.875,1.695312 a 1,1 0 0 0 0.02734,0.07031 1,1 0 0 0 0.02734,0.0625 c -0.01666,-0.04527 -0.03494,-0.08922 -0.05469,-0.132813 z m -0.986328,2.658204 a 1,1 0 0 0 -0.06836,0.02539 1,1 0 0 0 -0.06055,0.02734 c 0.04342,-0.01608 0.08703,-0.03381 0.128906,-0.05273 z m 1.570313,1.367187 c -0.529766,0.401082 -1.162324,0.67459 -1.847656,0.771484 l 0.04883,0.117188 a 1,1 0 0 0 1.30664,0.542969 1,1 0 0 0 0.542969,-1.306641 z M 19.53125,13.304688 a 1,1 0 0 0 -0.382813,0.07617 1,1 0 0 0 -0.541015,0.541016 l -0.04883,0.117188 c 0.684977,0.09713 1.316225,0.370461 1.845703,0.771484 L 20.455078,14.6875 A 1,1 0 0 0 19.914062,13.380859 1,1 0 0 0 19.53125,13.304688 Z M 18.705078,16.125 a 1,1 0 0 0 0.06055,0.02734 1,1 0 0 0 0.06836,0.02539 c -0.04188,-0.01892 -0.08549,-0.03666 -0.128906,-0.05273 z m -1.541016,3.695312 c 0.04359,0.01975 0.08755,0.03802 0.132813,0.05469 a 1,1 0 0 0 -0.0625,-0.02734 1,1 0 0 0 -0.07031,-0.02734 z m -1.568359,1.369141 -0.05078,0.123047 a 1,1 0 0 0 0.541015,1.306641 1,1 0 0 0 1.306641,-0.541016 l 0.04883,-0.117188 C 16.75647,21.863807 16.12522,21.590412 15.595706,21.189453 Z m 0.873047,-7.884765 a 1,1 0 0 0 -0.382813,0.07617 1,1 0 0 0 -0.541015,1.306641 l 0.05078,0.123047 c 0.529514,-0.400959 1.160764,-0.674358 1.845703,-0.771484 l -0.04883,-0.117188 A 1,1 0 0 0 16.46875,13.304688 Z M 17.296875,16.125 c -0.04527,0.01666 -0.08922,0.03494 -0.132813,0.05469 a 1,1 0 0 0 0.07031,-0.02734 1,1 0 0 0 0.0625,-0.02734 z m -2.992187,-0.65625 a 1,1 0 0 0 -0.923829,0.617187 1,1 0 0 0 0.541016,1.306641 l 0.117188,0.04883 c 0.09713,-0.684977 0.370461,-1.316225 0.771484,-1.845703 L 14.6875,15.544922 a 1,1 0 0 0 -0.382812,-0.07617 z m 1.873046,1.697266 c -0.01892,0.04188 -0.03666,0.08549 -0.05273,0.128906 a 1,1 0 0 0 0.02734,-0.06055 1,1 0 0 0 0.02539,-0.06836 z m -2.138671,1.390625 -0.117188,0.04883 a 1,1 0 0 0 -0.541016,1.30664 1,1 0 0 0 1.306641,0.541016 l 0.121094,-0.05078 C 14.407791,19.872716 14.135915,19.241683 14.039063,18.556641 Z M 16.125,18.705078 c 0.01608,0.04343 0.03381,0.08703 0.05273,0.128906 A 1,1 0 0 0 16.15234,18.765624 1,1 0 0 0 16.125,18.705074 Z M 4,2 C 2.3549904,2 1,3.3549904 1,5 v 13 c 0,1.64501 1.3549904,3 3,3 h 6.300781 a 1,1 0 0 0 1,-1 1,1 0 0 0 -1,-1 H 4 C 3.4358706,19 3,18.564129 3,18 V 5 C 3,4.4358706 3.4358706,4 4,4 h 3.9804687 a 1.0001,1.0001 0 0 0 0.00977,0 C 8.3288321,3.99668 8.6400358,4.1642012 8.828125,4.4453125 l 0.625,1.1367187 a 1.0001,1.0001 0 0 0 0.041016,0.068359 C 10.048358,6.4919668 10.992324,6.9998341 12,7 h 8 c 0.564129,0 1,0.4358706 1,1 v 3.300781 a 1,1 0 0 0 1,1 1,1 0 0 0 1,-1 V 8 C 23,6.3549904 21.64501,5 20,5 H 12 C 11.665002,4.9999448 11.357974,4.8327914 11.171875,4.5546875 l -0.625,-1.1367187 a 1.0001,1.0001 0 0 0 -0.04102,-0.068359 C 9.9458558,2.4991408 8.9889395,1.990017 7.9707031,2 Z" />
+</svg>
diff --git a/web/src/channel_folders.ts b/web/src/channel_folders.ts
index fdb92c21925..9b85d6a7b84 100644
--- a/web/src/channel_folders.ts
+++ b/web/src/channel_folders.ts
@@ -14,6 +14,10 @@ let channel_folder_name_dict: FoldDict<ChannelFolder>;
let channel_folder_by_id_dict: Map<number, ChannelFolder>;
let active_channel_folder_ids: Set<number>;
+function compare_by_name(a: StreamSubscription, b: StreamSubscription): number {
+ return util.strcmp(a.name, b.name);
+}
+
export function clean_up_description(channel_folder: ChannelFolder): void {
if (channel_folder.rendered_description !== undefined) {
channel_folder.rendered_description = channel_folder.rendered_description
@@ -137,6 +141,12 @@ export function get_streams_in_folder(folder_id: number): StreamSubscription[] {
return streams;
}
+export function get_sorted_streams_in_folder(folder_id: number): StreamSubscription[] {
+ const streams = get_streams_in_folder(folder_id);
+ streams.sort(compare_by_name);
+ return streams;
+}
+
export function get_stream_ids_in_folder(folder_id: number): number[] {
const streams = get_streams_in_folder(folder_id);
return streams.map((sub) => sub.stream_id);
diff --git a/web/src/channel_folders_ui.ts b/web/src/channel_folders_ui.ts
index 61675b8c44f..5b541ad4bcb 100644
--- a/web/src/channel_folders_ui.ts
+++ b/web/src/channel_folders_ui.ts
@@ -2,18 +2,29 @@ import $ from "jquery";
import * as z from "zod/mini";
import render_confirm_archive_channel_folder from "../templates/confirm_dialog/confirm_archive_channel_folder.hbs";
+import render_stream_list_item from "../templates/stream_list_item.hbs";
import render_create_channel_folder_modal from "../templates/stream_settings/create_channel_folder_modal.hbs";
import render_edit_channel_folder_modal from "../templates/stream_settings/edit_channel_folder_modal.hbs";
+import * as banners from "./banners.ts";
+import * as buttons from "./buttons.ts";
import * as channel from "./channel.ts";
import * as channel_folders from "./channel_folders.ts";
import * as confirm_dialog from "./confirm_dialog.ts";
import * as dialog_widget from "./dialog_widget.ts";
+import * as hash_util from "./hash_util.ts";
import {$t_html} from "./i18n.ts";
+import * as ListWidget from "./list_widget.ts";
+import type {ListWidget as ListWidgetType} from "./list_widget.ts";
+import * as modals from "./modals.ts";
import * as people from "./people.ts";
import {realm} from "./state_data.ts";
+import type {StreamSubscription} from "./sub_store.ts";
import * as ui_report from "./ui_report.ts";
+let channel_folder_stream_list_widget: ListWidgetType<StreamSubscription> | undefined;
+let stream_list_widget_stream_ids: Set<number> | undefined;
+
export function add_channel_folder(): void {
const html_body = render_create_channel_folder_modal({
max_channel_folder_name_length: realm.max_channel_folder_name_length,
@@ -151,18 +162,134 @@ export function handle_archiving_channel_folder(folder_id: number): void {
});
}
+function format_channel_item_html(stream: StreamSubscription): string {
+ return render_stream_list_item({
+ name: stream.name,
+ stream_id: stream.stream_id,
+ stream_color: stream.color,
+ invite_only: stream.invite_only,
+ is_web_public: stream.is_web_public,
+ stream_edit_url: hash_util.channels_settings_edit_url(stream, "general"),
+ show_remove_channel_from_folder: true,
+ });
+}
+
+function render_channel_list(streams: StreamSubscription[], folder_id: number): void {
+ const $container = $("#edit_channel_folder .folder-stream-list");
+ $container.empty();
+ stream_list_widget_stream_ids = new Set(channel_folders.get_stream_ids_in_folder(folder_id));
+ channel_folder_stream_list_widget = ListWidget.create($container, streams, {
+ name: `edit-channel-folder-stream-list`,
+ get_item: ListWidget.default_get_item,
+ modifier_html(item) {
+ return format_channel_item_html(item);
+ },
+ filter: {
+ $element: $("#edit_channel_folder .stream-list-container .stream-search"),
+ predicate(item, value) {
+ return item?.name.toLocaleLowerCase().includes(value);
+ },
+ },
+ $simplebar_container: $("#edit_channel_folder .modal__content"),
+ });
+
+ $container.on("click", ".remove-button", (e) => {
+ e.stopPropagation();
+ e.preventDefault();
+ const $remove_button = $(e.currentTarget).closest(".remove-button");
+ buttons.show_button_loading_indicator($remove_button);
+ const stream_id = Number.parseInt(
+ $remove_button.closest(".stream-list-item").attr("data-stream-id")!,
+ 10,
+ );
+
+ function on_success(): void {
+ banners.open(
+ {
+ intent: "success",
+ label: $t_html({
+ defaultMessage: "Channel removed!",
+ }),
+ buttons: [],
+ close_button: false,
+ },
+ $("#channel_folder_banner"),
+ 1200,
+ );
+ }
+
+ function on_error(xhr: JQuery.jqXHR): void {
+ const error_message = channel.xhr_error_message(
+ $t_html({
+ defaultMessage: "Failed removing channel from the folder",
+ }),
+ xhr,
+ );
+ banners.open(
+ {
+ intent: "danger",
+ label: error_message,
+ buttons: [],
+ close_button: false,
+ },
+ $("#channel_folder_banner"),
+ 1200,
+ );
+ buttons.hide_button_loading_indicator($remove_button);
+ }
+
+ remove_channel_from_folder(stream_id, on_success, on_error);
+ });
+}
+
+function get_edit_modal_folder_id_if_open(): number | undefined {
+ const $edit_folder_modal = $("#edit_channel_folder");
+
+ if (!modals.any_active() || $edit_folder_modal.length === 0) {
+ return undefined;
+ }
+
+ return Number($edit_folder_modal.find(".stream-list-container").attr("data-folder-id"));
+}
+
+export function update_channel_folder_channels_list(
+ stream_id: number,
+ folder_id: number | null,
+): void {
+ const current_folder_id = get_edit_modal_folder_id_if_open();
+
+ if (!current_folder_id) {
+ return;
+ }
+
+ // We need to update the rendered list when either an item in the current list
+ // had a folder_id changed or an unrelated channel was set to current folder id.
+ const should_update_channel_list =
+ Boolean(stream_list_widget_stream_ids?.has(stream_id)) || folder_id === current_folder_id;
+
+ if (should_update_channel_list && channel_folder_stream_list_widget !== undefined) {
+ const subs = channel_folders.get_sorted_streams_in_folder(current_folder_id);
+ stream_list_widget_stream_ids = new Set(
+ channel_folders.get_stream_ids_in_folder(current_folder_id),
+ );
+ channel_folder_stream_list_widget.replace_list_data(subs);
+ }
+}
+
export function handle_editing_channel_folder(folder_id: number): void {
const folder = channel_folders.get_channel_folder_by_id(folder_id);
+ const subs = channel_folders.get_sorted_streams_in_folder(folder_id);
const html_body = render_edit_channel_folder_modal({
name: folder.name,
description: folder.description,
+ folder_id,
max_channel_folder_name_length: realm.max_channel_folder_name_length,
max_channel_folder_description_length: realm.max_channel_folder_description_length,
});
dialog_widget.launch({
- html_heading: $t_html({defaultMessage: "Edit channel folder"}),
+ html_heading: $t_html({defaultMessage: "Manage channel folder"}),
html_body,
id: "edit_channel_folder",
on_click() {
@@ -195,6 +322,12 @@ export function handle_editing_channel_folder(folder_id: number): void {
},
loading_spinner: true,
on_shown: () => $("#edit_channel_folder_name").trigger("focus"),
+ on_hidden() {
+ stream_list_widget_stream_ids = undefined;
+ },
update_submit_disabled_state_on_change: true,
+ post_render() {
+ render_channel_list(subs, folder_id);
+ },
});
}
diff --git a/web/src/dropdown_widget.ts b/web/src/dropdown_widget.ts
index b11b5e8e73b..8bdd9379f50 100644
--- a/web/src/dropdown_widget.ts
+++ b/web/src/dropdown_widget.ts
@@ -35,8 +35,10 @@ export type Option = {
bold_current_selection?: boolean;
has_delete_icon?: boolean;
has_edit_icon?: boolean;
+ has_manage_folder_icon?: boolean;
delete_icon_label?: string;
edit_icon_label?: string;
+ manage_folder_icon_label?: string;
};
export type DropdownWidgetOptions = {
diff --git a/web/src/stream_events.ts b/web/src/stream_events.ts
index eb758a95efe..d72d3090da0 100644
--- a/web/src/stream_events.ts
+++ b/web/src/stream_events.ts
@@ -6,6 +6,7 @@ import render_first_stream_created_modal from "../templates/stream_settings/firs
import * as activity_ui from "./activity_ui.ts";
import * as blueslip from "./blueslip.ts";
import * as browser_history from "./browser_history.ts";
+import * as channel_folders_ui from "./channel_folders_ui.ts";
import * as color_data from "./color_data.ts";
import * as compose_recipient from "./compose_recipient.ts";
import * as compose_state from "./compose_state.ts";
@@ -227,6 +228,7 @@ export function update_property<P extends keyof UpdatableStreamProperties>(
},
folder_id(value) {
stream_settings_ui.update_channel_folder(sub, value);
+ channel_folders_ui.update_channel_folder_channels_list(stream_id, value);
},
};
diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.ts
index 175331aa1cb..14455d52c58 100644
--- a/web/src/stream_settings_components.ts
+++ b/web/src/stream_settings_components.ts
@@ -326,9 +326,9 @@ export function set_up_folder_dropdown_widget(sub?: StreamSubscription): Dropdow
name: folder.name,
unique_id: folder.id,
has_delete_icon: true,
- has_edit_icon: true,
+ has_manage_folder_icon: true,
delete_icon_label: $t({defaultMessage: "Delete folder"}),
- edit_icon_label: $t({defaultMessage: "Edit folder"}),
+ manage_folder_icon_label: $t({defaultMessage: "Manage folder"}),
}));
const disabled_option = {
@@ -391,7 +391,7 @@ export function set_up_folder_dropdown_widget(sub?: StreamSubscription): Dropdow
if (
$(event.target).closest(
- `.${CSS.escape(widget_name)}-dropdown-list-container .dropdown-list-edit`,
+ `.${CSS.escape(widget_name)}-dropdown-list-container .dropdown-list-manage-folder`,
).length > 0
) {
const folder_id = Number.parseInt(
diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.ts
index 771e5386292..de835b37600 100644
--- a/web/src/tippyjs.ts
+++ b/web/src/tippyjs.ts
@@ -825,8 +825,8 @@ export function initialize(): void {
});
tippy.delegate("body", {
- target: ".folder_id-dropdown-list-container .dropdown-list-edit, .new_channel_folder_id-dropdown-list-container .dropdown-list-edit",
- content: $t({defaultMessage: "Edit folder"}),
+ target: ".folder_id-dropdown-list-container .dropdown-list-manage-folder, .new_channel_folder_id-dropdown-list-container .dropdown-list-manage-folder",
+ content: $t({defaultMessage: "Manage folder"}),
delay: LONG_HOVER_DELAY,
appendTo: () => document.body,
onHidden(instance) {
diff --git a/web/styles/modal.css b/web/styles/modal.css
index 912f1df1614..a9a9c5db7f3 100644
--- a/web/styles/modal.css
+++ b/web/styles/modal.css
@@ -197,9 +197,30 @@
/* Modal-specific CSS belongs below this point. */
+.folder-channels-list-header {
+ margin: 0;
+ font-weight: 600;
+ font-size: 1.125em; /* 18px at 16px em */
+}
+
#user-profile-modal .group-list-container,
#user-profile-modal .stream-list-container {
height: calc(100% - var(--header-line-height));
+}
+
+#edit_channel_folder .stream-list-container {
+ height: 30vh;
+}
+
+#channel_folder_banner {
+ &:has(.banner) {
+ margin-bottom: 10px;
+ }
+}
+
+#user-profile-modal .group-list-container,
+#user-profile-modal .stream-list-container,
+#edit_channel_folder .stream-list-container {
border-radius: 4px;
background-color: var(--background-color-user-profile-list-container);
border: 1px solid var(--color-border-user-profile-list-container);
@@ -253,13 +274,15 @@
}
.subscription-group-list,
- .subscription-stream-list {
+ .subscription-stream-list,
+ .edit-channel-folder-stream-list {
/* We set max-height to remaining height of stream-list-container
so that we don't clip it. Search field height takes up 2em of total. */
height: calc(100% - 2em);
.user-group-list,
- .user-stream-list {
+ .user-stream-list,
+ .folder-stream-list {
list-style: none;
margin: 0;
}
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 05d045736b8..3d604260c3d 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -2427,7 +2427,8 @@ body:not(.spectator-view) {
outline: none;
.dropdown-list-delete,
- .dropdown-list-edit {
+ .dropdown-list-edit,
+ .dropdown-list-manage-folder {
visibility: visible;
}
}
diff --git a/web/templates/dropdown_list.hbs b/web/templates/dropdown_list.hbs
index af493da295a..c88ea4cbabf 100644
--- a/web/templates/dropdown_list.hbs
+++ b/web/templates/dropdown_list.hbs
@@ -10,6 +10,9 @@
{{#if has_edit_icon}}
{{> components/icon_button custom_classes="dropdown-list-edit dropdown-list-control-button" intent="neutral" icon="edit" aria-label=edit_icon_label }}
{{/if}}
+ {{#if has_manage_folder_icon}}
+ {{> components/icon_button custom_classes="dropdown-list-manage-folder dropdown-list-control-button" intent="neutral" icon="folder-cog" aria-label=manage_folder_icon_label }}
+ {{/if}}
{{#if has_delete_icon}}
{{> components/icon_button custom_classes="dropdown-list-delete dropdown-list-control-button" intent="danger" icon="trash" aria-label=delete_icon_label }}
{{/if}}
@@ -53,6 +56,9 @@
{{#if has_edit_icon}}
{{> components/icon_button custom_classes="dropdown-list-edit dropdown-list-control-button" intent="neutral" icon="edit" aria-label=(t "Edit folder") }}
{{/if}}
+ {{#if has_manage_folder_icon}}
+ {{> components/icon_button custom_classes="dropdown-list-manage-folder dropdown-list-control-button" intent="neutral" icon="folder-cog" aria-label=manage_folder_icon_label }}
+ {{/if}}
{{#if has_delete_icon}}
{{> components/icon_button custom_classes="dropdown-list-delete dropdown-list-control-button" intent="danger" icon="trash" aria-label=(t "Delete folder") }}
{{/if}}
diff --git a/web/templates/settings/admin_channel_folder_list_item.hbs b/web/templates/settings/admin_channel_folder_list_item.hbs
index 8381ce95278..0338d792343 100644
--- a/web/templates/settings/admin_channel_folder_list_item.hbs
+++ b/web/templates/settings/admin_channel_folder_list_item.hbs
@@ -14,10 +14,10 @@
{{#if is_admin}}
<td class="actions">
{{> ../components/icon_button
- icon="edit"
+ icon="folder-cog"
intent="neutral"
custom_classes="tippy-zulip-delayed-tooltip edit-channel-folder-button"
- data-tippy-content=(t "Edit")
+ data-tippy-content=(t "Manage folder")
}}
{{> ../components/icon_button
icon="trash"
diff --git a/web/templates/stream_list_item.hbs b/web/templates/stream_list_item.hbs
index b25f67a5970..2975203b475 100644
--- a/web/templates/stream_list_item.hbs
+++ b/web/templates/stream_list_item.hbs
@@ -16,6 +16,9 @@
{{> components/icon_button icon="close" custom_classes="hidden-remove-button remove-button tippy-zulip-delayed-tooltip" intent="danger" aria-label=(t "Unsubscribe") data-tippy-content=(t "Unsubscribe") }}
{{/if}}
{{/if}}
+ {{#if show_remove_channel_from_folder}}
+ {{> components/icon_button icon="close" custom_classes="hidden-remove-button remove-button tippy-zulip-delayed-tooltip" intent="danger" aria-label=(t "Remove channel") data-tippy-content=(t "Remove channel") }}
+ {{/if}}
</div>
</a>
</li>
diff --git a/web/templates/stream_settings/edit_channel_folder_modal.hbs b/web/templates/stream_settings/edit_channel_folder_modal.hbs
index d68aeeeda5b..d90c4fcd00f 100644
--- a/web/templates/stream_settings/edit_channel_folder_modal.hbs
+++ b/web/templates/stream_settings/edit_channel_folder_modal.hbs
@@ -1,3 +1,4 @@
+<div id="channel_folder_banner" class="banner-wrapper"></div>
<div>
<label for="edit_channel_folder_name" class="modal-field-label">
{{t 'Channel folder name' }}
@@ -10,3 +11,22 @@
</label>
<textarea id="edit_channel_folder_description" class="modal-textarea" name="channel_folder_description" maxlength="{{ max_channel_folder_description_length }}">{{~description~}}</textarea>
</div>
+<div>
+ <div>
+ <h3 class="folder-channels-list-header">
+ {{t 'Channels' }}
+ </h3>
+ </div>
+ <div class="stream-list-container" data-folder-id="{{folder_id}}">
+ <div class="stream-search-container filter-input has-input-icon has-input-button input-element-wrapper">
+ <i class="input-icon zulip-icon zulip-icon-search" aria-hidden="true"></i>
+ <input type="text" class="input-element stream-search" placeholder="{{t 'Filter' }}" />
+ <button type="button" class="input-button input-close-filter-button icon-button icon-button-square icon-button-neutral ">
+ <i class="zulip-icon zulip-icon-close" aria-hidden="true"></i>
+ </button>
+ </div>
+ <div class="edit-channel-folder-stream-list" data-simplebar data-simplebar-tab-index="-1">
+ <ul class="folder-stream-list" data-empty="{{t 'No channel in channel folder.' }}" data-search-results-empty="{{t 'No matching channels.' }}"></ul>
+ </div>
+ </div>
+</div>
diff --git a/web/tests/channel_folders.test.cjs b/web/tests/channel_folders.test.cjs
index b350751a0fd..e19f3c38805 100644
--- a/web/tests/channel_folders.test.cjs
+++ b/web/tests/channel_folders.test.cjs
@@ -102,6 +102,11 @@ run_test("basics", () => {
name: "Stream 4",
folder_id: frontend_folder.id,
});
+ const stream_5 = make_stream({
+ stream_id: 5,
+ name: "channel 5",
+ folder_id: frontend_folder.id,
+ });
stream_data.add_sub_for_tests(stream_1);
assert.deepEqual(channel_folders.user_has_folders(), false);
@@ -109,16 +114,24 @@ run_test("basics", () => {
stream_data.add_sub_for_tests(stream_2);
stream_data.add_sub_for_tests(stream_3);
stream_data.add_sub_for_tests(stream_4);
+ stream_data.add_sub_for_tests(stream_5);
assert.deepEqual(channel_folders.get_stream_ids_in_folder(frontend_folder.id), [
stream_2.stream_id,
stream_4.stream_id,
+ stream_5.stream_id,
]);
assert.deepEqual(channel_folders.get_stream_ids_in_folder(devops_folder.id), [
stream_3.stream_id,
]);
assert.deepEqual(channel_folders.get_stream_ids_in_folder(backend_folder.id), []);
+ assert.deepEqual(channel_folders.get_sorted_streams_in_folder(frontend_folder.id), [
+ stream_5,
+ stream_2,
+ stream_4,
+ ]);
+
const subscribed_streams = new Set([
stream_1.stream_id,
stream_2.stream_id,