Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
modal: Show channel/group card popover in stream & group list items.
Alya Abbott74da66271b6d
diff --git a/web/src/channel_folders_ui.ts b/web/src/channel_folders_ui.tsindex 187df28b71e..4c75fe07f05 100644--- a/web/src/channel_folders_ui.ts+++ b/web/src/channel_folders_ui.ts@@ -16,7 +16,6 @@ import * as confirm_dialog from "./confirm_dialog.ts";import * as dialog_widget from "./dialog_widget.ts";import * as dropdown_widget from "./dropdown_widget.ts";import type {DropdownWidget, DropdownWidgetOptions} from "./dropdown_widget.ts";-import * as hash_util from "./hash_util.ts";import {$t, $t_html} from "./i18n.ts";import * as ListWidget from "./list_widget.ts";import type {ListWidget as ListWidgetType} from "./list_widget.ts";@@ -201,7 +200,6 @@ function format_channel_item_html(stream: StreamSubscription): string {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"),can_manage_folder: settings_data.can_user_manage_folder(),});}diff --git a/web/src/stream_card_popover.ts b/web/src/stream_card_popover.tsindex 13f2f37e30e..42e403d9d9d 100644--- a/web/src/stream_card_popover.ts+++ b/web/src/stream_card_popover.ts@@ -14,51 +14,54 @@ import * as ui_util from "./ui_util.ts";let stream_id: number | undefined;export function initialize(): void {- popover_menus.register_popover_menu(".pill[data-stream-id]", {- theme: "popover-menu",- placement: "right",- onShow(instance) {- popover_menus.popover_instances.stream_card_popover = instance;- popover_menus.on_show_prep(instance);+ popover_menus.register_popover_menu(+ ".pill[data-stream-id], .view-stream-card[data-stream-id]",+ {+ theme: "popover-menu",+ placement: "right",+ onShow(instance) {+ popover_menus.popover_instances.stream_card_popover = instance;+ popover_menus.on_show_prep(instance);- const $elt = $(instance.reference);- const stream_id_str = $elt.attr("data-stream-id");- assert(stream_id_str !== undefined);- stream_id = Number.parseInt(stream_id_str, 10);- const subscribers_count = peer_data.get_subscriber_count(stream_id);+ const $elt = $(instance.reference);+ const stream_id_str = $elt.attr("data-stream-id");+ assert(stream_id_str !== undefined);+ stream_id = Number.parseInt(stream_id_str, 10);+ const subscribers_count = peer_data.get_subscriber_count(stream_id);- instance.setContent(- ui_util.parse_html(- render_stream_card_popover({- stream: {- ...sub_store.get(stream_id),- },- subscribers_count,- }),- ),- );- },- onMount(instance) {- const $popper = $(instance.popper);+ instance.setContent(+ ui_util.parse_html(+ render_stream_card_popover({+ stream: {+ ...sub_store.get(stream_id),+ },+ subscribers_count,+ }),+ ),+ );+ },+ onMount(instance) {+ const $popper = $(instance.popper);- // Stream settings- $popper.on("click", ".open_stream_settings", () => {- assert(stream_id !== undefined);- const sub = sub_store.get(stream_id);- assert(sub !== undefined);- popover_menus.hide_current_popover_if_visible(instance);- const can_change_stream_permissions =- stream_data.can_change_permissions_requiring_metadata_access(sub);- let stream_edit_hash = hash_util.channels_settings_edit_url(sub, "general");- if (!can_change_stream_permissions) {- stream_edit_hash = hash_util.channels_settings_edit_url(sub, "personal");- }- browser_history.go_to_location(stream_edit_hash);- });- },- onHidden(instance) {- instance.destroy();- popover_menus.popover_instances.stream_card_popover = null;+ // Stream settings+ $popper.on("click", ".open_stream_settings", () => {+ assert(stream_id !== undefined);+ const sub = sub_store.get(stream_id);+ assert(sub !== undefined);+ popover_menus.hide_current_popover_if_visible(instance);+ const can_change_stream_permissions =+ stream_data.can_change_permissions_requiring_metadata_access(sub);+ let stream_edit_hash = hash_util.channels_settings_edit_url(sub, "general");+ if (!can_change_stream_permissions) {+ stream_edit_hash = hash_util.channels_settings_edit_url(sub, "personal");+ }+ browser_history.go_to_location(stream_edit_hash);+ });+ },+ onHidden(instance) {+ instance.destroy();+ popover_menus.popover_instances.stream_card_popover = null;+ },},- });+ );}diff --git a/web/src/user_group_popover.ts b/web/src/user_group_popover.tsindex e5facf699c4..3eb45e0c876 100644--- a/web/src/user_group_popover.ts+++ b/web/src/user_group_popover.ts@@ -198,6 +198,7 @@ export function register_click_handlers(): void {});$("body").on("click", ".view_user_group", function (this: HTMLElement, e) {+ e.preventDefault();e.stopPropagation();toggle_user_group_info_popover(this, undefined);});diff --git a/web/src/user_profile.ts b/web/src/user_profile.tsindex 6214c6c8a13..3c444e5df4f 100644--- a/web/src/user_profile.ts+++ b/web/src/user_profile.ts@@ -309,7 +309,6 @@ function format_user_stream_list_item_html(stream: StreamSubscription, user: Useshow_unsubscribe_button,show_private_stream_unsub_tooltip,show_last_user_in_private_stream_unsub_tooltip,- stream_edit_url: hash_util.channels_settings_edit_url(stream, "general"),});}@@ -332,7 +331,6 @@ function format_user_group_list_item_html(group: UserGroup, user: User): stringreturn render_user_group_list_item({group_id: group.id,name: user_groups.get_display_group_name(group.name),- group_edit_url: hash_util.group_edit_url(group, "general"),is_guest: current_user.is_guest,is_direct_member,subgroups_name: subgroups_name.join(", "),@@ -1684,6 +1682,19 @@ export function initialize(): void {browser_history.go_to_location("#settings/profile");});+ $("body").on(+ "keydown",+ ".stream-list-container .view-stream-card, .group-list-container .view_user_group",+ function (this: HTMLElement, e) {+ if (e.key !== "Enter") {+ return;+ }+ e.preventDefault();+ e.stopPropagation();+ $(this).trigger("click");+ },+ );+bot_helper.initialize_bot_click_handlers();new ClipboardJS(".copy-link-to-user-profile", {diff --git a/web/styles/app_variables.css b/web/styles/app_variables.cssindex d41ec463e07..41a31d0f46e 100644--- a/web/styles/app_variables.css+++ b/web/styles/app_variables.css@@ -1603,10 +1603,6 @@hsl(0deg 0% 97%),hsl(0deg 0% 21%));- --color-outline-user-profile-list-item: light-dark(- hsl(0deg 0% 0%),- hsl(0deg 0% 100%)- );/* Link colors */--color-text-link: light-dark(hsl(210deg 94% 42%), hsl(200deg 100% 50%));diff --git a/web/styles/modal.css b/web/styles/modal.cssindex 66381bac937..8e86ae0c29d 100644--- a/web/styles/modal.css+++ b/web/styles/modal.css@@ -503,18 +503,25 @@.modal-channel-list-row {display: flex;justify-content: space-between;- padding: 0.3125em 0.625em;+ padding-right: 0.625em;align-items: center;text-decoration: none;border-bottom: none;border-radius: 4px;color: var(--color-dropdown-item);- cursor: pointer;.modal-group-list-row-content,.modal-channel-list-row-content {display: flex;overflow: hidden;+ border-radius: 4px;+ padding: 0.3125em 0.5em;+ cursor: pointer;++ &:focus-visible {+ outline: 1px solid var(--color-user-profile-list-item-hover);+ outline-offset: -2px;+ }}.stream-privacy {@@ -526,21 +533,11 @@padding-right: 3px;}- &:hover {- background-color: var(--color-user-profile-list-item-hover);- }-- &:focus-visible {- outline: 1px solid var(--color-outline-user-profile-list-item);- outline-offset: -2px;- }-.user-group-name,.stream-name {white-space: nowrap;overflow: hidden;text-overflow: ellipsis;- padding-right: 2px;}}diff --git a/web/templates/channel_list_item.hbs b/web/templates/channel_list_item.hbsindex 0961550cf25..e1d79c53637 100644--- a/web/templates/channel_list_item.hbs+++ b/web/templates/channel_list_item.hbs@@ -1,6 +1,6 @@<li class="stream-list-item" role="presentation" data-stream-id="{{stream_id}}">- <a class="modal-channel-list-row hidden-remove-button-row" href="{{stream_edit_url}}">- <span class="modal-channel-list-row-content">+ <div class="modal-channel-list-row hidden-remove-button-row">+ <span class="view-stream-card modal-channel-list-row-content" data-stream-id="{{stream_id}}" tabindex="0"><span class="stream-privacy-original-color-{{stream_id}} stream-privacy filter-icon" style="color: {{stream_color}}">{{> stream_privacy . }}</span>@@ -20,5 +20,5 @@{{> 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>+ </div></li>diff --git a/web/templates/user_group_list_item.hbs b/web/templates/user_group_list_item.hbsindex 96b505a5fd9..e18d07a3d98 100644--- a/web/templates/user_group_list_item.hbs+++ b/web/templates/user_group_list_item.hbs@@ -1,6 +1,6 @@<li class="group-list-item" role="presentation" data-group-id="{{group_id}}">- <a class="modal-group-list-row hidden-remove-button-row" href="{{group_edit_url}}">- <span class="modal-group-list-row-content">+ <div class="modal-group-list-row hidden-remove-button-row">+ <span class="view_user_group modal-group-list-row-content" data-user-group-id="{{group_id}}" tabindex="0"><span class="user-group-name">{{name}}</span>@@ -16,5 +16,5 @@{{/if}}</div>{{/if}}- </a>+ </div></li>