Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Hover menu for all chat channels in sidebar (#34727)

Martin Brennanfc98ce9a7232
diff --git a/app/assets/stylesheets/common/base/sidebar-section-link.scss b/app/assets/stylesheets/common/base/sidebar-section-link.scss
index d656b8af112..bb5725df63c 100644
--- a/app/assets/stylesheets/common/base/sidebar-section-link.scss
+++ b/app/assets/stylesheets/common/base/sidebar-section-link.scss
@@ -18,12 +18,24 @@
font-size: var(--font-down-1-rem);
}
+ &.--hovering .sidebar-section-link {
+ background: var(--d-sidebar-highlight-background);
+ color: var(--d-sidebar-highlight-color);
+
+ .prefix-text {
+ background: var(--d-sidebar-highlight-prefix-background);
+ }
+
+ .sidebar-section-link-suffix.icon.unread svg {
+ color: var(--d-sidebar-highlight-suffix-color);
+ }
+ }
+
.sidebar-section-link {
display: inline-flex;
width: 100%;
align-items: center;
color: var(--d-sidebar-link-color);
- transition: background-color 0.25s;
border-radius: var(--d-border-radius);
&:focus-visible,
@@ -267,9 +279,8 @@
color: var(--d-sidebar-highlight-color);
border: none;
background: transparent;
- padding: 0 0 0 0.5em;
+ padding: 0 0.5em;
height: 100%;
- transition: background-color 0.25s;
&:focus,
.discourse-no-touch & {
@@ -282,17 +293,10 @@
font-size: var(--font-down-1);
}
}
-
- &:hover {
- .sidebar-section-hover-button {
- background: var(--d-sidebar-highlight-background);
- }
- }
}
- &:hover {
- .sidebar-section-hover-button {
- display: block;
- }
+ &.--hovering .sidebar-section-hover-button {
+ display: block;
+ background: var(--d-sidebar-highlight-background);
}
}
diff --git a/app/assets/stylesheets/common/components/buttons.scss b/app/assets/stylesheets/common/components/buttons.scss
index 827b1465300..784fb0a459a 100644
--- a/app/assets/stylesheets/common/components/buttons.scss
+++ b/app/assets/stylesheets/common/components/buttons.scss
@@ -196,6 +196,14 @@
padding: $vpad $hpad;
cursor: pointer;
line-height: normal;
+
+ .d-button__suffix-icon {
+ margin-left: auto;
+
+ .d-icon {
+ margin-right: 0;
+ }
+ }
}
/* link button */
diff --git a/frontend/discourse/app/components/d-button.gjs b/frontend/discourse/app/components/d-button.gjs
index 80ae23bfdc0..96e80f44d87 100644
--- a/frontend/discourse/app/components/d-button.gjs
+++ b/frontend/discourse/app/components/d-button.gjs
@@ -214,6 +214,12 @@ export default class DButton extends Component {
{{~/if~}}
{{yield}}
+
+ {{#if @suffixIcon}}
+ <span class="d-button__suffix-icon">
+ {{~icon @suffixIcon~}}
+ </span>
+ {{/if}}
</this.wrapperElement>
</template>
}
diff --git a/frontend/discourse/app/components/sidebar/section-link.gjs b/frontend/discourse/app/components/sidebar/section-link.gjs
index 8000f585e77..4186d92844d 100644
--- a/frontend/discourse/app/components/sidebar/section-link.gjs
+++ b/frontend/discourse/app/components/sidebar/section-link.gjs
@@ -1,6 +1,8 @@
import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
import { hash } from "@ember/helper";
import { on } from "@ember/modifier";
+import { action } from "@ember/object";
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import { LinkTo } from "@ember/routing";
@@ -40,6 +42,9 @@ export function isHex(input) {
export default class SectionLink extends Component {
@service currentUser;
+ @tracked hovering = false;
+ @tracked hoverActionActive = false;
+
constructor() {
super(...arguments);
this.args.didInsert?.();
@@ -58,6 +63,16 @@ export default class SectionLink extends Component {
return this.args.shouldDisplay;
}
+ get wrapperClass() {
+ let classNames = ["sidebar-section-link-wrapper"];
+
+ if (this.hovering || this.hoverActionActive) {
+ classNames.push("--hovering");
+ }
+
+ return classNames.join(" ");
+ }
+
get linkClass() {
let classNames = ["sidebar-section-link", "sidebar-row"];
@@ -126,6 +141,31 @@ export default class SectionLink extends Component {
}
}
+ @action
+ hoveringSectionLink() {
+ if (this.hoverActionActive) {
+ return;
+ }
+ this.hovering = true;
+ }
+
+ @action
+ stopHoveringSectionLink() {
+ if (this.hoverActionActive) {
+ return;
+ }
+ this.hovering = false;
+ }
+
+ @action
+ runHoverAction(event) {
+ this.hoverActionActive = true;
+ this.args.hoverAction(event, () => {
+ this.hoverActionActive = false;
+ this.hovering = false;
+ });
+ }
+
@bind
maybeScrollIntoView(element) {
if (!this.args.scrollIntoView) {
@@ -150,8 +190,10 @@ export default class SectionLink extends Component {
<li
{{didInsert this.maybeScrollIntoView}}
{{didUpdate this.maybeScrollIntoView @scrollIntoView}}
+ {{on "mouseenter" this.hoveringSectionLink}}
+ {{on "mouseleave" this.stopHoveringSectionLink}}
data-list-item-name={{@linkName}}
- class="sidebar-section-link-wrapper"
+ class={{this.wrapperClass}}
...attributes
>
{{#if @href}}
@@ -230,7 +272,7 @@ export default class SectionLink extends Component {
{{#if @hoverValue}}
<span class="sidebar-section-link-hover">
<button
- {{on "click" @hoverAction}}
+ {{on "click" this.runHoverAction}}
type="button"
title={{@hoverTitle}}
class="sidebar-section-hover-button"
diff --git a/frontend/discourse/tests/integration/components/d-button-test.gjs b/frontend/discourse/tests/integration/components/d-button-test.gjs
index cd29d9fbf5e..d3b91f93936 100644
--- a/frontend/discourse/tests/integration/components/d-button-test.gjs
+++ b/frontend/discourse/tests/integration/components/d-button-test.gjs
@@ -250,4 +250,19 @@ module("Integration | Component | d-button", function (hooks) {
assert.dom(".d-button-label").hasText("test label…");
});
+
+ test("suffix icon", async function (assert) {
+ await render(
+ <template>
+ <DButton @translatedLabel="Open menu" @suffixIcon="angle-right" />
+ </template>
+ );
+
+ assert
+ .dom("button .d-button__suffix-icon")
+ .exists("has the suffix icon wrapper");
+ assert
+ .dom("button .d-button__suffix-icon .d-icon-angle-right")
+ .exists("has the suffix icon");
+ });
});
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs
new file mode 100644
index 00000000000..5ca992600ad
--- /dev/null
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-menu.gjs
@@ -0,0 +1,165 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import DButton from "discourse/components/d-button";
+import DropdownMenu from "discourse/components/dropdown-menu";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import ChatChannelSidebarContextNotificationSubmenu from "./chat-channel-sidebar-context-notification-submenu";
+
+export default class ChatChannelSidebarContextMenu extends Component {
+ @service chatApi;
+ @service chat;
+ @service menu;
+ @service router;
+ @service chatChannelsManager;
+ @service currentUser;
+
+ @tracked isTogglingStarred;
+
+ get channel() {
+ return this.args.data.channel;
+ }
+
+ get currentUserMembership() {
+ return this.channel?.currentUserMembership;
+ }
+
+ get starIcon() {
+ return this.currentUserMembership?.starred ? "star" : "far-star";
+ }
+
+ get starLabel() {
+ return this.currentUserMembership?.starred
+ ? "chat.channel_settings.unstar_channel"
+ : "chat.channel_settings.star_channel";
+ }
+
+ get isGroupChannel() {
+ return !!this.channel?.chatable?.group;
+ }
+
+ @action
+ async toggleStarred() {
+ if (!this.currentUserMembership || this.isTogglingStarred) {
+ return;
+ }
+
+ this.isTogglingStarred = true;
+ const previousValue = this.currentUserMembership.starred;
+ const newValue = !previousValue;
+
+ this.currentUserMembership.starred = newValue;
+
+ try {
+ await this.chatApi.updateCurrentUserChannelMembership(this.channel.id, {
+ starred: newValue,
+ });
+ this.args.close();
+ } catch (err) {
+ this.currentUserMembership.starred = previousValue;
+ popupAjaxError(err);
+ } finally {
+ this.isTogglingStarred = false;
+ }
+ }
+
+ @action
+ async leaveChannel() {
+ try {
+ if (this.isGroupChannel) {
+ await this.chatApi.leaveChannel(this.channel.id);
+ } else {
+ await this.chat.unfollowChannel(this.channel);
+ }
+ this.currentUser.custom_fields.last_chat_channel_id = null;
+
+ this.args.close();
+ this.chatChannelsManager.remove(this.channel);
+
+ if (this.chatChannelsManager.publicMessageChannels.length) {
+ return this.router.transitionTo(
+ "chat.channel",
+ ...this.chatChannelsManager.publicMessageChannels[0].routeModels
+ );
+ } else if (this.chatChannelsManager.directMessageChannels.length) {
+ return this.router.transitionTo(
+ "chat.channel",
+ ...this.chatChannelsManager.directMessageChannels[0].routeModels
+ );
+ } else {
+ return this.router.transitionTo("chat.browse");
+ }
+ } catch (err) {
+ popupAjaxError(err);
+ }
+ }
+
+ @action
+ async navigateToSettings() {
+ try {
+ await this.router.transitionTo(
+ "chat.channel.info.settings",
+ ...this.channel.routeModels
+ );
+ } finally {
+ this.args.close();
+ }
+ }
+
+ @action
+ openNotificationSettings(_actionParam, event) {
+ this.menu.show(event.target, {
+ identifier: "chat-channel-menu-notification-submenu",
+ component: ChatChannelSidebarContextNotificationSubmenu,
+ modalForMobile: true,
+ placement: "right-start",
+ data: { channel: this.channel },
+ onClose: () => this.args.close(),
+ });
+ }
+
+ <template>
+ <DropdownMenu class="chat-channel-sidebar-link-menu" as |dropdown|>
+ <dropdown.item>
+ <DButton
+ @action={{this.openNotificationSettings}}
+ @forwardEvent={{true}}
+ @icon="bell"
+ @suffixIcon="angle-right"
+ @label="chat.channel_settings.notification_settings_context"
+ @title="chat.channel_settings.notification_settings_context"
+ class="chat-channel-sidebar-link-menu__open-notification-settings"
+ />
+ </dropdown.item>
+ <dropdown.item>
+ <DButton
+ @action={{this.navigateToSettings}}
+ @icon="gear"
+ @label="chat.channel_settings.title"
+ @title="chat.channel_settings.title"
+ class="chat-channel-sidebar-link-menu__channel-settings"
+ />
+ </dropdown.item>
+ <dropdown.item>
+ <DButton
+ @action={{this.toggleStarred}}
+ @disabled={{this.isTogglingStarred}}
+ @icon={{this.starIcon}}
+ @label={{this.starLabel}}
+ @title={{this.starLabel}}
+ class="chat-channel-sidebar-link-menu__star-channel"
+ />
+ </dropdown.item>
+ <dropdown.item>
+ <DButton
+ @action={{this.leaveChannel}}
+ @icon="xmark"
+ @label="chat.channel_settings.leave_channel"
+ @title="chat.channel_settings.leave_channel"
+ class="chat-channel-sidebar-link-menu__leave-channel btn-danger"
+ />
+ </dropdown.item>
+ </DropdownMenu>
+ </template>
+}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-notification-submenu.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-notification-submenu.gjs
new file mode 100644
index 00000000000..35d054c75ec
--- /dev/null
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-sidebar-context-notification-submenu.gjs
@@ -0,0 +1,126 @@
+import Component from "@glimmer/component";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import DButton from "discourse/components/d-button";
+import DropdownMenu from "discourse/components/dropdown-menu";
+import concatClass from "discourse/helpers/concat-class";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+
+export default class ChatChannelSidebarContextNotificationSubmenu extends Component {
+ @service chatApi;
+
+ get channel() {
+ return this.args.data.channel;
+ }
+
+ @action
+ isItemSelected(item) {
+ if (this.channel.currentUserMembership.muted) {
+ return item === "muted";
+ }
+
+ return this.channel.currentUserMembership.notificationLevel === item;
+ }
+
+ @action
+ async changePushNotifications(setting) {
+ try {
+ const result =
+ await this.chatApi.updateCurrentUserChannelNotificationsSettings(
+ this.channel.id,
+ {
+ notification_level: setting,
+ }
+ );
+ this.channel.currentUserMembership.notificationLevel =
+ result.membership.notification_level;
+ } catch (err) {
+ popupAjaxError(err);
+ }
+ this.args.close();
+ }
+
+ @action
+ async toggleMuteChannel() {
+ try {
+ const result =
+ await this.chatApi.updateCurrentUserChannelNotificationsSettings(
+ this.channel.id,
+ {
+ muted: !this.channel.currentUserMembership.muted,
+ }
+ );
+ this.channel.currentUserMembership.muted = result.membership.muted;
+ } catch (err) {
+ popupAjaxError(err);
+ }
+ this.args.close();
+ }
+
+ <template>
+ <DropdownMenu as |dropdown|>
+ <dropdown.item>
+ <DButton
+ @action={{this.changePushNotifications "never"}}
+ @label="chat.notification_levels.never"
+ @title="chat.notification_levels.never"
+ class={{concatClass
+ "chat-channel-sidebar-link-menu__notification-level-never"
+ (if (this.isItemSelected "never") "-selected")
+ }}
+ />
+ </dropdown.item>
+
+ <dropdown.item>
+ <DButton
+ @action={{this.changePushNotifications "mention"}}
+ @label="chat.notification_levels.mention"
+ @title="chat.notification_levels.mention"
+ class={{concatClass
+ "chat-channel-sidebar-link-menu__notification-level-mention"
+ (if (this.isItemSelected "mention") "-selected")
+ }}
+ />
+ </dropdown.item>
+
+ <dropdown.item>
+ <DButton
+ @action={{this.changePushNotifications "always"}}
+ @label="chat.notification_levels.always"
+ @title="chat.notification_levels.always"
+ class={{concatClass
+ "chat-channel-sidebar-link-menu__notification-level-always"
+ (if (this.isItemSelected "always") "-selected")
+ }}
+ />
+ </dropdown.item>
+
+ <dropdown.divider />
+
+ <dropdown.item>
+ <DButton
+ @action={{this.toggleMuteChannel}}
+ @icon={{if
+ this.channel.currentUserMembership.muted
+ "bell-slash"
+ "bell"
+ }}
+ @label={{if
+ this.channel.currentUserMembership.muted
+ "chat.settings.unmute"
+ "chat.settings.mute"
+ }}
+ @title={{if
+ this.channel.currentUserMembership.muted
+ "chat.settings.unmute"
+ "chat.settings.mute"
+ }}
+ class={{concatClass
+ "chat-channel-sidebar-link-menu__mute-channel"
+ (if (this.isItemSelected "muted") "-selected")
+ }}
+ />
+ </dropdown.item>
+ </DropdownMenu>
+ </template>
+}
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
index 57a1d7d068c..b80ac447205 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
@@ -11,6 +11,7 @@ import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
import { i18n } from "discourse-i18n";
import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";
+import ChatChannelSidebarContextMenu from "discourse/plugins/chat/discourse/components/chat-channel-sidebar-context-menu";
import ChatSidebarIndicators from "discourse/plugins/chat/discourse/components/chat-sidebar-indicators";
import {
CHAT_PANEL,
@@ -386,7 +387,7 @@ export default {
api.addSidebarSection(
(BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => {
- const SidebarChatStarredChannelLink = createChannelLink(
+ const BaseStarredChannelLink = createChannelLink(
BaseCustomSidebarSectionLink,
{
showSuffix: false,
@@ -394,6 +395,38 @@ export default {
}
);
+ const SidebarChatStarredChannelLink = class extends BaseStarredChannelLink {
+ constructor({ menuService }) {
+ super(...arguments);
+ this.menuService = menuService;
+ }
+
+ get hoverValue() {
+ return "ellipsis";
+ }
+
+ get hoverTitle() {
+ return i18n("chat.open_channel_menu");
+ }
+
+ get hoverAction() {
+ return (event, onMenuClose) => {
+ event.stopPropagation();
+ event.preventDefault();
+
+ this.menuService.show(event.target, {
+ identifier: this.isDM
+ ? "chat-direct-message-channel-menu"
+ : "chat-channel-menu",
+ component: ChatChannelSidebarContextMenu,
+ placement: "right",
+ data: { channel: this.channel },
+ onClose: onMenuClose,
+ });
+ };
+ }
+ };
+
const SidebarChatStarredChannelsSection = class extends BaseCustomSidebarSection {
@service currentUser;
@service chatStateManager;
@@ -409,6 +442,7 @@ export default {
this.chatChannelsManager = container.lookup(
"service:chat-channels-manager"
);
+ this.menuService = container.lookup("service:menu");
}
get sectionLinks() {
@@ -420,6 +454,7 @@ export default {
currentUser: this.currentUser,
siteSettings: this.siteSettings,
chatStateManager: this.chatStateManager,
+ menuService: this.menuService,
})
);
}
@@ -457,10 +492,15 @@ export default {
api.addSidebarSection(
(BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => {
const SidebarChatChannelsSectionLink = class extends BaseCustomSidebarSectionLink {
- constructor({ channel, chatService, siteSettings }) {
+ hoverType = "icon";
+ hoverValue = "ellipsis";
+ hoverTitle = i18n("chat.open_channel_menu");
+
+ constructor({ channel, chatService, siteSettings, menuService }) {
super(...arguments);
this.channel = channel;
this.chatService = chatService;
+ this.menuService = menuService;
this.chatStateManager = chatStateManager;
this.siteSettings = siteSettings;
}
@@ -542,6 +582,21 @@ export default {
isDirectMessageChannel: false,
};
}
+
+ get hoverAction() {
+ return (event, onMenuClose) => {
+ event.stopPropagation();
+ event.preventDefault();
+
+ this.menuService.show(event.target, {
+ identifier: "chat-channel-menu",
+ component: ChatChannelSidebarContextMenu,
+ placement: "right",
+ data: { channel: this.channel },
+ onClose: onMenuClose,
+ });
+ };
+ }
};
const SidebarChatChannelsSection = class extends BaseCustomSidebarSection {
@@ -566,6 +621,7 @@ export default {
"service:chat-channels-manager"
);
this.router = container.lookup("service:router");
+ this.menuService = container.lookup("service:menu");
}
get sectionLinks() {
@@ -574,6 +630,7 @@ export default {
new SidebarChatChannelsSectionLink({
channel,
chatService: this.chatService,
+ menuService: this.menuService,
siteSettings: this.siteSettings,
})
);
@@ -640,16 +697,23 @@ export default {
route = "chat.channel";
suffixType = "icon";
hoverType = "icon";
- hoverValue = "xmark";
- hoverTitle = i18n("chat.direct_messages.close");
-
- constructor({ channel, chatService, currentUser, siteSettings }) {
+ hoverValue = "ellipsis";
+ hoverTitle = i18n("chat.open_channel_menu");
+
+ constructor({
+ channel,
+ chatService,
+ currentUser,
+ menuService,
+ siteSettings,
+ }) {
super(...arguments);
this.channel = channel;
this.chatService = chatService;
this.siteSettings = siteSettings;
this.currentUser = currentUser;
this.chatStateManager = chatStateManager;
+ this.menuService = menuService;
if (this.oneOnOneMessage) {
const user = this.channel.chatable.users[0];
@@ -784,10 +848,17 @@ export default {
}
get hoverAction() {
- return (event) => {
+ return (event, onMenuClose) => {
event.stopPropagation();
event.preventDefault();
- this.chatService.unfollowChannel(this.channel);
+
+ this.menuService.show(event.target, {
+ identifier: "chat-direct-message-channel-menu",
+ component: ChatChannelSidebarContextMenu,
+ placement: "right",
+ data: { channel: this.channel },
+ onClose: onMenuClose,
+ });
};
}
};
@@ -811,6 +882,7 @@ export default {
this.chatChannelsManager = container.lookup(
"service:chat-channels-manager"
);
+ this.menuService = container.lookup("service:menu");
}
get hideSectionHeader() {
@@ -832,6 +904,7 @@ export default {
channel,
chatService: this.chatService,
currentUser: this.currentUser,
+ menuService: this.menuService,
siteSettings: this.siteSettings,
})
);
@@ -882,7 +955,7 @@ export default {
return SidebarChatDirectMessagesSection;
},
- "chat"
+ CHAT_PANEL
);
}
});
diff --git a/plugins/chat/assets/stylesheets/common/chat-sidebar.scss b/plugins/chat/assets/stylesheets/common/chat-sidebar.scss
new file mode 100644
index 00000000000..8fb0aa6654d
--- /dev/null
+++ b/plugins/chat/assets/stylesheets/common/chat-sidebar.scss
@@ -0,0 +1,7 @@
+.chat-channel-sidebar-link-menu {
+ .btn {
+ > * {
+ pointer-events: none;
+ }
+ }
+}
diff --git a/plugins/chat/assets/stylesheets/common/index.scss b/plugins/chat/assets/stylesheets/common/index.scss
index b5f9e714f87..b760a963508 100644
--- a/plugins/chat/assets/stylesheets/common/index.scss
+++ b/plugins/chat/assets/stylesheets/common/index.scss
@@ -3,6 +3,7 @@
@import "base-common";
@import "chat-drawer-routes";
@import "chat-browse";
+@import "chat-sidebar";
@import "chat-channel";
@import "chat-channel-card";
@import "chat-channel-icon";
diff --git a/plugins/chat/assets/stylesheets/desktop/chat-channel-sidebar-menu.scss b/plugins/chat/assets/stylesheets/desktop/chat-channel-sidebar-menu.scss
new file mode 100644
index 00000000000..46b95729945
--- /dev/null
+++ b/plugins/chat/assets/stylesheets/desktop/chat-channel-sidebar-menu.scss
@@ -0,0 +1,11 @@
+.fk-d-menu[data-identifier="chat-channel-menu"],
+.fk-d-menu[data-identifier="chat-channel-menu-notification-submenu"],
+.fk-d-menu[data-identifier="chat-direct-message-channel-menu"] {
+ .dropdown-menu__item {
+ &:hover {
+ button {
+ background: var(--d-sidebar-highlight-background);
+ }
+ }
+ }
+}
diff --git a/plugins/chat/assets/stylesheets/desktop/index.scss b/plugins/chat/assets/stylesheets/desktop/index.scss
index 7ae411ba1b0..c45290e21fc 100644
--- a/plugins/chat/assets/stylesheets/desktop/index.scss
+++ b/plugins/chat/assets/stylesheets/desktop/index.scss
@@ -3,6 +3,7 @@
@import "chat-index-drawer";
@import "chat-index-full-page";
@import "chat-channel";
+@import "chat-channel-sidebar-menu";
@import "chat-message-actions";
@import "chat-message";
@import "chat-channel-info";
diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.yml
index 721331fe2f5..53dd46146b4 100644
--- a/plugins/chat/config/locales/client.en.yml
+++ b/plugins/chat/config/locales/client.en.yml
@@ -58,6 +58,7 @@ en:
starred_channels_empty: "You haven't starred any channels yet. Star channels to see them here for quick access."
browse_all_channels: "Browse all channels"
see_in: "See in"
+ open_channel_menu: "Open channel menu"
move_to_channel:
title: "Move messages to channel"
instructions:
@@ -81,6 +82,8 @@ en:
join_channel: "Join channel"
leave_channel: "Leave channel"
leave_groupchat_info: "By leaving this group chat, you will no longer have access to it and won’t receive notifications related to it. To rejoin, you will need to be re-invited by a member of the group chat."
+ notification_settings: "Notification settings"
+ notification_settings_context: "Notifications"
join: "Join"
leave: "Leave"
save_label:
@@ -508,6 +511,7 @@ en:
follow: "Join"
followed: "Joined"
mute: "Mute channel"
+ unmute: "Unmute channel"
threading_enabled: "Enabled"
threading_disabled: "Disabled"
muted_on: "On"
diff --git a/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb b/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb
new file mode 100644
index 00000000000..ab0f3ab1aea
--- /dev/null
+++ b/plugins/chat/spec/system/chat_channel_sidebar_context_menu_spec.rb
@@ -0,0 +1,170 @@
+# frozen_string_literal: true
+
+RSpec.describe "Chat channel sidebar context menu", type: :system do
+ fab!(:current_user, :user)
+ fab!(:channel_1, :chat_channel)
+
+ let(:chat_page) { PageObjects::Pages::Chat.new }
+ let(:chat_sidebar_page) { PageObjects::Pages::ChatSidebar.new }
+
+ before do
+ chat_system_bootstrap
+ channel_1.add(current_user)
+ sign_in(current_user)
+ end
+
+ context "when navigating to channel settings" do
+ it "opens the channel settings page" do
+ chat_page.visit_channel(channel_1)
+ chat_sidebar_page.open_channel_settings(channel_1)
+ expect(page).to have_current_path("/chat/c/#{channel_1.slug}/#{channel_1.id}/info/settings")
+ end
+ end
+
+ context "when starring toggling starred channel" do
+ it "stars and unstars a channel" do
+ chat_page.visit_channel(channel_1)
+ chat_sidebar_page.toggle_star_channel(channel_1)
+
+ within(chat_sidebar_page.starred_section) do
+ expect(page).to have_css(".channel-#{channel_1.id}")
+ end
+ expect(channel_1.membership_for(current_user).starred).to be_truthy
+
+ chat_sidebar_page.toggle_star_channel(channel_1)
+
+ expect(chat_sidebar_page).to have_no_starred_channels_section
+ expect(channel_1.membership_for(current_user).starred).to be_falsy
+ end
+ end
+
+ context "when leaving a channel" do
+ fab!(:channel_2, :chat_channel)
+
+ before { channel_2.add(current_user) }
+
+ it "removes the channel from sidebar and redirects to another channel" do
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.remove_channel(channel_1)
+
+ expect(chat_sidebar_page).to have_no_channel(channel_1)
+ expect(page).to have_current_path(chat.channel_path(channel_2.slug, channel_2.id))
+ end
+
+ context "when removing the last followed channel" do
+ fab!(:dm_channel) do
+ Fabricate(:direct_message_channel, users: [current_user, Fabricate(:user)])
+ end
+
+ before do
+ channel_1.membership_for(current_user).update!(following: false)
+ channel_2.membership_for(current_user).update!(following: false)
+ end
+
+ it "redirects to browse page" do
+ chat_page.visit_channel(dm_channel)
+ chat_sidebar_page.remove_channel(dm_channel)
+
+ expect(page).to have_current_path("/chat/browse/open")
+ end
+ end
+
+ context "when removing a channel with a last chat channel set" do
+ fab!(:dm_channel) do
+ Fabricate(:direct_message_channel, users: [current_user, Fabricate(:user)])
+ end
+
+ before do
+ current_user.upsert_custom_fields(::Chat::LAST_CHAT_CHANNEL_ID => channel_1.id)
+ channel_1.add(current_user)
+ end
+
+ it "redirects to the last chat channel" do
+ chat_page.visit_channel(dm_channel)
+ chat_sidebar_page.remove_channel(dm_channel)
+
+ expect(page).to have_current_path(chat.channel_path(channel_1.slug, channel_1.id))
+ end
+ end
+ end
+
+ context "when changing notification settings" do
+ it "changes notification level to never" do
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.set_notification_level("never")
+
+ expect(channel_1.membership_for(current_user).reload.notification_level).to eq("never")
+ end
+
+ it "changes notification level to mention" do
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.set_notification_level("mention")
+
+ expect(channel_1.membership_for(current_user).reload.notification_level).to eq("mention")
+ end
+
+ it "changes notification level to always" do
+ channel_1.membership_for(current_user).update!(notification_level: "never")
+
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.set_notification_level("always")
+
+ expect(channel_1.membership_for(current_user).reload.notification_level).to eq("always")
+ end
+
+ it "highlights the current notification level" do
+ channel_1.membership_for(current_user).update!(notification_level: "mention")
+
+ chat_page.visit_channel(channel_1)
+
+ menu = chat_sidebar_page.open_notification_settings(channel_1)
+
+ expect(menu).to have_option(
+ ".chat-channel-sidebar-link-menu__notification-level-mention.-selected",
+ )
+ end
+ end
+
+ context "when muting and unmuting a channel" do
+ it "mutes an unmuted channel" do
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.toggle_mute_channel
+
+ expect(channel_1.membership_for(current_user).reload.muted).to eq(true)
+ end
+
+ it "unmutes a muted channel" do
+ channel_1.membership_for(current_user).update!(muted: true)
+
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.toggle_mute_channel
+
+ expect(channel_1.membership_for(current_user).reload.muted).to eq(false)
+ end
+
+ it "doesn't show unread indicators when channel is muted" do
+ other_user = Fabricate(:user)
+ channel_1.add(other_user)
+
+ chat_page.visit_channel(channel_1)
+
+ chat_sidebar_page.open_notification_settings(channel_1)
+ chat_sidebar_page.toggle_mute_channel
+
+ Fabricate(:chat_message_with_service, chat_channel: channel_1, user: other_user)
+
+ expect(chat_sidebar_page).to have_no_unread_channel(channel_1)
+ end
+ end
+end
diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb
index 287f04c04b3..29bafdf380b 100644
--- a/plugins/chat/spec/system/chat_channel_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe "Chat channel", type: :system do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:side_panel_page) { PageObjects::Pages::ChatSidePanel.new }
before do
diff --git a/plugins/chat/spec/system/kick_user_from_channel_spec.rb b/plugins/chat/spec/system/kick_user_from_channel_spec.rb
index b1574bd60fc..7c094ecdf3e 100644
--- a/plugins/chat/spec/system/kick_user_from_channel_spec.rb
+++ b/plugins/chat/spec/system/kick_user_from_channel_spec.rb
@@ -8,7 +8,7 @@ describe "Kick user from chat channel", type: :system do
let(:chat) { PageObjects::Pages::Chat.new }
let(:channel) { PageObjects::Pages::ChatChannel.new }
let(:dialog) { PageObjects::Components::Dialog.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
SiteSetting.navigation_menu = "sidebar"
diff --git a/plugins/chat/spec/system/last_visit_spec.rb b/plugins/chat/spec/system/last_visit_spec.rb
index 1b4230368e2..7358bc5919b 100644
--- a/plugins/chat/spec/system/last_visit_spec.rb
+++ b/plugins/chat/spec/system/last_visit_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "Last visit", type: :system do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
chat_system_bootstrap
diff --git a/plugins/chat/spec/system/list_channels/sidebar_spec.rb b/plugins/chat/spec/system/list_channels/sidebar_spec.rb
index 37b1e197587..2c6a3738263 100644
--- a/plugins/chat/spec/system/list_channels/sidebar_spec.rb
+++ b/plugins/chat/spec/system/list_channels/sidebar_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe "List channels | sidebar", type: :system do
let(:chat) { PageObjects::Pages::Chat.new }
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
let(:chat_sidebar) { PageObjects::Components::Chat::Sidebar.new }
+ let(:chat_sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
chat_system_bootstrap
@@ -186,11 +187,8 @@ RSpec.describe "List channels | sidebar", type: :system do
it "removes it from the sidebar" do
visit("/")
-
- find(".sidebar-row.channel-#{dm_channel_1.id}").hover
- find(".sidebar-row.channel-#{dm_channel_1.id} .sidebar-section-hover-button").click
-
- expect(page).to have_no_selector(".sidebar-row.channel-#{dm_channel_1.id}")
+ chat_sidebar_page.remove_channel(dm_channel_1)
+ expect(chat_sidebar_page).to have_no_channel(dm_channel_1)
end
end
end
diff --git a/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb b/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb
index edca2827d32..98323657fb7 100644
--- a/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb
+++ b/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
let!(:chat_page) { PageObjects::Pages::Chat.new }
let!(:channel_page) { PageObjects::Pages::ChatChannel.new }
let!(:thread_page) { PageObjects::Pages::ChatThread.new }
- let!(:sidebar) { PageObjects::Pages::Sidebar.new }
+ let!(:sidebar) { PageObjects::Pages::ChatSidebar.new }
before do
SiteSetting.navigation_menu = "sidebar"
diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb
index 0de48253cb7..ad8c1d61fac 100644
--- a/plugins/chat/spec/system/navigation_spec.rb
+++ b/plugins/chat/spec/system/navigation_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe "Navigation", type: :system do
let(:thread_list_page) { PageObjects::Components::Chat::ThreadList.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:side_panel_page) { PageObjects::Pages::ChatSidePanel.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:sidebar_component) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
diff --git a/plugins/chat/spec/system/page_objects/sidebar/chat_sidebar.rb b/plugins/chat/spec/system/page_objects/sidebar/chat_sidebar.rb
new file mode 100644
index 00000000000..1ef03d2e2a5
--- /dev/null
+++ b/plugins/chat/spec/system/page_objects/sidebar/chat_sidebar.rb
@@ -0,0 +1,159 @@
+# frozen_string_literal: true
+
+module PageObjects
+ module Pages
+ class ChatSidebar < PageObjects::Pages::Base
+ PUBLIC_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-channels']"
+ DM_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-dms']"
+ STARRED_CHANNELS_SECTION_SELECTOR =
+ ".sidebar-section[data-section-name='chat-starred-channels']"
+
+ def has_no_public_channels_section?
+ has_no_css?(PUBLIC_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def has_no_dm_channels_section?
+ has_no_css?(DM_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def has_no_starred_channels_section?
+ has_no_css?(STARRED_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def channels_section
+ find(PUBLIC_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def dms_section
+ find(DM_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def starred_section
+ find(STARRED_CHANNELS_SECTION_SELECTOR)
+ end
+
+ def open_browse
+ channels_section.find(".sidebar-section-header-button", visible: false).click
+ end
+
+ def open_channel(channel)
+ find(".sidebar-section-link.channel-#{channel.id}").click
+ end
+
+ def remove_channel(channel)
+ menu = open_channel_hover_menu(channel)
+ menu.option(".chat-channel-sidebar-link-menu__leave-channel").click
+ end
+
+ def open_channel_settings(channel)
+ menu = open_channel_hover_menu(channel)
+ menu.option(".chat-channel-sidebar-link-menu__channel-settings").click
+ end
+
+ def toggle_star_channel(channel)
+ menu = open_channel_hover_menu(channel)
+ menu.option(".chat-channel-sidebar-link-menu__star-channel").click
+ end
+
+ def channel_section_link_selector(channel)
+ ".sidebar-section-link.channel-#{channel.id}"
+ end
+
+ def open_channel_hover_menu(channel)
+ find(channel_section_link_selector(channel)).hover
+ first_level_hover_menu =
+ PageObjects::Components::DMenu.new(
+ "#{channel_section_link_selector(channel)} .sidebar-section-hover-button",
+ (
+ if channel.direct_message_channel?
+ "chat-direct-message-channel-menu"
+ else
+ "chat-channel-menu"
+ end
+ ),
+ )
+ first_level_hover_menu.expand
+ first_level_hover_menu
+ end
+
+ def find_channel(channel)
+ find(".sidebar-section-link.channel-#{channel.id}")
+ self
+ end
+
+ def has_no_channel?(channel)
+ has_no_css?(".sidebar-row.channel-#{channel.id}")
+ end
+
+ def has_user_threads_section?
+ has_css?(
+ ".sidebar-section-link[data-link-name='user-threads'][href='/chat/threads']",
+ text: I18n.t("js.chat.my_threads.title"),
+ )
+ end
+
+ def has_no_user_threads_section?
+ has_no_css?(
+ ".sidebar-section-link[data-link-name='user-threads'][href='/chat/threads']",
+ text: I18n.t("js.chat.my_threads.title"),
+ )
+ end
+
+ def has_unread_user_threads?
+ has_css?(
+ ".sidebar-section-link[data-link-name='user-threads'] .sidebar-section-link-content-badge.icon.unread",
+ )
+ end
+
+ def has_no_unread_user_threads?
+ has_no_css?(
+ ".sidebar-section-link[data-link-name='user-threads'] .sidebar-section-link-content-badge.icon.unread",
+ )
+ end
+
+ def has_unread_channel?(channel)
+ has_css?(
+ ".sidebar-section-link.channel-#{channel.id} .sidebar-section-link-content-badge:is(.unread, .urgent)",
+ )
+ end
+
+ def has_no_unread_channel?(channel)
+ has_no_css?(
+ ".sidebar-section-link.channel-#{channel.id} .sidebar-section-link-content-badge:is(.unread, .urgent)",
+ )
+ end
+
+ def has_active_channel?(channel)
+ has_css?(".sidebar-section-link.channel-#{channel.id}.active")
+ end
+
+ def has_no_active_channel?(channel)
+ has_no_css?(".sidebar-section-link.channel-#{channel.id}.active")
+ end
+
+ def open_notification_settings(channel)
+ menu = open_channel_hover_menu(channel)
+ notification_button =
+ menu.option(".chat-channel-sidebar-link-menu__open-notification-settings")
+ notification_button.click
+
+ PageObjects::Components::DMenu.new(
+ notification_button,
+ "chat-channel-menu-notification-submenu",
+ )
+ end
+
+ # Requires open_notification_settings to be called first
+ def set_notification_level(level)
+ find(".chat-channel-sidebar-link-menu__notification-level-#{level}").click
+ self
+ end
+
+ # Requires open_notification_settings to be called first
+ def toggle_mute_channel
+ find(".chat-channel-sidebar-link-menu__mute-channel").click
+ self
+ end
+ end
+ end
+end
diff --git a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb b/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb
deleted file mode 100644
index d5368e3d56e..00000000000
--- a/plugins/chat/spec/system/page_objects/sidebar/sidebar.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-# frozen_string_literal: true
-
-module PageObjects
- module Pages
- class Sidebar < PageObjects::Pages::Base
- PUBLIC_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-channels']"
- DM_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-dms']"
-
- def has_no_public_channels_section?
- has_no_css?(PUBLIC_CHANNELS_SECTION_SELECTOR)
- end
-
- def channels_section
- find(PUBLIC_CHANNELS_SECTION_SELECTOR)
- end
-
- def dms_section
- find(DM_CHANNELS_SECTION_SELECTOR)
- end
-
- def open_browse
- channels_section.find(".sidebar-section-header-button", visible: false).click
- end
-
- def open_channel(channel)
- find(".sidebar-section-link.channel-#{channel.id}").click
- end
-
- def remove_channel(channel)
- selector = ".sidebar-section-link.channel-#{channel.id}"
- find(selector).hover
- find(selector + " .sidebar-section-hover-button").click
- end
-
- def find_channel(channel)
- find(".sidebar-section-link.channel-#{channel.id}")
- self
- end
-
- def has_user_threads_section?
- has_css?(
- ".sidebar-section-link[data-link-name='user-threads'][href='/chat/threads']",
- text: I18n.t("js.chat.my_threads.title"),
- )
- end
-
- def has_no_user_threads_section?
- has_no_css?(
- ".sidebar-section-link[data-link-name='user-threads'][href='/chat/threads']",
- text: I18n.t("js.chat.my_threads.title"),
- )
- end
-
- def has_unread_user_threads?
- has_css?(
- ".sidebar-section-link[data-link-name='user-threads'] .sidebar-section-link-content-badge.icon.unread",
- )
- end
-
- def has_no_unread_user_threads?
- has_no_css?(
- ".sidebar-section-link[data-link-name='user-threads'] .sidebar-section-link-content-badge.icon.unread",
- )
- end
-
- def has_unread_channel?(channel)
- has_css?(
- ".sidebar-section-link.channel-#{channel.id} .sidebar-section-link-content-badge:is(.unread, .urgent)",
- )
- end
-
- def has_no_unread_channel?(channel)
- has_no_css?(
- ".sidebar-section-link.channel-#{channel.id} .sidebar-section-link-content-badge:is(.unread, .urgent)",
- )
- end
-
- def has_active_channel?(channel)
- has_css?(".sidebar-section-link.channel-#{channel.id}.active")
- end
-
- def has_no_active_channel?(channel)
- has_no_css?(".sidebar-section-link.channel-#{channel.id}.active")
- end
- end
- end
-end
diff --git a/plugins/chat/spec/system/removing_channel_spec.rb b/plugins/chat/spec/system/removing_channel_spec.rb
deleted file mode 100644
index 1880317a645..00000000000
--- a/plugins/chat/spec/system/removing_channel_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Removing channel", type: :system do
- fab!(:current_user, :user)
-
- let(:chat_page) { PageObjects::Pages::Chat.new }
- let(:chat_sidebar_page) { PageObjects::Pages::Sidebar.new }
-
- before do
- chat_system_bootstrap
- sign_in(current_user)
- end
-
- context "when removing last followed channel" do
- fab!(:channel_1, :chat_channel)
- fab!(:channel_2) { Fabricate(:direct_message_channel, users: [current_user, Fabricate(:user)]) }
-
- before do
- Fabricate(
- :user_chat_channel_membership,
- user: current_user,
- chat_channel: channel_1,
- following: false,
- )
- end
-
- it "redirects to browse page" do
- chat_page.visit_channel(channel_2)
- chat_sidebar_page.remove_channel(channel_2)
-
- expect(page).to have_current_path("/chat/browse/open")
- end
- end
-
- context "when removing channel" do
- fab!(:channel_1, :chat_channel)
- fab!(:channel_2) { Fabricate(:direct_message_channel, users: [current_user, Fabricate(:user)]) }
-
- before do
- current_user.upsert_custom_fields(::Chat::LAST_CHAT_CHANNEL_ID => channel_1.id)
- channel_1.add(current_user)
- end
-
- it "redirects to another followed channgel" do
- chat_page.visit_channel(channel_2)
- chat_sidebar_page.remove_channel(channel_2)
-
- expect(page).to have_current_path(chat.channel_path(channel_1.slug, channel_1.id))
- end
- end
-end
diff --git a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb b/plugins/chat/spec/system/separate_sidebar_mode_spec.rb
index 7206e2e06bf..dfb0a90caae 100644
--- a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb
+++ b/plugins/chat/spec/system/separate_sidebar_mode_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe "Separate sidebar mode", type: :system do
let(:chat_page) { PageObjects::Pages::Chat.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:sidebar_component) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
let(:header_component) { PageObjects::Components::Chat::Header.new }
diff --git a/plugins/chat/spec/system/shortcuts/mark_all_read_spec.rb b/plugins/chat/spec/system/shortcuts/mark_all_read_spec.rb
index b2cf955ab44..988230876c6 100644
--- a/plugins/chat/spec/system/shortcuts/mark_all_read_spec.rb
+++ b/plugins/chat/spec/system/shortcuts/mark_all_read_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe "Shortcuts | mark all read", type: :system do
fab!(:channel_2, :chat_channel)
fab!(:channel_3, :chat_channel)
- let(:chat_sidebar) { PageObjects::Pages::Sidebar.new }
+ let(:chat_sidebar) { PageObjects::Pages::ChatSidebar.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:drawer) { PageObjects::Pages::ChatDrawer.new }
diff --git a/plugins/chat/spec/system/shortcuts/sidebar_spec.rb b/plugins/chat/spec/system/shortcuts/sidebar_spec.rb
index da9c23b5da1..77023a0f9b4 100644
--- a/plugins/chat/spec/system/shortcuts/sidebar_spec.rb
+++ b/plugins/chat/spec/system/shortcuts/sidebar_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "Shortcuts | sidebar", type: :system do
fab!(:current_user, :admin)
let(:chat) { PageObjects::Pages::Chat.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
SiteSetting.navigation_menu = "sidebar"
diff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
index 4a9916190d1..2b156245ca0 100644
--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "Sidebar navigation menu", type: :system do
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:sidebar_component) { PageObjects::Components::NavigationMenu::Sidebar.new }
fab!(:current_user, :user)
diff --git a/plugins/chat/spec/system/sidebars_spec.rb b/plugins/chat/spec/system/sidebars_spec.rb
index aa836b8afa3..2cebed247fe 100644
--- a/plugins/chat/spec/system/sidebars_spec.rb
+++ b/plugins/chat/spec/system/sidebars_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe "Navigation", type: :system do
fab!(:category_channel)
fab!(:category_channel_2, :category_channel)
let(:chat_page) { PageObjects::Pages::Chat.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
chat_system_bootstrap(user, [category_channel, category_channel_2])
diff --git a/plugins/chat/spec/system/single_thread_spec.rb b/plugins/chat/spec/system/single_thread_spec.rb
index 3dcab16b1c7..acf5c9ad5ad 100644
--- a/plugins/chat/spec/system/single_thread_spec.rb
+++ b/plugins/chat/spec/system/single_thread_spec.rb
@@ -8,7 +8,7 @@ describe "Single thread in side panel", type: :system do
let(:side_panel) { PageObjects::Pages::ChatSidePanel.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
chat_system_bootstrap(current_user, [channel])
diff --git a/plugins/chat/spec/system/thread_tracking/full_page_spec.rb b/plugins/chat/spec/system/thread_tracking/full_page_spec.rb
index bddb13640e5..ff3b1eeec20 100644
--- a/plugins/chat/spec/system/thread_tracking/full_page_spec.rb
+++ b/plugins/chat/spec/system/thread_tracking/full_page_spec.rb
@@ -11,7 +11,7 @@ describe "Thread tracking state | full page", type: :system do
let(:thread_page) { PageObjects::Pages::ChatThread.new }
let(:channel_threads_page) { PageObjects::Pages::ChatChannelThreads.new }
let(:thread_list_page) { PageObjects::Components::Chat::ThreadList.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
chat_system_bootstrap(current_user, [channel])
diff --git a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb b/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
index 08f4e93b7f5..b90c53a28f1 100644
--- a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
+++ b/plugins/chat/spec/system/unfollow_dm_channel_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-RSpec.describe "Unfollow dm channel", type: :system do
+RSpec.describe "Unfollow DM channel", type: :system do
fab!(:current_user, :user)
fab!(:other_user, :user)
fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user, other_user]) }
let!(:chat_page) { PageObjects::Pages::Chat.new }
let!(:channel_page) { PageObjects::Pages::ChatChannel.new }
- let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
+ let!(:chat_sidebar_page) { PageObjects::Pages::ChatSidebar.new }
before do
SiteSetting.navigation_menu = "sidebar"
@@ -18,10 +18,8 @@ RSpec.describe "Unfollow dm channel", type: :system do
context "when receiving a message after unfollowing" do
it "correctly shows the channel" do
visit("/")
- find(".channel-#{dm_channel_1.id}").hover
- find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click
-
- expect(page).to have_no_css(".channel-#{dm_channel_1.id}")
+ chat_sidebar_page.remove_channel(dm_channel_1)
+ expect(chat_sidebar_page).to have_no_channel(dm_channel_1)
using_session(:user_1) do
text = "this is fine"
@@ -42,14 +40,15 @@ RSpec.describe "Unfollow dm channel", type: :system do
it "does not show the channel back in the starred section" do
visit("/")
- within(sidebar.sidebar_section_selector("chat-starred-channels")) do
+ within(chat_sidebar_page.starred_section) do
expect(page).to have_css(".channel-#{dm_channel_1.id}")
end
- find(".channel-#{dm_channel_1.id}").hover
- find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click
+ chat_sidebar_page.remove_channel(dm_channel_1)
- expect(page).to have_no_css(".channel-#{dm_channel_1.id}")
+ within(chat_sidebar_page.dms_section) do
+ expect(page).to have_no_css(".channel-#{dm_channel_1.id}")
+ end
using_session(:user_1) do
text = "this is fine"
@@ -59,9 +58,9 @@ RSpec.describe "Unfollow dm channel", type: :system do
expect(channel_page.messages).to have_message(text: text)
end
- expect(page).to have_no_css(sidebar.sidebar_section_selector("chat-starred-channels"))
+ expect(chat_sidebar_page).to have_no_starred_channels_section
- within(sidebar.sidebar_section_selector("chat-dms")) do
+ within(chat_sidebar_page.dms_section) do
expect(page).to have_css(".channel-#{dm_channel_1.id} .urgent", wait: 25)
end
end
diff --git a/plugins/chat/spec/system/user_threads_spec.rb b/plugins/chat/spec/system/user_threads_spec.rb
index 9aec1af1808..4c3a4ed4c32 100644
--- a/plugins/chat/spec/system/user_threads_spec.rb
+++ b/plugins/chat/spec/system/user_threads_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe "User threads", type: :system do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:user_threads_page) { PageObjects::Pages::UserThreads.new }
diff --git a/plugins/chat/spec/system/visit_channel_spec.rb b/plugins/chat/spec/system/visit_channel_spec.rb
index ec3ae158064..5a569f575af 100644
--- a/plugins/chat/spec/system/visit_channel_spec.rb
+++ b/plugins/chat/spec/system/visit_channel_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe "Visit channel", type: :system do
fab!(:inaccessible_dm_channel_1, :direct_message_channel)
let(:chat) { PageObjects::Pages::Chat.new }
- let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
+ let(:sidebar_page) { PageObjects::Pages::ChatSidebar.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:dialog) { PageObjects::Components::Dialog.new }
diff --git a/spec/system/page_objects/components/d_menu.rb b/spec/system/page_objects/components/d_menu.rb
index c1f890c5440..f0353b52f3b 100644
--- a/spec/system/page_objects/components/d_menu.rb
+++ b/spec/system/page_objects/components/d_menu.rb
@@ -5,12 +5,14 @@ module PageObjects
class DMenu < PageObjects::Components::Base
attr_reader :component
- def initialize(input)
- if input.is_a?(Capybara::Node::Element)
- @component = input
+ def initialize(trigger_input, identifier = nil)
+ if trigger_input.is_a?(Capybara::Node::Element)
+ @component = trigger_input
else
- @component = find(input)
+ @component = find(trigger_input)
end
+
+ @identifier = identifier
end
def expand
@@ -31,20 +33,28 @@ module PageObjects
!is_expanded?
end
+ def portal_with_identifier_selector
+ if @identifier.nil?
+ "#d-menu-portals"
+ else
+ "#d-menu-portals [data-identifier=\"#{@identifier}\"]"
+ end
+ end
+
def option(selector, match = nil)
params = {}
params[:match] = match if match
- within("#d-menu-portals") { find(selector, **params) }
+ within(portal_with_identifier_selector, visible: false) { find(selector, **params) }
end
def has_option?(selector, text = nil)
params = {}
params[:text] = text if text
- within("#d-menu-portals") { has_css?(selector, **params) }
+ within(portal_with_identifier_selector) { has_css?(selector, **params) }
end
def has_no_option?(selector)
- within("#d-menu-portals") { has_no_css?(selector) }
+ within(portal_with_identifier_selector) { has_no_css?(selector) }
end
def has_value?(value)