DEV: replaces topic-notifications-options by DMenu (#30298)

This commit introduces <NotificationsTracking /> which is a wrapper component around <DMenu /> which replaces the select-kit component <TopicNotificationsButton />.

Each tracking case has its dedicated component:

- topic -> `<TopicNotificationsTracking />`
- group -> `<GroupNotificationsTracking />`
- tag -> `<TagNotificationsTracking />`
- category -> `<CategoryNotificationsTracking />`
- chat thread -> `<ThreadNotificationsTracking />`
This commit is contained in:
Joffrey JAFFEUX
2024-12-16 19:59:18 +01:00
committed by GitHub
parent 062e4fb4f3
commit 41df705188
38 changed files with 565 additions and 289 deletions

View File

@ -1,19 +0,0 @@
import { classNames } from "@ember-decorators/component";
import NotificationsButtonComponent from "select-kit/components/notifications-button";
import {
pluginApiIdentifiers,
selectKitOptions,
} from "select-kit/components/select-kit";
import { threadNotificationButtonLevels } from "discourse/plugins/chat/discourse/lib/chat-notification-levels";
@classNames("thread-notifications-button")
@selectKitOptions({
i18nPrefix: "chat.thread.notifications",
showFullTitle: false,
btnCustomClasses: "btn-flat",
customStyle: true,
})
@pluginApiIdentifiers("thread-notifications-button")
export default class ChatThreadTrackingDropdown extends NotificationsButtonComponent {
content = threadNotificationButtonLevels;
}

View File

@ -5,7 +5,7 @@ import { service } from "@ember/service";
import concatClass from "discourse/helpers/concat-class";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { NotificationLevels } from "discourse/lib/notification-levels";
import ThreadTrackingDropdown from "discourse/plugins/chat/discourse/components/chat-thread-tracking-dropdown";
import ThreadNotificationsTracking from "discourse/plugins/chat/discourse/components/thread-notifications-tracking";
import UserChatThreadMembership from "discourse/plugins/chat/discourse/models/user-chat-thread-membership";
export default class ChatNavbarThreadTrackingDropdown extends Component {
@ -54,8 +54,8 @@ export default class ChatNavbarThreadTrackingDropdown extends Component {
}
<template>
<ThreadTrackingDropdown
@value={{this.threadNotificationLevel}}
<ThreadNotificationsTracking
@levelId={{this.threadNotificationLevel}}
@onChange={{this.updateThreadNotificationLevel}}
class={{concatClass
"c-navbar__thread-tracking-dropdown"

View File

@ -0,0 +1,17 @@
import NotificationsTracking from "discourse/components/notifications-tracking";
import { threadNotificationButtonLevels } from "discourse/plugins/chat/discourse/lib/chat-notification-levels";
const ThreadNotificationsTracking = <template>
<NotificationsTracking
@onChange={{@onChange}}
@levels={{threadNotificationButtonLevels}}
@levelId={{@levelId}}
@showCaret={{false}}
@showFullTitle={{false}}
@prefix="chat.thread.notifications"
class="thread-notifications-tracking"
@triggerClass="btn-transparent"
/>
</template>;
export default ThreadNotificationsTracking;

View File

@ -1,18 +0,0 @@
import { classNames } from "@ember-decorators/component";
import NotificationsButtonComponent from "select-kit/components/notifications-button";
import {
pluginApiIdentifiers,
selectKitOptions,
} from "select-kit/components/select-kit";
import { threadNotificationButtonLevels } from "discourse/plugins/chat/discourse/lib/chat-notification-levels";
@classNames("thread-notifications-button")
@selectKitOptions({
i18nPrefix: "chat.thread.notifications",
showFullTitle: false,
btnCustomClasses: "btn-flat",
})
@pluginApiIdentifiers("thread-notifications-button")
export default class ThreadNotificationsButton extends NotificationsButtonComponent {
content = threadNotificationButtonLevels;
}

View File

@ -22,23 +22,19 @@ module PageObjects
def notifications_button
@notifications_button ||=
PageObjects::Components::SelectKit.new(".thread-notifications-button")
PageObjects::Components::NotificationsTracking.new(".thread-notifications-tracking")
end
def notification_level=(level)
notifications_button.expand
notifications_button.select_row_by_value(
::Chat::UserChatThreadMembership.notification_levels[level.to_sym],
)
notifications_button.has_selected_value?(
notifications_button.toggle
notifications_button.select_level_id(
::Chat::UserChatThreadMembership.notification_levels[level.to_sym],
)
has_notification_level?(level)
end
def has_notification_level?(level)
select_kit =
PageObjects::Components::SelectKit.new(".c-navbar__thread-tracking-dropdown.-persisted")
select_kit.has_selected_value?(
notifications_button.has_selected_level_id?(
::Chat::UserChatThreadMembership.notification_levels[level.to_sym],
)
end