Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Move buttons with right panel title in channels and groups UI.
Sahil Batraee183f8da0c7
diff --git a/web/e2e-tests/subscribe_toggle.test.ts b/web/e2e-tests/subscribe_toggle.test.tsindex f9f09978bd0..46887348883 100644--- a/web/e2e-tests/subscribe_toggle.test.ts+++ b/web/e2e-tests/subscribe_toggle.test.ts@@ -13,7 +13,7 @@ async function test_subscription_button(page: Page): Promise<void> {async function subscribed(): Promise<ElementHandle | null> {await page.waitForSelector(- `xpath///*[${common.has_class_x("stream_settings_header")}]//*[${common.has_class_x(+ `xpath///*[${common.has_class_x("stream-info-title")}]//*[${common.has_class_x("sub_unsub_button",)} and normalize-space()="Unsubscribe"]`,);@@ -22,7 +22,7 @@ async function test_subscription_button(page: Page): Promise<void> {async function unsubscribed(): Promise<ElementHandle | null> {await page.waitForSelector(- `xpath///*[${common.has_class_x("stream_settings_header")}]//*[${common.has_class_x(+ `xpath///*[${common.has_class_x("stream-info-title")}]//*[${common.has_class_x("sub_unsub_button",)} and normalize-space()="Subscribe"]`,);diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.tsindex 43762add784..78afbf51c8d 100644--- a/web/src/stream_edit.ts+++ b/web/src/stream_edit.ts@@ -204,7 +204,7 @@ export function get_display_text_for_realm_message_retention_setting(): string {function get_stream_id(target: HTMLElement): number {const $row = $(target).closest(- ".stream-row, .stream_settings_header, .subscription_settings, .save-button",+ ".stream-row, .stream-title-buttons, .subscription_settings, .save-button",);return Number.parseInt($row.attr("data-stream-id")!, 10);}@@ -486,7 +486,6 @@ export function show_settings_for(node: HTMLElement): void {$edit_container.addClass("show");- stream_ui_updates.update_settings_button_for_archive_and_unarchive(sub);show_subscription_settings(sub);settings_org.set_message_retention_setting_dropdown(sub);set_up_channel_privacy_dropdown_widget(undefined, sub);diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.tsindex 6ef66833aac..67aa69b4040 100644--- a/web/src/stream_settings_components.ts+++ b/web/src/stream_settings_components.ts@@ -35,6 +35,30 @@ export let archived_status_filter_dropdown_widget: DropdownWidget;export let channel_creation_privacy_widget: DropdownWidget;let folder_filter_dropdown_widget: DropdownWidget;+function set_visibility_for_archive_and_unarchive_buttons(sub: StreamSubscription): void {+ // This is for the Archive/Unarchive button in the right panel.+ const $archive_button = $(+ `.stream-title-buttons[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .deactivate`,+ );+ const $unarchive_button = $(+ `.stream-title-buttons[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .reactivate`,+ );++ if (!stream_data.can_administer_channel(sub)) {+ $archive_button.hide();+ $unarchive_button.hide();+ return;+ }++ if (sub.is_archived) {+ $archive_button.hide();+ $unarchive_button.show();+ } else {+ $unarchive_button.hide();+ $archive_button.show();+ }+}+export function set_right_panel_title(sub: StreamSubscription): void {let title_icon_color = "#333333";if (settings_data.using_dark_theme()) {@@ -42,9 +66,17 @@ export function set_right_panel_title(sub: StreamSubscription): void {}const preview_url = hash_util.channel_url_by_user_setting(sub.stream_id);+ const settings_sub = stream_settings_data.get_sub_for_settings(sub);$("#subscription_overlay .stream-info-title")- .html(render_selected_stream_title({sub, title_icon_color, preview_url}))+ .html(+ render_selected_stream_title({+ sub: settings_sub,+ title_icon_color,+ preview_url,+ }),+ ).toggleClass("new-channel-members-title", false);+ set_visibility_for_archive_and_unarchive_buttons(sub);}export const show_subs_pane = {diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.tsindex 3d8f90c7aad..ced66906f18 100644--- a/web/src/stream_settings_ui.ts+++ b/web/src/stream_settings_ui.ts@@ -431,7 +431,7 @@ export function update_settings_for_subscribed(slim_sub: StreamSubscription): voconst sub = stream_settings_data.get_sub_for_settings(slim_sub);stream_ui_updates.update_add_subscriptions_elements(sub);$(- `.stream_settings_header[data-stream-id='${CSS.escape(+ `.stream-title-buttons[data-stream-id='${CSS.escape(sub.stream_id.toString(),)}'] #preview-stream-button`,).show();@@ -478,7 +478,6 @@ export function update_settings_for_archived_and_unarchived(slim_sub: StreamSubsconst active_data = stream_settings_components.get_active_data();if (active_data.id === sub.stream_id) {stream_settings_components.set_right_panel_title(sub);- stream_ui_updates.update_settings_button_for_archive_and_unarchive(sub);stream_ui_updates.update_toggler_for_sub(sub);stream_ui_updates.enable_or_disable_permission_settings_in_edit_panel(sub);stream_ui_updates.update_stream_privacy_icon_in_settings(sub);@@ -1427,7 +1426,7 @@ export function initialize(): void {});$("#channels_overlay_container").on("click", "#preview-stream-button", () => {- const stream_id = Number.parseInt($(".stream_settings_header").attr("data-stream-id")!, 10);+ const stream_id = Number.parseInt($(".stream-title-buttons").attr("data-stream-id")!, 10);window.location.href = hash_util.channel_url_by_user_setting(stream_id);});}diff --git a/web/src/stream_ui_updates.ts b/web/src/stream_ui_updates.tsindex 2c0dd22160d..08f37b5b3f9 100644--- a/web/src/stream_ui_updates.ts+++ b/web/src/stream_ui_updates.ts@@ -34,7 +34,7 @@ function settings_button_for_sub(sub: StreamSubscription): JQuery {// We don't do expectOne() here, because this button is only// visible if the user has that stream selected in the streams UI.return $(- `.stream_settings_header[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .subscribe-button`,+ `.stream-title-buttons[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .subscribe-button`,);}@@ -167,7 +167,9 @@ export function update_history_public_to_subscribers_on_can_create_topic_group_c}export function initialize_cant_subscribe_popover(): void {- const $button_wrapper = $(".settings .stream_settings_header .sub_unsub_button_wrapper");+ const $button_wrapper = $(+ "#subscription_overlay .stream-title-buttons .sub_unsub_button_wrapper",+ );settings_components.initialize_disable_button_hint_popover($button_wrapper, undefined);}@@ -253,34 +255,6 @@ export function update_settings_button_for_sub(sub: StreamSubscription): void {}}-export function update_settings_button_for_archive_and_unarchive(sub: StreamSubscription): void {- if (!hash_parser.is_editing_stream(sub.stream_id)) {- return;- }-- // This is for the Archive/Unarchive button in the right panel.- const $archive_button = $(- `.stream_settings_header[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .deactivate`,- );- const $unarchive_button = $(- `.stream_settings_header[data-stream-id='${CSS.escape(sub.stream_id.toString())}'] .reactivate`,- );-- if (!stream_data.can_administer_channel(sub)) {- $archive_button.hide();- $unarchive_button.hide();- return;- }-- if (sub.is_archived) {- $archive_button.hide();- $unarchive_button.show();- } else {- $unarchive_button.hide();- $archive_button.show();- }-}-export function update_channel_email_section(sub: StreamSubscription): void {// These are in the right panel.if (!hash_parser.is_editing_stream(sub.stream_id)) {diff --git a/web/src/user_group_edit.ts b/web/src/user_group_edit.tsindex 62f12ccb9c4..6780a1c9596 100644--- a/web/src/user_group_edit.ts+++ b/web/src/user_group_edit.ts@@ -10,7 +10,6 @@ import render_settings_checkbox from "../templates/settings/settings_checkbox.hbimport render_browse_user_groups_list_item from "../templates/user_group_settings/browse_user_groups_list_item.hbs";import render_cannot_deactivate_group_banner from "../templates/user_group_settings/cannot_deactivate_group_banner.hbs";import render_change_user_group_info_modal from "../templates/user_group_settings/change_user_group_info_modal.hbs";-import render_selected_group_title from "../templates/user_group_settings/selected_group_title.hbs";import render_stream_group_permission_settings from "../templates/user_group_settings/stream_group_permission_settings.hbs";import render_user_group_membership_status from "../templates/user_group_settings/user_group_membership_status.hbs";import render_user_group_permission_settings from "../templates/user_group_settings/user_group_permission_settings.hbs";@@ -103,7 +102,7 @@ const GROUP_INFO_BANNER: Banner = {function get_user_group_id(target: HTMLElement): number {const $row = $(target).closest(- ".group-row, .user_group_settings_wrapper, .save-button, .group_settings_header",+ ".group-row, .user_group_settings_wrapper, .save-button, .selected-group-buttons",);return Number.parseInt($row.attr("data-group-id")!, 10);}@@ -245,27 +244,27 @@ function show_general_settings(group: UserGroup): void {function update_deactivate_and_reactivate_buttons(group: UserGroup): void {if (!settings_data.can_manage_user_group(group.id)) {$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,).hide();$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,).hide();return;}if (group.deactivated) {$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,).hide();$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,).show();} else {$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .deactivate`,).show();$(- `.group_settings_header[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group.id.toString())}'] .reactivate`,).hide();}}@@ -313,7 +312,7 @@ export function update_group_management_ui(): void {function group_membership_button(group_id: number): JQuery {return $(- `.group_settings_header[data-group-id='${CSS.escape(group_id.toString())}'] .join_leave_button`,+ `.selected-group-buttons[data-group-id='${CSS.escape(group_id.toString())}'] .join_leave_button`,);}@@ -1549,9 +1548,10 @@ export function update_group(event: UserGroupUpdateEvent, group: UserGroup): voiupdate_group_details(group);if (event.data.name !== undefined) {// update settings title- $("#groups_overlay .user-group-info-title").html(- render_selected_group_title({group_name: group.name}),- );+ user_group_components.set_right_panel_title(group);+ // We call this to make sure that correct button is shown+ // after re-rendering of the title template.+ update_deactivate_and_reactivate_buttons(group);}if (changed_group_settings.length > 0) {@@ -2026,7 +2026,7 @@ export function initialize(): void {$("#groups_overlay_container").on("click",- ".group_settings_header .deactivate-group-button",+ ".user-group-info-title .deactivate-group-button",() => {const active_group_data = get_active_data();const group_id = active_group_data.id;@@ -2134,7 +2134,7 @@ export function initialize(): void {$("#groups_overlay_container").on("click",- ".group_settings_header .reactivate-group-button",+ ".user-group-info-title .reactivate-group-button",function (this: HTMLElement) {const active_group_data = get_active_data();const group_id = active_group_data.id;diff --git a/web/styles/subscriptions.css b/web/styles/subscriptions.cssindex ecdc295b0ca..915989b7218 100644--- a/web/styles/subscriptions.css+++ b/web/styles/subscriptions.css@@ -439,6 +439,7 @@ h4.user_group_setting_subsection_title {font-weight: 600;padding: 10px;overflow: hidden;+ width: 100%;& a {color: inherit;@@ -457,20 +458,79 @@ h4.user_group_setting_subsection_title {content: "Preferences";}- .stream-info-title,+ .stream-info-title {+ display: flex;+ justify-content: center;+ }+.user-group-info-title {display: block;+ text-align: center;+ text-overflow: ellipsis;+ white-space: nowrap;+ margin-left: 5px;+ }++ .stream-info-title,+ .user-group-info-title {font-size: 1.5em; /* 21px at 14px/em */line-height: 1.25;font-weight: 600;overflow-wrap: break-word;overflow: hidden;+ width: 100%;&.new-channel-members-title {line-clamp: 2;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;+ width: unset;+ }++ .selected-group-title,+ .selected-stream-title {+ display: flex;+ width: 100%;+ justify-content: space-between;++ .selected-stream,+ .selected-group-name {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .button-group {+ height: 1.25em;+ display: flex;++ .subscribe-button,+ .join_leave_button,+ #preview-stream-button {+ height: 100%;+ margin-left: 3px;+ }++ .icon-button {+ /* Equal to to font sizes for other icon buttons+ in the channel and group settings UI. */+ font-size: calc(1.2 * var(--base-font-size-px));+ }+ }++ .selected-group {+ display: flex;+ align-items: center;+ overflow: hidden;+ }++ .deactivated-user-group-icon-right {+ margin-right: 5px;+ margin-left: 3px;+ opacity: 0.6;+ font-size: var(--base-font-size-px);+ }}.large-icon {@@ -482,35 +542,6 @@ h4.user_group_setting_subsection_title {}}}-- .selected-group {- display: flex;- align-items: center;- }-- .selected-stream-title,- .selected-group-name,- .user-group-info-title {- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }-- .selected-stream-title {- display: block;- margin: auto;- }-- .user-group-info-title {- margin-left: 5px;- }-- .deactivated-user-group-icon-right {- margin-right: 5px;- margin-left: 3px;- opacity: 0.6;- font-size: var(--base-font-size-px);- }}}@@ -1134,21 +1165,6 @@ h4.user_group_setting_subsection_title {display: flex;}}-- .button-group {- padding-top: 5px;- margin-left: auto;- margin-right: 18px;- height: var(--settings-overlay-header-button-height);- display: flex;-- .subscribe-button,- .join_leave_button,- #preview-stream-button {- height: 100%;- margin-left: 3px;- }- }}.group-header,diff --git a/web/templates/stream_settings/selected_stream_title.hbs b/web/templates/stream_settings/selected_stream_title.hbsindex 8201da10ff2..7e7f1bc2508 100644--- a/web/templates/stream_settings/selected_stream_title.hbs+++ b/web/templates/stream_settings/selected_stream_title.hbs@@ -1,8 +1,52 @@-<a {{#if preview_url}}class="tippy-zulip-delayed-tooltip selected-stream-title" data-tooltip-template-id="view-stream-tooltip-template" data-tippy-placement="top" href="{{preview_url}}"{{/if}}>-{{#unless preview_url}}{{t "Add subscribers to "}}{{/unless}}-{{> stream_privacy_icon- invite_only=sub.invite_only- is_web_public=sub.is_web_public- is_archived=sub.is_archived }}-<span class="stream-name-title">{{sub.name}}</span>-</a>+<div class="selected-stream-title">+ <a {{#if preview_url}}class="tippy-zulip-delayed-tooltip selected-stream" data-tooltip-template-id="view-stream-tooltip-template" data-tippy-placement="top" href="{{preview_url}}"{{/if}}>+ {{#unless preview_url}}{{t "Add subscribers to "}}{{/unless}}+ {{> stream_privacy_icon+ invite_only=sub.invite_only+ is_web_public=sub.is_web_public+ is_archived=sub.is_archived }}+ <span class="stream-name-title">{{sub.name}}</span>+ </a>+ {{#with sub}}+ <div class="button-group stream-title-buttons" data-stream-id="{{stream_id}}">+ <div class="sub_unsub_button_wrapper inline-block {{#unless should_display_subscription_button }}cannot-subscribe-tooltip{{/unless}}" data-tooltip-template-id="cannot-subscribe-tooltip-template">+ <template id="cannot-subscribe-tooltip-template">+ <span>+ {{#tr}}+ Cannot subscribe to private channel <z-stream></z-stream>+ {{#*inline "z-stream"}}{{> ../inline_decorated_channel_name stream=sub}}{{/inline}}+ {{/tr}}+ </span>+ </template>+ <button class="action-button subscribe-button sub_unsub_button {{#if subscribed}}action-button-subtle-neutral{{else}}action-button-subtle-brand{{/if}} {{#if should_display_subscription_button}}toggle-subscription-tooltip{{/if}} {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" data-tooltip-template-id="toggle-subscription-tooltip-template" {{#unless should_display_subscription_button}}disabled="disabled"{{/unless}}>+ {{#if subscribed }}+ {{t "Unsubscribe" }}+ {{else}}+ {{t "Subscribe" }}+ {{/if}}+ </button>+ </div>+ {{> ../components/action_button+ icon="eye"+ variant="subtle"+ intent="neutral"+ custom_classes="tippy-zulip-delayed-tooltip"+ data-tooltip-template-id="view-stream-tooltip-template"+ id="preview-stream-button"+ hidden=(not should_display_preview_button)+ }}+ {{> ../components/icon_button+ icon="archive"+ intent="danger"+ custom_classes="tippy-zulip-delayed-tooltip deactivate"+ data-tippy-content=(t 'Archive channel')+ }}+ {{> ../components/icon_button+ icon="unarchive"+ intent="success"+ custom_classes="tippy-zulip-delayed-tooltip reactivate"+ data-tippy-content=(t 'Unarchive channel')+ }}+ </div>+ {{/with}}+</div>diff --git a/web/templates/stream_settings/stream_settings.hbs b/web/templates/stream_settings/stream_settings.hbsindex 31a967d86a0..7d2861417a1 100644--- a/web/templates/stream_settings/stream_settings.hbs+++ b/web/templates/stream_settings/stream_settings.hbs@@ -1,47 +1,5 @@<div class="stream_settings_header" data-stream-id="{{sub.stream_id}}"><div class="tab-container"></div>- {{#with sub}}- <div class="button-group">- <div class="sub_unsub_button_wrapper inline-block {{#unless should_display_subscription_button }}cannot-subscribe-tooltip{{/unless}}" data-tooltip-template-id="cannot-subscribe-tooltip-template">- <template id="cannot-subscribe-tooltip-template">- <span>- {{#tr}}- Cannot subscribe to private channel <z-stream></z-stream>- {{#*inline "z-stream"}}{{> ../inline_decorated_channel_name stream=../sub}}{{/inline}}- {{/tr}}- </span>- </template>- <button class="action-button subscribe-button sub_unsub_button {{#if subscribed}}action-button-subtle-neutral{{else}}action-button-subtle-brand{{/if}} {{#if should_display_subscription_button}}toggle-subscription-tooltip{{/if}} {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" data-tooltip-template-id="toggle-subscription-tooltip-template" {{#unless should_display_subscription_button}}disabled="disabled"{{/unless}}>- {{#if subscribed }}- {{t "Unsubscribe" }}- {{else}}- {{t "Subscribe" }}- {{/if}}- </button>- </div>- {{> ../components/action_button- icon="eye"- variant="subtle"- intent="neutral"- custom_classes="tippy-zulip-delayed-tooltip"- data-tooltip-template-id="view-stream-tooltip-template"- id="preview-stream-button"- hidden=(not should_display_preview_button)- }}- {{> ../components/icon_button- icon="archive"- intent="danger"- custom_classes="tippy-zulip-delayed-tooltip deactivate"- data-tippy-content=(t 'Archive channel')- }}- {{> ../components/icon_button- icon="unarchive"- intent="success"- custom_classes="tippy-zulip-delayed-tooltip reactivate"- data-tippy-content=(t 'Unarchive channel')- }}- </div>- {{/with}}</div><div class="subscription_settings" data-stream-id="{{sub.stream_id}}"><div class="inner-box">diff --git a/web/templates/user_group_settings/selected_group_title.hbs b/web/templates/user_group_settings/selected_group_title.hbsindex 107058a0de2..60f81478464 100644--- a/web/templates/user_group_settings/selected_group_title.hbs+++ b/web/templates/user_group_settings/selected_group_title.hbs@@ -3,4 +3,19 @@<span class="selected-group-name">{{group_name}}</span><i class="fa fa-ban deactivated-user-icon deactivated-user-group-icon-right"></i></div>+ <div class="button-group selected-group-buttons" data-group-id="{{group_id}}">+ <div class="join_leave_button_wrapper inline-block">+ {{#if is_direct_member}}+ {{> ../components/action_button label=(t "Leave group") custom_classes="join_leave_button" type="button"+ variant="subtle" intent="neutral" }}+ {{else}}+ {{> ../components/action_button label=(t "Join group") custom_classes="join_leave_button" type="button"+ variant="subtle" intent="brand" }}+ {{/if}}+ </div>+ {{> ../components/icon_button icon="user-group-x" intent="danger" custom_classes="deactivate-group-button deactivate tippy-zulip-delayed-tooltip"+ data-tippy-content=(t 'Deactivate group') }}+ {{> ../components/icon_button icon="user-group-plus" intent="success" custom_classes="reactivate-group-button reactivate tippy-zulip-delayed-tooltip"+ data-tippy-content=(t 'Reactivate group') }}+ </div></div>diff --git a/web/templates/user_group_settings/user_group_settings.hbs b/web/templates/user_group_settings/user_group_settings.hbsindex 5b1e16a915e..3d5044a4b99 100644--- a/web/templates/user_group_settings/user_group_settings.hbs+++ b/web/templates/user_group_settings/user_group_settings.hbs@@ -1,20 +1,5 @@-<div class="group_settings_header" data-group-id="{{group.id}}">+<div class="group_settings_header"><div class="tab-container"></div>- <div class="button-group">- <div class="join_leave_button_wrapper inline-block">- {{#if is_direct_member}}- {{> ../components/action_button label=(t "Leave group") custom_classes="join_leave_button" type="button"- variant="subtle" intent="neutral" }}- {{else}}- {{> ../components/action_button label=(t "Join group") custom_classes="join_leave_button" type="button"- variant="subtle" intent="brand" }}- {{/if}}- </div>- {{> ../components/icon_button icon="user-group-x" intent="danger" custom_classes="deactivate-group-button deactivate tippy-zulip-delayed-tooltip"- data-tippy-content=(t 'Deactivate group') }}- {{> ../components/icon_button icon="user-group-plus" intent="success" custom_classes="reactivate-group-button reactivate tippy-zulip-delayed-tooltip"- data-tippy-content=(t 'Reactivate group') }}- </div></div><div class="user_group_settings_wrapper" data-group-id="{{group.id}}"><div class="inner-box">