/* * Copyright 2025 New Vector Ltd. * * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial * Please see LICENSE files in the repository root for full details. */ import React, { type JSX, useState } from "react"; import { IconButton, Menu, MenuItem, Separator, ToggleMenuItem } from "@vector-im/compound-web"; import MarkAsReadIcon from "@vector-im/compound-design-tokens/assets/web/icons/mark-as-read"; import MarkAsUnreadIcon from "@vector-im/compound-design-tokens/assets/web/icons/mark-as-unread"; import FavouriteIcon from "@vector-im/compound-design-tokens/assets/web/icons/favourite"; import ArrowDownIcon from "@vector-im/compound-design-tokens/assets/web/icons/arrow-down"; import UserAddIcon from "@vector-im/compound-design-tokens/assets/web/icons/user-add"; import LinkIcon from "@vector-im/compound-design-tokens/assets/web/icons/link"; import LeaveIcon from "@vector-im/compound-design-tokens/assets/web/icons/leave"; import OverflowIcon from "@vector-im/compound-design-tokens/assets/web/icons/overflow-horizontal"; import NotificationIcon from "@vector-im/compound-design-tokens/assets/web/icons/notifications-solid"; import NotificationOffIcon from "@vector-im/compound-design-tokens/assets/web/icons/notifications-off-solid"; import CheckIcon from "@vector-im/compound-design-tokens/assets/web/icons/check"; import { type Room } from "matrix-js-sdk/src/matrix"; import { Flex } from "@element-hq/web-shared-components"; import classNames from "classnames"; import { _t } from "../../../../languageHandler"; import { type RoomListItemMenuViewState, useRoomListItemMenuViewModel, } from "../../../viewmodels/roomlist/RoomListItemMenuViewModel"; import { RoomNotifState } from "../../../../RoomNotifs"; interface RoomListItemMenuViewProps { /** * Additional class name for the root element. */ className?: string; /** * The room to display the menu for. */ room: Room; } /** * A view for the room list item menu. */ export function RoomListItemMenuView({ room, className }: RoomListItemMenuViewProps): JSX.Element { const vm = useRoomListItemMenuViewModel(room); return ( {vm.showMoreOptionsMenu && } {vm.showNotificationMenu && } ); } interface MoreOptionsMenuProps { /** * The view model state for the menu. */ vm: RoomListItemMenuViewState; } /** * The more options menu for the room list item. */ function MoreOptionsMenu({ vm }: MoreOptionsMenuProps): JSX.Element { const [open, setOpen] = useState(false); return ( } > ); } interface MoreOptionContentProps { /** * The view model state for the menu. */ vm: RoomListItemMenuViewState; } export function MoreOptionContent({ vm }: MoreOptionContentProps): JSX.Element { return (
e.stopPropagation()} > {vm.canMarkAsRead && ( evt.stopPropagation()} hideChevron={true} /> )} {vm.canMarkAsUnread && ( evt.stopPropagation()} hideChevron={true} /> )} evt.stopPropagation()} /> evt.stopPropagation()} /> {vm.canInvite && ( evt.stopPropagation()} hideChevron={true} /> )} {vm.canCopyRoomLink && ( evt.stopPropagation()} hideChevron={true} /> )} evt.stopPropagation()} hideChevron={true} />
); } interface NotificationMenuProps { /** * The view model state for the menu. */ vm: RoomListItemMenuViewState; } function NotificationMenu({ vm }: NotificationMenuProps): JSX.Element { const [open, setOpen] = useState(false); const checkComponent = ; return ( {vm.isNotificationMute ? : } } >
e.stopPropagation()} > vm.setRoomNotifState(RoomNotifState.AllMessages)} onClick={(evt) => evt.stopPropagation()} > {vm.isNotificationAllMessage && checkComponent} vm.setRoomNotifState(RoomNotifState.AllMessagesLoud)} onClick={(evt) => evt.stopPropagation()} > {vm.isNotificationAllMessageLoud && checkComponent} vm.setRoomNotifState(RoomNotifState.MentionsOnly)} onClick={(evt) => evt.stopPropagation()} > {vm.isNotificationMentionOnly && checkComponent} vm.setRoomNotifState(RoomNotifState.Mute)} onClick={(evt) => evt.stopPropagation()} > {vm.isNotificationMute && checkComponent}
); }